@coinlist-co/react 0.12.0 → 0.12.1-rc.0fa5c3b
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-ZFBEI3BW.js → chunk-3EOK47CQ.js} +20 -330
- package/dist/chunk-3EOK47CQ.js.map +1 -0
- package/dist/{chunk-F6WGUKZC.js → chunk-I5EHOV7V.js} +129 -3
- package/dist/chunk-I5EHOV7V.js.map +1 -0
- package/dist/{chunk-6CQHDASY.js → chunk-VSYGGTI6.js} +1173 -156
- package/dist/chunk-VSYGGTI6.js.map +1 -0
- package/dist/client/index.cjs +8559 -7690
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +116 -48
- package/dist/client/index.d.ts +116 -48
- package/dist/client/index.js +4059 -4007
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-DOm9VKVm.d.cts → collections-C6b-rJpx.d.ts} +1 -1
- package/dist/{collections-aCv-Wr2a.d.ts → collections-UYVlXbEh.d.cts} +1 -1
- package/dist/server/index.cjs +1291 -166
- 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-C-BxcYMj.d.cts} +362 -188
- package/dist/{config-DIaFzrMW.d.ts → tokens-namespace-C-BxcYMj.d.ts} +362 -188
- package/dist/universal/index.cjs +1103 -405
- 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 +16 -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
package/dist/server/index.cjs
CHANGED
|
@@ -215,6 +215,9 @@ var HEADER_API_VERSION = "X-API-Version";
|
|
|
215
215
|
var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
216
216
|
var API_VERSION = "2025-10-17";
|
|
217
217
|
|
|
218
|
+
// src/universal/core/shared/observability/log-cause.ts
|
|
219
|
+
var import_viem = require("viem");
|
|
220
|
+
|
|
218
221
|
// src/universal/types/errors.ts
|
|
219
222
|
var NotImplementedError = class extends Error {
|
|
220
223
|
constructor(message = "Not implemented yet") {
|
|
@@ -267,8 +270,32 @@ function classifyLogCause(error) {
|
|
|
267
270
|
if (error instanceof NotImplementedError) {
|
|
268
271
|
return { type: "not-implemented" };
|
|
269
272
|
}
|
|
273
|
+
if (error instanceof import_viem.BaseError) {
|
|
274
|
+
const http2 = error.walk((e) => e instanceof HttpError);
|
|
275
|
+
if (http2 instanceof HttpError) {
|
|
276
|
+
return httpCause(http2);
|
|
277
|
+
}
|
|
278
|
+
return { type: "rpc", reason: rpcFailureReason(error) };
|
|
279
|
+
}
|
|
270
280
|
return { type: "generic-error", name: errorName(error) };
|
|
271
281
|
}
|
|
282
|
+
function rpcFailureReason(error) {
|
|
283
|
+
if (error.walk((e) => e instanceof import_viem.ContractFunctionRevertedError)) {
|
|
284
|
+
return "reverted";
|
|
285
|
+
}
|
|
286
|
+
if (error.walk((e) => e instanceof import_viem.RpcError)) {
|
|
287
|
+
return "node-rejected";
|
|
288
|
+
}
|
|
289
|
+
if (error.walk(
|
|
290
|
+
(e) => e instanceof import_viem.HttpRequestError || e instanceof import_viem.WebSocketRequestError || e instanceof import_viem.SocketClosedError || e instanceof import_viem.TimeoutError
|
|
291
|
+
)) {
|
|
292
|
+
return "transport";
|
|
293
|
+
}
|
|
294
|
+
if (error instanceof import_viem.ContractFunctionExecutionError) {
|
|
295
|
+
return "malformed-response";
|
|
296
|
+
}
|
|
297
|
+
return "unknown";
|
|
298
|
+
}
|
|
272
299
|
function describeErrorUnredacted(error) {
|
|
273
300
|
if (error instanceof HttpError) {
|
|
274
301
|
return describeHttpErrorRedacted(error);
|
|
@@ -457,9 +484,9 @@ var HttpClient = class {
|
|
|
457
484
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
458
485
|
return url;
|
|
459
486
|
}
|
|
460
|
-
const
|
|
487
|
+
const base2 = this.config.baseUrl.replace(/\/$/, "");
|
|
461
488
|
const path = url.startsWith("/") ? url : `/${url}`;
|
|
462
|
-
return
|
|
489
|
+
return base2 + path;
|
|
463
490
|
}
|
|
464
491
|
async runBeforeRequestMiddleware(initialRequest) {
|
|
465
492
|
let request = initialRequest;
|
|
@@ -1051,6 +1078,10 @@ var Asset = {
|
|
|
1051
1078
|
})
|
|
1052
1079
|
};
|
|
1053
1080
|
|
|
1081
|
+
// src/universal/types/trading.ts
|
|
1082
|
+
var Ticker = (value) => value;
|
|
1083
|
+
var Isin = (value) => value;
|
|
1084
|
+
|
|
1054
1085
|
// src/universal/types/offer-detail.ts
|
|
1055
1086
|
var OfferOptionId = (value) => value;
|
|
1056
1087
|
var OfferOptionSlug = (value) => value;
|
|
@@ -1103,6 +1134,8 @@ var OfferDetail = {
|
|
|
1103
1134
|
`OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
|
|
1104
1135
|
);
|
|
1105
1136
|
}
|
|
1137
|
+
const isin = notBlankStringOrNull(dto.isin);
|
|
1138
|
+
const ticker = notBlankStringOrNull(dto.ticker);
|
|
1106
1139
|
return {
|
|
1107
1140
|
id: OfferId(dto.id),
|
|
1108
1141
|
slug: OfferSlug(dto.slug),
|
|
@@ -1117,6 +1150,11 @@ var OfferDetail = {
|
|
|
1117
1150
|
bannerUrl: dto.banner_url,
|
|
1118
1151
|
logoUrl: dto.logo_url,
|
|
1119
1152
|
category: dto.category,
|
|
1153
|
+
issuer: notBlankStringOrNull(dto.issuer),
|
|
1154
|
+
isin: isin === null ? null : Isin(isin),
|
|
1155
|
+
ticker: ticker === null ? null : Ticker(ticker),
|
|
1156
|
+
instrumentType: notBlankStringOrNull(dto.instrument_type),
|
|
1157
|
+
listingVenue: notBlankStringOrNull(dto.listing_venue),
|
|
1120
1158
|
startsAt: new Date(dto.starts_at),
|
|
1121
1159
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
1122
1160
|
faqs: dto.faqs.map(FaqItem.fromDto),
|
|
@@ -1441,6 +1479,151 @@ var ServerRequirementsNamespaceImpl = class extends RequirementsNamespaceImpl {
|
|
|
1441
1479
|
// src/universal/api/nabu/config.ts
|
|
1442
1480
|
var NABU_BASE_URL = "https://asset.coinlist.co";
|
|
1443
1481
|
|
|
1482
|
+
// src/universal/api/rpc/public-clients.ts
|
|
1483
|
+
var import_viem3 = require("viem");
|
|
1484
|
+
|
|
1485
|
+
// src/universal/api/rpc/frontline-transport.ts
|
|
1486
|
+
var import_viem2 = require("viem");
|
|
1487
|
+
function frontlineTransport(api, chain, logger = null) {
|
|
1488
|
+
const log = internalLogger(logger, "RPC");
|
|
1489
|
+
let nextId = 0;
|
|
1490
|
+
return (0, import_viem2.custom)(
|
|
1491
|
+
{
|
|
1492
|
+
async request({ method, params }) {
|
|
1493
|
+
const id = ++nextId;
|
|
1494
|
+
return sendRpc({ api, log, chain, id, method, params });
|
|
1495
|
+
}
|
|
1496
|
+
},
|
|
1497
|
+
// The `Sender` below already retries: `requestRetryMiddleware` makes three
|
|
1498
|
+
// attempts at a 5xx and `renewSessionMiddleware` re-sends once after a 401.
|
|
1499
|
+
// viem's own default is `retryCount: 3`, and it applies on top: an
|
|
1500
|
+
// `HttpError` carries no numeric `code`, so `buildRequest` wraps it in
|
|
1501
|
+
// `UnknownRpcError` (`code === -1`) and `shouldRetry` says yes. That reruns
|
|
1502
|
+
// the whole pipeline four times - twelve requests for one `eth_call`, and
|
|
1503
|
+
// with multicall batching one `eth_call` is a screen's worth of reads. The
|
|
1504
|
+
// SDK's retry policy is the one that applies, so viem's is turned off.
|
|
1505
|
+
{ retryCount: 0 }
|
|
1506
|
+
);
|
|
1507
|
+
}
|
|
1508
|
+
async function sendRpc({
|
|
1509
|
+
api,
|
|
1510
|
+
log,
|
|
1511
|
+
chain,
|
|
1512
|
+
id,
|
|
1513
|
+
method,
|
|
1514
|
+
params
|
|
1515
|
+
}) {
|
|
1516
|
+
const url = rpcPath(chain);
|
|
1517
|
+
const startedAt = Date.now();
|
|
1518
|
+
log.debug(() => ({
|
|
1519
|
+
msg: "rpc call sent",
|
|
1520
|
+
fields: { id, method, chain, params }
|
|
1521
|
+
}));
|
|
1522
|
+
const response = await sendEnvelope(api, url, {
|
|
1523
|
+
jsonrpc: "2.0",
|
|
1524
|
+
id,
|
|
1525
|
+
method,
|
|
1526
|
+
params
|
|
1527
|
+
});
|
|
1528
|
+
const elapsed = Date.now() - startedAt;
|
|
1529
|
+
if (response.error) {
|
|
1530
|
+
const error = new import_viem2.RpcRequestError({
|
|
1531
|
+
body: { method, params },
|
|
1532
|
+
error: response.error,
|
|
1533
|
+
url
|
|
1534
|
+
});
|
|
1535
|
+
log.warning(
|
|
1536
|
+
() => ({
|
|
1537
|
+
msg: "rpc call rejected",
|
|
1538
|
+
cause: { type: "rpc", reason: "node-rejected" },
|
|
1539
|
+
fields: {
|
|
1540
|
+
method,
|
|
1541
|
+
chain,
|
|
1542
|
+
duration_ms: elapsed,
|
|
1543
|
+
"rpc.error_code": response.error?.code ?? null
|
|
1544
|
+
}
|
|
1545
|
+
}),
|
|
1546
|
+
error
|
|
1547
|
+
);
|
|
1548
|
+
throw error;
|
|
1549
|
+
}
|
|
1550
|
+
log.info(() => ({
|
|
1551
|
+
msg: "rpc call",
|
|
1552
|
+
fields: { method, chain, duration_ms: elapsed }
|
|
1553
|
+
}));
|
|
1554
|
+
return response.result;
|
|
1555
|
+
}
|
|
1556
|
+
function rpcPath(chain) {
|
|
1557
|
+
return `/v1/chains/${encodeURIComponent(chain)}/rpc`;
|
|
1558
|
+
}
|
|
1559
|
+
async function sendEnvelope(api, url, body) {
|
|
1560
|
+
try {
|
|
1561
|
+
return await api.send({
|
|
1562
|
+
method: "POST",
|
|
1563
|
+
url,
|
|
1564
|
+
body,
|
|
1565
|
+
attributes: Attributes.protected()
|
|
1566
|
+
});
|
|
1567
|
+
} catch (error) {
|
|
1568
|
+
if (error instanceof HttpError && isJsonRpcError(error.response.body)) {
|
|
1569
|
+
return error.response.body;
|
|
1570
|
+
}
|
|
1571
|
+
throw error;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
function isJsonRpcError(body) {
|
|
1575
|
+
if (typeof body !== "object" || body === null || !("error" in body)) {
|
|
1576
|
+
return false;
|
|
1577
|
+
}
|
|
1578
|
+
const { error } = body;
|
|
1579
|
+
return typeof error === "object" && error !== null && "code" in error && typeof error.code === "number";
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
// src/universal/core/shared/blockchain/chain.ts
|
|
1583
|
+
var import_chains = require("viem/chains");
|
|
1584
|
+
|
|
1585
|
+
// src/universal/types/blockchain/ui.ts
|
|
1586
|
+
var FormattedAmountAssetUi = (value) => value;
|
|
1587
|
+
|
|
1588
|
+
// src/universal/core/shared/blockchain/chain.ts
|
|
1589
|
+
var VIEM_CHAINS = {
|
|
1590
|
+
ethereum_mainnet: import_chains.mainnet,
|
|
1591
|
+
ethereum_sepolia: import_chains.sepolia,
|
|
1592
|
+
base_mainnet: import_chains.base,
|
|
1593
|
+
base_sepolia: import_chains.baseSepolia
|
|
1594
|
+
};
|
|
1595
|
+
function viemChain(chain) {
|
|
1596
|
+
return VIEM_CHAINS[chain];
|
|
1597
|
+
}
|
|
1598
|
+
function chainFromId(chainId) {
|
|
1599
|
+
const chains = Object.keys(VIEM_CHAINS);
|
|
1600
|
+
const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
|
|
1601
|
+
if (!chain) {
|
|
1602
|
+
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
1603
|
+
}
|
|
1604
|
+
return chain;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
// src/universal/api/rpc/public-clients.ts
|
|
1608
|
+
function publicClients(api, config, logger = null) {
|
|
1609
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1610
|
+
return (chain) => {
|
|
1611
|
+
const cached = cache.get(chain);
|
|
1612
|
+
if (cached) return cached;
|
|
1613
|
+
const client = (0, import_viem3.createPublicClient)({
|
|
1614
|
+
chain: viemChain(chain),
|
|
1615
|
+
transport: transportFor(api, config?.[chain], chain, logger),
|
|
1616
|
+
batch: { multicall: true }
|
|
1617
|
+
});
|
|
1618
|
+
cache.set(chain, client);
|
|
1619
|
+
return client;
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
function transportFor(api, override, chain, logger) {
|
|
1623
|
+
if (override === void 0) return frontlineTransport(api, chain, logger);
|
|
1624
|
+
return typeof override === "string" ? (0, import_viem3.http)(override) : override;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1444
1627
|
// src/universal/types/providers/coin-list/token-sale.ts
|
|
1445
1628
|
var ParticipationId = (value) => value;
|
|
1446
1629
|
var Blockchain = (value) => value;
|
|
@@ -1555,36 +1738,15 @@ var CoinListTokenSaleNamespaceImpl = class {
|
|
|
1555
1738
|
};
|
|
1556
1739
|
|
|
1557
1740
|
// src/universal/core/shared/blockchain/formatters.ts
|
|
1558
|
-
var
|
|
1559
|
-
|
|
1560
|
-
// src/universal/types/blockchain/ui.ts
|
|
1561
|
-
var FormattedAmountAssetUi = (value) => value;
|
|
1562
|
-
|
|
1563
|
-
// src/universal/core/shared/blockchain/formatters.ts
|
|
1741
|
+
var import_viem4 = require("viem");
|
|
1564
1742
|
function formatRawAmount(amount) {
|
|
1565
|
-
return (0,
|
|
1743
|
+
return (0, import_viem4.formatUnits)(amount.raw, amount.decimals);
|
|
1566
1744
|
}
|
|
1567
1745
|
var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
|
|
1568
1746
|
var USD_FRACTION_DIGITS = AssetDecimals(2);
|
|
1569
1747
|
|
|
1570
|
-
// src/universal/core/shared/blockchain/chain.ts
|
|
1571
|
-
var CHAIN_IDS = {
|
|
1572
|
-
ethereum_mainnet: 1,
|
|
1573
|
-
ethereum_sepolia: 11155111,
|
|
1574
|
-
base_mainnet: 8453,
|
|
1575
|
-
base_sepolia: 84532
|
|
1576
|
-
};
|
|
1577
|
-
function chainFromId(chainId) {
|
|
1578
|
-
const chains = Object.keys(CHAIN_IDS);
|
|
1579
|
-
const chain = chains.find((c) => String(CHAIN_IDS[c]) === chainId);
|
|
1580
|
-
if (!chain) {
|
|
1581
|
-
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
1582
|
-
}
|
|
1583
|
-
return chain;
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
1748
|
// src/universal/core/shared/blockchain/math.ts
|
|
1587
|
-
var
|
|
1749
|
+
var import_viem5 = require("viem");
|
|
1588
1750
|
function blockchainAmountFromRawOrThrow({
|
|
1589
1751
|
label,
|
|
1590
1752
|
raw,
|
|
@@ -1607,9 +1769,6 @@ function blockchainAmountFromRawOrThrow({
|
|
|
1607
1769
|
}
|
|
1608
1770
|
}
|
|
1609
1771
|
|
|
1610
|
-
// src/universal/types/trading.ts
|
|
1611
|
-
var Ticker = (value) => value;
|
|
1612
|
-
|
|
1613
1772
|
// src/universal/types/providers/ondo/ondo.ts
|
|
1614
1773
|
var OndoTradingStatus = {
|
|
1615
1774
|
fromDto: (dto) => {
|
|
@@ -1904,39 +2063,42 @@ var OndoNamespaceImpl = class {
|
|
|
1904
2063
|
};
|
|
1905
2064
|
|
|
1906
2065
|
// src/universal/types/providers/superstate/swap.ts
|
|
1907
|
-
var SwapAuthorization = {
|
|
1908
|
-
fromDto: (dto) => ({
|
|
1909
|
-
authorized: dto.authorized
|
|
1910
|
-
})
|
|
1911
|
-
};
|
|
1912
2066
|
var SwapPreview = {
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
)
|
|
1918
|
-
fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
|
|
1919
|
-
outputAmount: parseUint256(
|
|
1920
|
-
BigInt(dto.receive_output_amount),
|
|
1921
|
-
"SwapPreview.receive_output_amount"
|
|
1922
|
-
)
|
|
2067
|
+
/** Maps the contract's `Preview { input, fee, output }` struct. */
|
|
2068
|
+
fromContract: (preview) => ({
|
|
2069
|
+
inputAmount: parseUint256(preview.input, "SwapPreview.input"),
|
|
2070
|
+
fee: parseUint256(preview.fee, "SwapPreview.fee"),
|
|
2071
|
+
outputAmount: parseUint256(preview.output, "SwapPreview.output")
|
|
1923
2072
|
})
|
|
1924
2073
|
};
|
|
2074
|
+
var PauseFlags = (value) => value;
|
|
1925
2075
|
var SwapStatus = {
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
2076
|
+
/**
|
|
2077
|
+
* Maps the contract's `Status { uint32 flags; State state }` struct, where
|
|
2078
|
+
* `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
|
|
2079
|
+
*
|
|
2080
|
+
* `flags` is carried onto the `paused` arm only. On the other two the
|
|
2081
|
+
* contract sets it to a self-identifying marker rather than to information -
|
|
2082
|
+
* so repeating it would invite a caller to read meaning into a constant.
|
|
2083
|
+
*
|
|
2084
|
+
* @throws ValidationError on a `state` outside the enum. A contract that has
|
|
2085
|
+
* grown a fourth state is one the SDK does not model, and guessing `active`
|
|
2086
|
+
* would let a halted swap read as a live one.
|
|
2087
|
+
*/
|
|
2088
|
+
fromContract: (status) => {
|
|
2089
|
+
switch (status.state) {
|
|
2090
|
+
case 0:
|
|
2091
|
+
return { state: "active" };
|
|
2092
|
+
case 1:
|
|
2093
|
+
return { state: "paused", pausedLevels: PauseFlags(status.flags) };
|
|
2094
|
+
case 2:
|
|
2095
|
+
return { state: "stopped" };
|
|
2096
|
+
default:
|
|
2097
|
+
throw new ValidationError(
|
|
2098
|
+
`SwapStatus.state: unknown contract state (${status.state})`
|
|
2099
|
+
);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
1940
2102
|
};
|
|
1941
2103
|
var AllowWalletResponse = {
|
|
1942
2104
|
fromDto: (dto) => {
|
|
@@ -1961,84 +2123,6 @@ var AllowWalletResponse = {
|
|
|
1961
2123
|
};
|
|
1962
2124
|
|
|
1963
2125
|
// src/universal/api/frontline/providers/superstate/swap.ts
|
|
1964
|
-
async function getSwapAuthorization(api, params) {
|
|
1965
|
-
const dto = await api.send({
|
|
1966
|
-
method: "GET",
|
|
1967
|
-
url: "/v1/wallet/authorized",
|
|
1968
|
-
queryParams: {
|
|
1969
|
-
chain: params.chain,
|
|
1970
|
-
contract_address: params.contractAddress,
|
|
1971
|
-
wallet_address: params.walletAddress
|
|
1972
|
-
},
|
|
1973
|
-
attributes: Attributes.protected()
|
|
1974
|
-
});
|
|
1975
|
-
return SwapAuthorization.fromDto(dto);
|
|
1976
|
-
}
|
|
1977
|
-
async function getSwapOutputToken(api, params) {
|
|
1978
|
-
const dto = await api.send({
|
|
1979
|
-
method: "GET",
|
|
1980
|
-
url: "/v1/swap/output-token",
|
|
1981
|
-
queryParams: {
|
|
1982
|
-
chain: params.chain,
|
|
1983
|
-
contract_address: params.contractAddress
|
|
1984
|
-
},
|
|
1985
|
-
attributes: Attributes.protected()
|
|
1986
|
-
});
|
|
1987
|
-
return toErc20Asset(dto);
|
|
1988
|
-
}
|
|
1989
|
-
async function getSwapPreview(api, params) {
|
|
1990
|
-
const dto = await api.send({
|
|
1991
|
-
method: "GET",
|
|
1992
|
-
url: "/v1/swap/preview",
|
|
1993
|
-
queryParams: {
|
|
1994
|
-
chain: params.chain,
|
|
1995
|
-
contract_address: params.contractAddress,
|
|
1996
|
-
input_token: params.inputToken,
|
|
1997
|
-
amount: params.amount.toString()
|
|
1998
|
-
},
|
|
1999
|
-
attributes: Attributes.protected()
|
|
2000
|
-
});
|
|
2001
|
-
return SwapPreview.fromDto(dto);
|
|
2002
|
-
}
|
|
2003
|
-
async function getSwapStatus(api, params) {
|
|
2004
|
-
const dto = await api.send({
|
|
2005
|
-
method: "GET",
|
|
2006
|
-
url: "/v1/swap/status",
|
|
2007
|
-
queryParams: {
|
|
2008
|
-
chain: params.chain,
|
|
2009
|
-
contract_address: params.contractAddress
|
|
2010
|
-
},
|
|
2011
|
-
attributes: Attributes.protected()
|
|
2012
|
-
});
|
|
2013
|
-
return SwapStatus.fromDto(dto);
|
|
2014
|
-
}
|
|
2015
|
-
async function getTokenAllowance(api, params) {
|
|
2016
|
-
const dto = await api.send({
|
|
2017
|
-
method: "GET",
|
|
2018
|
-
url: "/v1/token/allowance",
|
|
2019
|
-
queryParams: {
|
|
2020
|
-
chain: params.chain,
|
|
2021
|
-
token_address: params.tokenAddress,
|
|
2022
|
-
owner: params.owner,
|
|
2023
|
-
spender: params.spender
|
|
2024
|
-
},
|
|
2025
|
-
attributes: Attributes.protected()
|
|
2026
|
-
});
|
|
2027
|
-
return TokenAllowance.fromDto(dto);
|
|
2028
|
-
}
|
|
2029
|
-
async function getTokenBalance(api, params) {
|
|
2030
|
-
const dto = await api.send({
|
|
2031
|
-
method: "GET",
|
|
2032
|
-
url: "/v1/token/balance",
|
|
2033
|
-
queryParams: {
|
|
2034
|
-
chain: params.chain,
|
|
2035
|
-
token_address: params.tokenAddress,
|
|
2036
|
-
owner: params.owner
|
|
2037
|
-
},
|
|
2038
|
-
attributes: Attributes.protected()
|
|
2039
|
-
});
|
|
2040
|
-
return TokenBalance.fromDto(dto);
|
|
2041
|
-
}
|
|
2042
2126
|
async function allowWallet(api, params) {
|
|
2043
2127
|
const dto = await api.send({
|
|
2044
2128
|
method: "POST",
|
|
@@ -2052,11 +2136,1025 @@ async function allowWallet(api, params) {
|
|
|
2052
2136
|
});
|
|
2053
2137
|
return AllowWalletResponse.fromDto(dto);
|
|
2054
2138
|
}
|
|
2055
|
-
|
|
2139
|
+
|
|
2140
|
+
// src/universal/core/checkout/superstate/blockchain/abi.ts
|
|
2141
|
+
var SUPERSTATE_SWAP_ABI = [
|
|
2142
|
+
{
|
|
2143
|
+
type: "function",
|
|
2144
|
+
name: "KIND",
|
|
2145
|
+
inputs: [],
|
|
2146
|
+
outputs: [
|
|
2147
|
+
{
|
|
2148
|
+
name: "",
|
|
2149
|
+
type: "uint16",
|
|
2150
|
+
internalType: "uint16"
|
|
2151
|
+
}
|
|
2152
|
+
],
|
|
2153
|
+
stateMutability: "view"
|
|
2154
|
+
},
|
|
2155
|
+
{
|
|
2156
|
+
type: "function",
|
|
2157
|
+
name: "ONE_HUNDRED_P",
|
|
2158
|
+
inputs: [],
|
|
2159
|
+
outputs: [
|
|
2160
|
+
{
|
|
2161
|
+
name: "",
|
|
2162
|
+
type: "uint256",
|
|
2163
|
+
internalType: "uint256"
|
|
2164
|
+
}
|
|
2165
|
+
],
|
|
2166
|
+
stateMutability: "view"
|
|
2167
|
+
},
|
|
2168
|
+
{
|
|
2169
|
+
type: "function",
|
|
2170
|
+
name: "SWAP_LEVEL",
|
|
2171
|
+
inputs: [],
|
|
2172
|
+
outputs: [
|
|
2173
|
+
{
|
|
2174
|
+
name: "",
|
|
2175
|
+
type: "uint32",
|
|
2176
|
+
internalType: "uint32"
|
|
2177
|
+
}
|
|
2178
|
+
],
|
|
2179
|
+
stateMutability: "view"
|
|
2180
|
+
},
|
|
2181
|
+
{
|
|
2182
|
+
type: "function",
|
|
2183
|
+
name: "VERSION",
|
|
2184
|
+
inputs: [],
|
|
2185
|
+
outputs: [
|
|
2186
|
+
{
|
|
2187
|
+
name: "",
|
|
2188
|
+
type: "uint16",
|
|
2189
|
+
internalType: "uint16"
|
|
2190
|
+
}
|
|
2191
|
+
],
|
|
2192
|
+
stateMutability: "view"
|
|
2193
|
+
},
|
|
2194
|
+
{
|
|
2195
|
+
type: "function",
|
|
2196
|
+
name: "authorized",
|
|
2197
|
+
inputs: [
|
|
2198
|
+
{
|
|
2199
|
+
name: "user",
|
|
2200
|
+
type: "address",
|
|
2201
|
+
internalType: "address"
|
|
2202
|
+
}
|
|
2203
|
+
],
|
|
2204
|
+
outputs: [
|
|
2205
|
+
{
|
|
2206
|
+
name: "",
|
|
2207
|
+
type: "bool",
|
|
2208
|
+
internalType: "bool"
|
|
2209
|
+
}
|
|
2210
|
+
],
|
|
2211
|
+
stateMutability: "view"
|
|
2212
|
+
},
|
|
2213
|
+
{
|
|
2214
|
+
type: "function",
|
|
2215
|
+
name: "bpp",
|
|
2216
|
+
inputs: [
|
|
2217
|
+
{
|
|
2218
|
+
name: "amount",
|
|
2219
|
+
type: "uint256",
|
|
2220
|
+
internalType: "uint256"
|
|
2221
|
+
}
|
|
2222
|
+
],
|
|
2223
|
+
outputs: [
|
|
2224
|
+
{
|
|
2225
|
+
name: "",
|
|
2226
|
+
type: "uint256",
|
|
2227
|
+
internalType: "uint256"
|
|
2228
|
+
}
|
|
2229
|
+
],
|
|
2230
|
+
stateMutability: "view"
|
|
2231
|
+
},
|
|
2232
|
+
{
|
|
2233
|
+
type: "function",
|
|
2234
|
+
name: "bps",
|
|
2235
|
+
inputs: [],
|
|
2236
|
+
outputs: [
|
|
2237
|
+
{
|
|
2238
|
+
name: "",
|
|
2239
|
+
type: "uint256",
|
|
2240
|
+
internalType: "uint256"
|
|
2241
|
+
}
|
|
2242
|
+
],
|
|
2243
|
+
stateMutability: "view"
|
|
2244
|
+
},
|
|
2245
|
+
{
|
|
2246
|
+
type: "function",
|
|
2247
|
+
name: "cancelOwnershipHandover",
|
|
2248
|
+
inputs: [],
|
|
2249
|
+
outputs: [],
|
|
2250
|
+
stateMutability: "payable"
|
|
2251
|
+
},
|
|
2252
|
+
{
|
|
2253
|
+
type: "function",
|
|
2254
|
+
name: "completeOwnershipHandover",
|
|
2255
|
+
inputs: [
|
|
2256
|
+
{
|
|
2257
|
+
name: "pendingOwner",
|
|
2258
|
+
type: "address",
|
|
2259
|
+
internalType: "address"
|
|
2260
|
+
}
|
|
2261
|
+
],
|
|
2262
|
+
outputs: [],
|
|
2263
|
+
stateMutability: "payable"
|
|
2264
|
+
},
|
|
2265
|
+
{
|
|
2266
|
+
type: "function",
|
|
2267
|
+
name: "fee",
|
|
2268
|
+
inputs: [
|
|
2269
|
+
{
|
|
2270
|
+
name: "amount",
|
|
2271
|
+
type: "uint256",
|
|
2272
|
+
internalType: "uint256"
|
|
2273
|
+
}
|
|
2274
|
+
],
|
|
2275
|
+
outputs: [
|
|
2276
|
+
{
|
|
2277
|
+
name: "",
|
|
2278
|
+
type: "uint256",
|
|
2279
|
+
internalType: "uint256"
|
|
2280
|
+
},
|
|
2281
|
+
{
|
|
2282
|
+
name: "",
|
|
2283
|
+
type: "uint256",
|
|
2284
|
+
internalType: "uint256"
|
|
2285
|
+
}
|
|
2286
|
+
],
|
|
2287
|
+
stateMutability: "view"
|
|
2288
|
+
},
|
|
2289
|
+
{
|
|
2290
|
+
type: "function",
|
|
2291
|
+
name: "id",
|
|
2292
|
+
inputs: [],
|
|
2293
|
+
outputs: [
|
|
2294
|
+
{
|
|
2295
|
+
name: "",
|
|
2296
|
+
type: "bytes32",
|
|
2297
|
+
internalType: "bytes32"
|
|
2298
|
+
}
|
|
2299
|
+
],
|
|
2300
|
+
stateMutability: "view"
|
|
2301
|
+
},
|
|
2302
|
+
{
|
|
2303
|
+
type: "function",
|
|
2304
|
+
name: "inputTokens",
|
|
2305
|
+
inputs: [
|
|
2306
|
+
{
|
|
2307
|
+
name: "",
|
|
2308
|
+
type: "address",
|
|
2309
|
+
internalType: "address"
|
|
2310
|
+
}
|
|
2311
|
+
],
|
|
2312
|
+
outputs: [
|
|
2313
|
+
{
|
|
2314
|
+
name: "",
|
|
2315
|
+
type: "bool",
|
|
2316
|
+
internalType: "bool"
|
|
2317
|
+
}
|
|
2318
|
+
],
|
|
2319
|
+
stateMutability: "view"
|
|
2320
|
+
},
|
|
2321
|
+
{
|
|
2322
|
+
type: "function",
|
|
2323
|
+
name: "outputToken",
|
|
2324
|
+
inputs: [],
|
|
2325
|
+
outputs: [
|
|
2326
|
+
{
|
|
2327
|
+
name: "",
|
|
2328
|
+
type: "address",
|
|
2329
|
+
internalType: "address"
|
|
2330
|
+
}
|
|
2331
|
+
],
|
|
2332
|
+
stateMutability: "view"
|
|
2333
|
+
},
|
|
2334
|
+
{
|
|
2335
|
+
type: "function",
|
|
2336
|
+
name: "outputTokenBalance",
|
|
2337
|
+
inputs: [],
|
|
2338
|
+
outputs: [
|
|
2339
|
+
{
|
|
2340
|
+
name: "",
|
|
2341
|
+
type: "uint256",
|
|
2342
|
+
internalType: "uint256"
|
|
2343
|
+
}
|
|
2344
|
+
],
|
|
2345
|
+
stateMutability: "view"
|
|
2346
|
+
},
|
|
2347
|
+
{
|
|
2348
|
+
type: "function",
|
|
2349
|
+
name: "owner",
|
|
2350
|
+
inputs: [],
|
|
2351
|
+
outputs: [
|
|
2352
|
+
{
|
|
2353
|
+
name: "result",
|
|
2354
|
+
type: "address",
|
|
2355
|
+
internalType: "address"
|
|
2356
|
+
}
|
|
2357
|
+
],
|
|
2358
|
+
stateMutability: "view"
|
|
2359
|
+
},
|
|
2360
|
+
{
|
|
2361
|
+
type: "function",
|
|
2362
|
+
name: "ownershipHandoverExpiresAt",
|
|
2363
|
+
inputs: [
|
|
2364
|
+
{
|
|
2365
|
+
name: "pendingOwner",
|
|
2366
|
+
type: "address",
|
|
2367
|
+
internalType: "address"
|
|
2368
|
+
}
|
|
2369
|
+
],
|
|
2370
|
+
outputs: [
|
|
2371
|
+
{
|
|
2372
|
+
name: "result",
|
|
2373
|
+
type: "uint256",
|
|
2374
|
+
internalType: "uint256"
|
|
2375
|
+
}
|
|
2376
|
+
],
|
|
2377
|
+
stateMutability: "view"
|
|
2378
|
+
},
|
|
2379
|
+
{
|
|
2380
|
+
type: "function",
|
|
2381
|
+
name: "pause",
|
|
2382
|
+
inputs: [
|
|
2383
|
+
{
|
|
2384
|
+
name: "level",
|
|
2385
|
+
type: "uint32",
|
|
2386
|
+
internalType: "uint32"
|
|
2387
|
+
}
|
|
2388
|
+
],
|
|
2389
|
+
outputs: [
|
|
2390
|
+
{
|
|
2391
|
+
name: "",
|
|
2392
|
+
type: "bool",
|
|
2393
|
+
internalType: "bool"
|
|
2394
|
+
}
|
|
2395
|
+
],
|
|
2396
|
+
stateMutability: "nonpayable"
|
|
2397
|
+
},
|
|
2398
|
+
{
|
|
2399
|
+
type: "function",
|
|
2400
|
+
name: "paused",
|
|
2401
|
+
inputs: [],
|
|
2402
|
+
outputs: [
|
|
2403
|
+
{
|
|
2404
|
+
name: "",
|
|
2405
|
+
type: "uint32",
|
|
2406
|
+
internalType: "uint32"
|
|
2407
|
+
}
|
|
2408
|
+
],
|
|
2409
|
+
stateMutability: "view"
|
|
2410
|
+
},
|
|
2411
|
+
{
|
|
2412
|
+
type: "function",
|
|
2413
|
+
name: "preview",
|
|
2414
|
+
inputs: [
|
|
2415
|
+
{
|
|
2416
|
+
name: "token",
|
|
2417
|
+
type: "address",
|
|
2418
|
+
internalType: "address"
|
|
2419
|
+
},
|
|
2420
|
+
{
|
|
2421
|
+
name: "amount",
|
|
2422
|
+
type: "uint256",
|
|
2423
|
+
internalType: "uint256"
|
|
2424
|
+
}
|
|
2425
|
+
],
|
|
2426
|
+
outputs: [
|
|
2427
|
+
{
|
|
2428
|
+
name: "",
|
|
2429
|
+
type: "tuple",
|
|
2430
|
+
internalType: "struct Preview",
|
|
2431
|
+
components: [
|
|
2432
|
+
{
|
|
2433
|
+
name: "input",
|
|
2434
|
+
type: "uint256",
|
|
2435
|
+
internalType: "uint256"
|
|
2436
|
+
},
|
|
2437
|
+
{
|
|
2438
|
+
name: "fee",
|
|
2439
|
+
type: "uint256",
|
|
2440
|
+
internalType: "uint256"
|
|
2441
|
+
},
|
|
2442
|
+
{
|
|
2443
|
+
name: "output",
|
|
2444
|
+
type: "uint256",
|
|
2445
|
+
internalType: "uint256"
|
|
2446
|
+
}
|
|
2447
|
+
]
|
|
2448
|
+
}
|
|
2449
|
+
],
|
|
2450
|
+
stateMutability: "view"
|
|
2451
|
+
},
|
|
2452
|
+
{
|
|
2453
|
+
type: "function",
|
|
2454
|
+
name: "renounceOwnership",
|
|
2455
|
+
inputs: [],
|
|
2456
|
+
outputs: [],
|
|
2457
|
+
stateMutability: "payable"
|
|
2458
|
+
},
|
|
2459
|
+
{
|
|
2460
|
+
type: "function",
|
|
2461
|
+
name: "requestOwnershipHandover",
|
|
2462
|
+
inputs: [],
|
|
2463
|
+
outputs: [],
|
|
2464
|
+
stateMutability: "payable"
|
|
2465
|
+
},
|
|
2466
|
+
{
|
|
2467
|
+
type: "function",
|
|
2468
|
+
name: "setBps",
|
|
2469
|
+
inputs: [
|
|
2470
|
+
{
|
|
2471
|
+
name: "points",
|
|
2472
|
+
type: "uint256",
|
|
2473
|
+
internalType: "uint256"
|
|
2474
|
+
}
|
|
2475
|
+
],
|
|
2476
|
+
outputs: [
|
|
2477
|
+
{
|
|
2478
|
+
name: "",
|
|
2479
|
+
type: "bool",
|
|
2480
|
+
internalType: "bool"
|
|
2481
|
+
}
|
|
2482
|
+
],
|
|
2483
|
+
stateMutability: "nonpayable"
|
|
2484
|
+
},
|
|
2485
|
+
{
|
|
2486
|
+
type: "function",
|
|
2487
|
+
name: "setInputToken",
|
|
2488
|
+
inputs: [
|
|
2489
|
+
{
|
|
2490
|
+
name: "token",
|
|
2491
|
+
type: "address",
|
|
2492
|
+
internalType: "address"
|
|
2493
|
+
},
|
|
2494
|
+
{
|
|
2495
|
+
name: "val",
|
|
2496
|
+
type: "bool",
|
|
2497
|
+
internalType: "bool"
|
|
2498
|
+
}
|
|
2499
|
+
],
|
|
2500
|
+
outputs: [
|
|
2501
|
+
{
|
|
2502
|
+
name: "",
|
|
2503
|
+
type: "bool",
|
|
2504
|
+
internalType: "bool"
|
|
2505
|
+
}
|
|
2506
|
+
],
|
|
2507
|
+
stateMutability: "nonpayable"
|
|
2508
|
+
},
|
|
2509
|
+
{
|
|
2510
|
+
type: "function",
|
|
2511
|
+
name: "status",
|
|
2512
|
+
inputs: [],
|
|
2513
|
+
outputs: [
|
|
2514
|
+
{
|
|
2515
|
+
name: "",
|
|
2516
|
+
type: "tuple",
|
|
2517
|
+
internalType: "struct Status",
|
|
2518
|
+
components: [
|
|
2519
|
+
{
|
|
2520
|
+
name: "flags",
|
|
2521
|
+
type: "uint32",
|
|
2522
|
+
internalType: "uint32"
|
|
2523
|
+
},
|
|
2524
|
+
{
|
|
2525
|
+
name: "state",
|
|
2526
|
+
type: "uint8",
|
|
2527
|
+
internalType: "enum State"
|
|
2528
|
+
}
|
|
2529
|
+
]
|
|
2530
|
+
}
|
|
2531
|
+
],
|
|
2532
|
+
stateMutability: "view"
|
|
2533
|
+
},
|
|
2534
|
+
{
|
|
2535
|
+
type: "function",
|
|
2536
|
+
name: "stop",
|
|
2537
|
+
inputs: [],
|
|
2538
|
+
outputs: [
|
|
2539
|
+
{
|
|
2540
|
+
name: "",
|
|
2541
|
+
type: "bool",
|
|
2542
|
+
internalType: "bool"
|
|
2543
|
+
}
|
|
2544
|
+
],
|
|
2545
|
+
stateMutability: "nonpayable"
|
|
2546
|
+
},
|
|
2547
|
+
{
|
|
2548
|
+
type: "function",
|
|
2549
|
+
name: "stopped",
|
|
2550
|
+
inputs: [],
|
|
2551
|
+
outputs: [
|
|
2552
|
+
{
|
|
2553
|
+
name: "",
|
|
2554
|
+
type: "bool",
|
|
2555
|
+
internalType: "bool"
|
|
2556
|
+
}
|
|
2557
|
+
],
|
|
2558
|
+
stateMutability: "view"
|
|
2559
|
+
},
|
|
2560
|
+
{
|
|
2561
|
+
type: "function",
|
|
2562
|
+
name: "swap",
|
|
2563
|
+
inputs: [
|
|
2564
|
+
{
|
|
2565
|
+
name: "token",
|
|
2566
|
+
type: "address",
|
|
2567
|
+
internalType: "address"
|
|
2568
|
+
},
|
|
2569
|
+
{
|
|
2570
|
+
name: "amount",
|
|
2571
|
+
type: "uint256",
|
|
2572
|
+
internalType: "uint256"
|
|
2573
|
+
},
|
|
2574
|
+
{
|
|
2575
|
+
name: "slip",
|
|
2576
|
+
type: "uint256",
|
|
2577
|
+
internalType: "uint256"
|
|
2578
|
+
}
|
|
2579
|
+
],
|
|
2580
|
+
outputs: [
|
|
2581
|
+
{
|
|
2582
|
+
name: "",
|
|
2583
|
+
type: "uint256",
|
|
2584
|
+
internalType: "uint256"
|
|
2585
|
+
}
|
|
2586
|
+
],
|
|
2587
|
+
stateMutability: "nonpayable"
|
|
2588
|
+
},
|
|
2589
|
+
{
|
|
2590
|
+
type: "function",
|
|
2591
|
+
name: "tokenBalance",
|
|
2592
|
+
inputs: [
|
|
2593
|
+
{
|
|
2594
|
+
name: "token",
|
|
2595
|
+
type: "address",
|
|
2596
|
+
internalType: "address"
|
|
2597
|
+
}
|
|
2598
|
+
],
|
|
2599
|
+
outputs: [
|
|
2600
|
+
{
|
|
2601
|
+
name: "",
|
|
2602
|
+
type: "uint256",
|
|
2603
|
+
internalType: "uint256"
|
|
2604
|
+
}
|
|
2605
|
+
],
|
|
2606
|
+
stateMutability: "view"
|
|
2607
|
+
},
|
|
2608
|
+
{
|
|
2609
|
+
type: "function",
|
|
2610
|
+
name: "totals",
|
|
2611
|
+
inputs: [
|
|
2612
|
+
{
|
|
2613
|
+
name: "user",
|
|
2614
|
+
type: "address",
|
|
2615
|
+
internalType: "address"
|
|
2616
|
+
},
|
|
2617
|
+
{
|
|
2618
|
+
name: "token",
|
|
2619
|
+
type: "address",
|
|
2620
|
+
internalType: "address"
|
|
2621
|
+
}
|
|
2622
|
+
],
|
|
2623
|
+
outputs: [
|
|
2624
|
+
{
|
|
2625
|
+
name: "",
|
|
2626
|
+
type: "tuple",
|
|
2627
|
+
internalType: "struct SwapTotal",
|
|
2628
|
+
components: [
|
|
2629
|
+
{
|
|
2630
|
+
name: "inputSum",
|
|
2631
|
+
type: "uint256",
|
|
2632
|
+
internalType: "uint256"
|
|
2633
|
+
},
|
|
2634
|
+
{
|
|
2635
|
+
name: "feeSum",
|
|
2636
|
+
type: "uint256",
|
|
2637
|
+
internalType: "uint256"
|
|
2638
|
+
},
|
|
2639
|
+
{
|
|
2640
|
+
name: "outputSum",
|
|
2641
|
+
type: "uint256",
|
|
2642
|
+
internalType: "uint256"
|
|
2643
|
+
},
|
|
2644
|
+
{
|
|
2645
|
+
name: "count",
|
|
2646
|
+
type: "uint256",
|
|
2647
|
+
internalType: "uint256"
|
|
2648
|
+
}
|
|
2649
|
+
]
|
|
2650
|
+
}
|
|
2651
|
+
],
|
|
2652
|
+
stateMutability: "view"
|
|
2653
|
+
},
|
|
2654
|
+
{
|
|
2655
|
+
type: "function",
|
|
2656
|
+
name: "totals",
|
|
2657
|
+
inputs: [
|
|
2658
|
+
{
|
|
2659
|
+
name: "token",
|
|
2660
|
+
type: "address",
|
|
2661
|
+
internalType: "address"
|
|
2662
|
+
}
|
|
2663
|
+
],
|
|
2664
|
+
outputs: [
|
|
2665
|
+
{
|
|
2666
|
+
name: "",
|
|
2667
|
+
type: "tuple",
|
|
2668
|
+
internalType: "struct SwapTotal",
|
|
2669
|
+
components: [
|
|
2670
|
+
{
|
|
2671
|
+
name: "inputSum",
|
|
2672
|
+
type: "uint256",
|
|
2673
|
+
internalType: "uint256"
|
|
2674
|
+
},
|
|
2675
|
+
{
|
|
2676
|
+
name: "feeSum",
|
|
2677
|
+
type: "uint256",
|
|
2678
|
+
internalType: "uint256"
|
|
2679
|
+
},
|
|
2680
|
+
{
|
|
2681
|
+
name: "outputSum",
|
|
2682
|
+
type: "uint256",
|
|
2683
|
+
internalType: "uint256"
|
|
2684
|
+
},
|
|
2685
|
+
{
|
|
2686
|
+
name: "count",
|
|
2687
|
+
type: "uint256",
|
|
2688
|
+
internalType: "uint256"
|
|
2689
|
+
}
|
|
2690
|
+
]
|
|
2691
|
+
}
|
|
2692
|
+
],
|
|
2693
|
+
stateMutability: "view"
|
|
2694
|
+
},
|
|
2695
|
+
{
|
|
2696
|
+
type: "function",
|
|
2697
|
+
name: "transfer",
|
|
2698
|
+
inputs: [
|
|
2699
|
+
{
|
|
2700
|
+
name: "to",
|
|
2701
|
+
type: "address",
|
|
2702
|
+
internalType: "address"
|
|
2703
|
+
},
|
|
2704
|
+
{
|
|
2705
|
+
name: "amount",
|
|
2706
|
+
type: "uint256",
|
|
2707
|
+
internalType: "uint256"
|
|
2708
|
+
}
|
|
2709
|
+
],
|
|
2710
|
+
outputs: [
|
|
2711
|
+
{
|
|
2712
|
+
name: "",
|
|
2713
|
+
type: "bool",
|
|
2714
|
+
internalType: "bool"
|
|
2715
|
+
}
|
|
2716
|
+
],
|
|
2717
|
+
stateMutability: "nonpayable"
|
|
2718
|
+
},
|
|
2719
|
+
{
|
|
2720
|
+
type: "function",
|
|
2721
|
+
name: "transfer",
|
|
2722
|
+
inputs: [
|
|
2723
|
+
{
|
|
2724
|
+
name: "to",
|
|
2725
|
+
type: "address",
|
|
2726
|
+
internalType: "address"
|
|
2727
|
+
},
|
|
2728
|
+
{
|
|
2729
|
+
name: "token",
|
|
2730
|
+
type: "address",
|
|
2731
|
+
internalType: "address"
|
|
2732
|
+
},
|
|
2733
|
+
{
|
|
2734
|
+
name: "amount",
|
|
2735
|
+
type: "uint256",
|
|
2736
|
+
internalType: "uint256"
|
|
2737
|
+
}
|
|
2738
|
+
],
|
|
2739
|
+
outputs: [
|
|
2740
|
+
{
|
|
2741
|
+
name: "",
|
|
2742
|
+
type: "bool",
|
|
2743
|
+
internalType: "bool"
|
|
2744
|
+
}
|
|
2745
|
+
],
|
|
2746
|
+
stateMutability: "nonpayable"
|
|
2747
|
+
},
|
|
2748
|
+
{
|
|
2749
|
+
type: "function",
|
|
2750
|
+
name: "transferOwnership",
|
|
2751
|
+
inputs: [
|
|
2752
|
+
{
|
|
2753
|
+
name: "newOwner",
|
|
2754
|
+
type: "address",
|
|
2755
|
+
internalType: "address"
|
|
2756
|
+
}
|
|
2757
|
+
],
|
|
2758
|
+
outputs: [],
|
|
2759
|
+
stateMutability: "payable"
|
|
2760
|
+
},
|
|
2761
|
+
{
|
|
2762
|
+
type: "event",
|
|
2763
|
+
name: "BpsUpdated",
|
|
2764
|
+
inputs: [
|
|
2765
|
+
{
|
|
2766
|
+
name: "prev",
|
|
2767
|
+
type: "uint256",
|
|
2768
|
+
indexed: false,
|
|
2769
|
+
internalType: "uint256"
|
|
2770
|
+
},
|
|
2771
|
+
{
|
|
2772
|
+
name: "next",
|
|
2773
|
+
type: "uint256",
|
|
2774
|
+
indexed: false,
|
|
2775
|
+
internalType: "uint256"
|
|
2776
|
+
}
|
|
2777
|
+
],
|
|
2778
|
+
anonymous: false
|
|
2779
|
+
},
|
|
2780
|
+
{
|
|
2781
|
+
type: "event",
|
|
2782
|
+
name: "InputTokenUpdated",
|
|
2783
|
+
inputs: [
|
|
2784
|
+
{
|
|
2785
|
+
name: "token",
|
|
2786
|
+
type: "address",
|
|
2787
|
+
indexed: true,
|
|
2788
|
+
internalType: "address"
|
|
2789
|
+
},
|
|
2790
|
+
{
|
|
2791
|
+
name: "prev",
|
|
2792
|
+
type: "bool",
|
|
2793
|
+
indexed: false,
|
|
2794
|
+
internalType: "bool"
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
name: "next",
|
|
2798
|
+
type: "bool",
|
|
2799
|
+
indexed: false,
|
|
2800
|
+
internalType: "bool"
|
|
2801
|
+
}
|
|
2802
|
+
],
|
|
2803
|
+
anonymous: false
|
|
2804
|
+
},
|
|
2805
|
+
{
|
|
2806
|
+
type: "event",
|
|
2807
|
+
name: "OwnershipHandoverCanceled",
|
|
2808
|
+
inputs: [
|
|
2809
|
+
{
|
|
2810
|
+
name: "pendingOwner",
|
|
2811
|
+
type: "address",
|
|
2812
|
+
indexed: true,
|
|
2813
|
+
internalType: "address"
|
|
2814
|
+
}
|
|
2815
|
+
],
|
|
2816
|
+
anonymous: false
|
|
2817
|
+
},
|
|
2818
|
+
{
|
|
2819
|
+
type: "event",
|
|
2820
|
+
name: "OwnershipHandoverRequested",
|
|
2821
|
+
inputs: [
|
|
2822
|
+
{
|
|
2823
|
+
name: "pendingOwner",
|
|
2824
|
+
type: "address",
|
|
2825
|
+
indexed: true,
|
|
2826
|
+
internalType: "address"
|
|
2827
|
+
}
|
|
2828
|
+
],
|
|
2829
|
+
anonymous: false
|
|
2830
|
+
},
|
|
2831
|
+
{
|
|
2832
|
+
type: "event",
|
|
2833
|
+
name: "OwnershipTransferred",
|
|
2834
|
+
inputs: [
|
|
2835
|
+
{
|
|
2836
|
+
name: "oldOwner",
|
|
2837
|
+
type: "address",
|
|
2838
|
+
indexed: true,
|
|
2839
|
+
internalType: "address"
|
|
2840
|
+
},
|
|
2841
|
+
{
|
|
2842
|
+
name: "newOwner",
|
|
2843
|
+
type: "address",
|
|
2844
|
+
indexed: true,
|
|
2845
|
+
internalType: "address"
|
|
2846
|
+
}
|
|
2847
|
+
],
|
|
2848
|
+
anonymous: false
|
|
2849
|
+
},
|
|
2850
|
+
{
|
|
2851
|
+
type: "event",
|
|
2852
|
+
name: "Paused",
|
|
2853
|
+
inputs: [
|
|
2854
|
+
{
|
|
2855
|
+
name: "previous",
|
|
2856
|
+
type: "uint32",
|
|
2857
|
+
indexed: false,
|
|
2858
|
+
internalType: "uint32"
|
|
2859
|
+
},
|
|
2860
|
+
{
|
|
2861
|
+
name: "next",
|
|
2862
|
+
type: "uint32",
|
|
2863
|
+
indexed: false,
|
|
2864
|
+
internalType: "uint32"
|
|
2865
|
+
}
|
|
2866
|
+
],
|
|
2867
|
+
anonymous: false
|
|
2868
|
+
},
|
|
2869
|
+
{
|
|
2870
|
+
type: "event",
|
|
2871
|
+
name: "Stopped",
|
|
2872
|
+
inputs: [],
|
|
2873
|
+
anonymous: false
|
|
2874
|
+
},
|
|
2875
|
+
{
|
|
2876
|
+
type: "event",
|
|
2877
|
+
name: "Swapped",
|
|
2878
|
+
inputs: [
|
|
2879
|
+
{
|
|
2880
|
+
name: "user",
|
|
2881
|
+
type: "address",
|
|
2882
|
+
indexed: true,
|
|
2883
|
+
internalType: "address"
|
|
2884
|
+
},
|
|
2885
|
+
{
|
|
2886
|
+
name: "inputToken",
|
|
2887
|
+
type: "address",
|
|
2888
|
+
indexed: true,
|
|
2889
|
+
internalType: "address"
|
|
2890
|
+
},
|
|
2891
|
+
{
|
|
2892
|
+
name: "outputToken",
|
|
2893
|
+
type: "address",
|
|
2894
|
+
indexed: true,
|
|
2895
|
+
internalType: "address"
|
|
2896
|
+
},
|
|
2897
|
+
{
|
|
2898
|
+
name: "inputAmount",
|
|
2899
|
+
type: "uint256",
|
|
2900
|
+
indexed: false,
|
|
2901
|
+
internalType: "uint256"
|
|
2902
|
+
},
|
|
2903
|
+
{
|
|
2904
|
+
name: "fee",
|
|
2905
|
+
type: "uint256",
|
|
2906
|
+
indexed: false,
|
|
2907
|
+
internalType: "uint256"
|
|
2908
|
+
},
|
|
2909
|
+
{
|
|
2910
|
+
name: "outputAmount",
|
|
2911
|
+
type: "uint256",
|
|
2912
|
+
indexed: false,
|
|
2913
|
+
internalType: "uint256"
|
|
2914
|
+
}
|
|
2915
|
+
],
|
|
2916
|
+
anonymous: false
|
|
2917
|
+
},
|
|
2918
|
+
{
|
|
2919
|
+
type: "event",
|
|
2920
|
+
name: "Transferred",
|
|
2921
|
+
inputs: [
|
|
2922
|
+
{
|
|
2923
|
+
name: "to",
|
|
2924
|
+
type: "address",
|
|
2925
|
+
indexed: true,
|
|
2926
|
+
internalType: "address"
|
|
2927
|
+
},
|
|
2928
|
+
{
|
|
2929
|
+
name: "token",
|
|
2930
|
+
type: "address",
|
|
2931
|
+
indexed: true,
|
|
2932
|
+
internalType: "address"
|
|
2933
|
+
},
|
|
2934
|
+
{
|
|
2935
|
+
name: "amount",
|
|
2936
|
+
type: "uint256",
|
|
2937
|
+
indexed: false,
|
|
2938
|
+
internalType: "uint256"
|
|
2939
|
+
}
|
|
2940
|
+
],
|
|
2941
|
+
anonymous: false
|
|
2942
|
+
},
|
|
2943
|
+
{
|
|
2944
|
+
type: "error",
|
|
2945
|
+
name: "AlreadyInitialized",
|
|
2946
|
+
inputs: []
|
|
2947
|
+
},
|
|
2948
|
+
{
|
|
2949
|
+
type: "error",
|
|
2950
|
+
name: "InsufficientAmount",
|
|
2951
|
+
inputs: []
|
|
2952
|
+
},
|
|
2953
|
+
{
|
|
2954
|
+
type: "error",
|
|
2955
|
+
name: "InvalidAddress",
|
|
2956
|
+
inputs: []
|
|
2957
|
+
},
|
|
2958
|
+
{
|
|
2959
|
+
type: "error",
|
|
2960
|
+
name: "InvalidAmount",
|
|
2961
|
+
inputs: []
|
|
2962
|
+
},
|
|
2963
|
+
{
|
|
2964
|
+
type: "error",
|
|
2965
|
+
name: "IsPaused",
|
|
2966
|
+
inputs: [
|
|
2967
|
+
{
|
|
2968
|
+
name: "level",
|
|
2969
|
+
type: "uint32",
|
|
2970
|
+
internalType: "uint32"
|
|
2971
|
+
}
|
|
2972
|
+
]
|
|
2973
|
+
},
|
|
2974
|
+
{
|
|
2975
|
+
type: "error",
|
|
2976
|
+
name: "IsStopped",
|
|
2977
|
+
inputs: []
|
|
2978
|
+
},
|
|
2979
|
+
{
|
|
2980
|
+
type: "error",
|
|
2981
|
+
name: "NewOwnerIsZeroAddress",
|
|
2982
|
+
inputs: []
|
|
2983
|
+
},
|
|
2984
|
+
{
|
|
2985
|
+
type: "error",
|
|
2986
|
+
name: "NoHandoverRequest",
|
|
2987
|
+
inputs: []
|
|
2988
|
+
},
|
|
2989
|
+
{
|
|
2990
|
+
type: "error",
|
|
2991
|
+
name: "SwapFailed",
|
|
2992
|
+
inputs: [
|
|
2993
|
+
{
|
|
2994
|
+
name: "user",
|
|
2995
|
+
type: "address",
|
|
2996
|
+
internalType: "address"
|
|
2997
|
+
},
|
|
2998
|
+
{
|
|
2999
|
+
name: "token",
|
|
3000
|
+
type: "address",
|
|
3001
|
+
internalType: "address"
|
|
3002
|
+
}
|
|
3003
|
+
]
|
|
3004
|
+
},
|
|
3005
|
+
{
|
|
3006
|
+
type: "error",
|
|
3007
|
+
name: "Unauthorized",
|
|
3008
|
+
inputs: []
|
|
3009
|
+
}
|
|
3010
|
+
];
|
|
3011
|
+
|
|
3012
|
+
// src/universal/core/shared/blockchain/erc20/abi.ts
|
|
3013
|
+
var ERC20_ABI = [
|
|
3014
|
+
{
|
|
3015
|
+
type: "function",
|
|
3016
|
+
name: "allowance",
|
|
3017
|
+
inputs: [
|
|
3018
|
+
{ name: "owner", type: "address" },
|
|
3019
|
+
{ name: "spender", type: "address" }
|
|
3020
|
+
],
|
|
3021
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
3022
|
+
stateMutability: "view"
|
|
3023
|
+
},
|
|
3024
|
+
{
|
|
3025
|
+
type: "function",
|
|
3026
|
+
name: "approve",
|
|
3027
|
+
inputs: [
|
|
3028
|
+
{ name: "spender", type: "address" },
|
|
3029
|
+
{ name: "amount", type: "uint256" }
|
|
3030
|
+
],
|
|
3031
|
+
outputs: [{ name: "", type: "bool" }],
|
|
3032
|
+
stateMutability: "nonpayable"
|
|
3033
|
+
},
|
|
3034
|
+
{
|
|
3035
|
+
type: "function",
|
|
3036
|
+
name: "balanceOf",
|
|
3037
|
+
inputs: [{ name: "account", type: "address" }],
|
|
3038
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
3039
|
+
stateMutability: "view"
|
|
3040
|
+
},
|
|
3041
|
+
{
|
|
3042
|
+
type: "function",
|
|
3043
|
+
name: "decimals",
|
|
3044
|
+
inputs: [],
|
|
3045
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
3046
|
+
stateMutability: "view"
|
|
3047
|
+
},
|
|
3048
|
+
{
|
|
3049
|
+
type: "function",
|
|
3050
|
+
name: "name",
|
|
3051
|
+
inputs: [],
|
|
3052
|
+
outputs: [{ name: "", type: "string" }],
|
|
3053
|
+
stateMutability: "view"
|
|
3054
|
+
},
|
|
3055
|
+
{
|
|
3056
|
+
type: "function",
|
|
3057
|
+
name: "symbol",
|
|
3058
|
+
inputs: [],
|
|
3059
|
+
outputs: [{ name: "", type: "string" }],
|
|
3060
|
+
stateMutability: "view"
|
|
3061
|
+
},
|
|
3062
|
+
{
|
|
3063
|
+
type: "function",
|
|
3064
|
+
name: "totalSupply",
|
|
3065
|
+
inputs: [],
|
|
3066
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
3067
|
+
stateMutability: "view"
|
|
3068
|
+
},
|
|
3069
|
+
{
|
|
3070
|
+
type: "function",
|
|
3071
|
+
name: "transfer",
|
|
3072
|
+
inputs: [
|
|
3073
|
+
{ name: "recipient", type: "address" },
|
|
3074
|
+
{ name: "amount", type: "uint256" }
|
|
3075
|
+
],
|
|
3076
|
+
outputs: [{ name: "", type: "bool" }],
|
|
3077
|
+
stateMutability: "nonpayable"
|
|
3078
|
+
},
|
|
3079
|
+
{
|
|
3080
|
+
type: "function",
|
|
3081
|
+
name: "transferFrom",
|
|
3082
|
+
inputs: [
|
|
3083
|
+
{ name: "sender", type: "address" },
|
|
3084
|
+
{ name: "recipient", type: "address" },
|
|
3085
|
+
{ name: "amount", type: "uint256" }
|
|
3086
|
+
],
|
|
3087
|
+
outputs: [{ name: "", type: "bool" }],
|
|
3088
|
+
stateMutability: "nonpayable"
|
|
3089
|
+
},
|
|
3090
|
+
{
|
|
3091
|
+
type: "event",
|
|
3092
|
+
name: "Approval",
|
|
3093
|
+
inputs: [
|
|
3094
|
+
{ name: "owner", type: "address", indexed: true },
|
|
3095
|
+
{ name: "spender", type: "address", indexed: true },
|
|
3096
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
3097
|
+
],
|
|
3098
|
+
anonymous: false
|
|
3099
|
+
},
|
|
3100
|
+
{
|
|
3101
|
+
type: "event",
|
|
3102
|
+
name: "Transfer",
|
|
3103
|
+
inputs: [
|
|
3104
|
+
{ name: "from", type: "address", indexed: true },
|
|
3105
|
+
{ name: "to", type: "address", indexed: true },
|
|
3106
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
3107
|
+
],
|
|
3108
|
+
anonymous: false
|
|
3109
|
+
}
|
|
3110
|
+
];
|
|
3111
|
+
|
|
3112
|
+
// src/universal/api/rpc/providers/superstate/swap.ts
|
|
3113
|
+
async function getSwapAuthorization(clients, params) {
|
|
3114
|
+
return clients(params.chain).readContract({
|
|
3115
|
+
address: params.contractAddress,
|
|
3116
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
3117
|
+
functionName: "authorized",
|
|
3118
|
+
args: [params.walletAddress]
|
|
3119
|
+
});
|
|
3120
|
+
}
|
|
3121
|
+
async function getSwapPreview(clients, params) {
|
|
3122
|
+
const preview = await clients(params.chain).readContract({
|
|
3123
|
+
address: params.contractAddress,
|
|
3124
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
3125
|
+
functionName: "preview",
|
|
3126
|
+
args: [params.inputToken, params.amount]
|
|
3127
|
+
});
|
|
3128
|
+
return SwapPreview.fromContract(preview);
|
|
3129
|
+
}
|
|
3130
|
+
async function getSwapStatus(clients, params) {
|
|
3131
|
+
const status = await clients(params.chain).readContract({
|
|
3132
|
+
address: params.contractAddress,
|
|
3133
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
3134
|
+
functionName: "status"
|
|
3135
|
+
});
|
|
3136
|
+
return SwapStatus.fromContract(status);
|
|
3137
|
+
}
|
|
3138
|
+
async function getSwapOutputToken(clients, params) {
|
|
3139
|
+
const client = clients(params.chain);
|
|
3140
|
+
const tokenAddress = await client.readContract({
|
|
3141
|
+
address: params.contractAddress,
|
|
3142
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
3143
|
+
functionName: "outputToken"
|
|
3144
|
+
});
|
|
3145
|
+
const token = { address: EvmContractAddress(tokenAddress), abi: ERC20_ABI };
|
|
3146
|
+
const [name, symbol, decimals] = await client.multicall({
|
|
3147
|
+
contracts: [
|
|
3148
|
+
{ ...token, functionName: "name" },
|
|
3149
|
+
{ ...token, functionName: "symbol" },
|
|
3150
|
+
{ ...token, functionName: "decimals" }
|
|
3151
|
+
],
|
|
3152
|
+
allowFailure: false
|
|
3153
|
+
});
|
|
2056
3154
|
return {
|
|
2057
|
-
name
|
|
2058
|
-
symbol: AssetSymbol(
|
|
2059
|
-
decimals: AssetDecimals(
|
|
3155
|
+
name,
|
|
3156
|
+
symbol: AssetSymbol(symbol),
|
|
3157
|
+
decimals: AssetDecimals(decimals)
|
|
2060
3158
|
};
|
|
2061
3159
|
}
|
|
2062
3160
|
|
|
@@ -2067,28 +3165,32 @@ var SuperstateSwapNamespaceImpl = class {
|
|
|
2067
3165
|
this.log = internalLogger(ctx.logger, "SUPERSTATE");
|
|
2068
3166
|
}
|
|
2069
3167
|
async getAuthorization(params) {
|
|
2070
|
-
return this.log.wrap(
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
3168
|
+
return this.log.wrap(
|
|
3169
|
+
"getAuthorization",
|
|
3170
|
+
params,
|
|
3171
|
+
async () => getSwapAuthorization(this.ctx.rpc, params)
|
|
3172
|
+
);
|
|
2074
3173
|
}
|
|
2075
3174
|
async getPreview(params) {
|
|
2076
|
-
return this.log.wrap(
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
3175
|
+
return this.log.wrap(
|
|
3176
|
+
"getPreview",
|
|
3177
|
+
params,
|
|
3178
|
+
async () => getSwapPreview(this.ctx.rpc, params)
|
|
3179
|
+
);
|
|
2080
3180
|
}
|
|
2081
3181
|
async getStatus(params) {
|
|
2082
|
-
return this.log.wrap(
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
3182
|
+
return this.log.wrap(
|
|
3183
|
+
"getStatus",
|
|
3184
|
+
params,
|
|
3185
|
+
async () => getSwapStatus(this.ctx.rpc, params)
|
|
3186
|
+
);
|
|
2086
3187
|
}
|
|
2087
3188
|
async getOutputToken(params) {
|
|
2088
|
-
return this.log.wrap(
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
3189
|
+
return this.log.wrap(
|
|
3190
|
+
"getOutputToken",
|
|
3191
|
+
params,
|
|
3192
|
+
async () => getSwapOutputToken(this.ctx.rpc, params)
|
|
3193
|
+
);
|
|
2092
3194
|
}
|
|
2093
3195
|
async allowWallet(params) {
|
|
2094
3196
|
return this.log.wrap("allowWallet", params, async () => {
|
|
@@ -2098,6 +3200,26 @@ var SuperstateSwapNamespaceImpl = class {
|
|
|
2098
3200
|
}
|
|
2099
3201
|
};
|
|
2100
3202
|
|
|
3203
|
+
// src/universal/api/rpc/erc20.ts
|
|
3204
|
+
async function getTokenAllowance(clients, params) {
|
|
3205
|
+
const allowance = await clients(params.chain).readContract({
|
|
3206
|
+
address: params.tokenAddress,
|
|
3207
|
+
abi: ERC20_ABI,
|
|
3208
|
+
functionName: "allowance",
|
|
3209
|
+
args: [params.owner, params.spender]
|
|
3210
|
+
});
|
|
3211
|
+
return parseUint256(allowance, "allowance");
|
|
3212
|
+
}
|
|
3213
|
+
async function getTokenBalance(clients, params) {
|
|
3214
|
+
const balance = await clients(params.chain).readContract({
|
|
3215
|
+
address: params.tokenAddress,
|
|
3216
|
+
abi: ERC20_ABI,
|
|
3217
|
+
functionName: "balanceOf",
|
|
3218
|
+
args: [params.owner]
|
|
3219
|
+
});
|
|
3220
|
+
return parseUint256(balance, "balanceOf");
|
|
3221
|
+
}
|
|
3222
|
+
|
|
2101
3223
|
// src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
|
|
2102
3224
|
var Erc20NamespaceImpl = class {
|
|
2103
3225
|
constructor(ctx) {
|
|
@@ -2105,21 +3227,23 @@ var Erc20NamespaceImpl = class {
|
|
|
2105
3227
|
this.log = internalLogger(ctx.logger, "ERC20");
|
|
2106
3228
|
}
|
|
2107
3229
|
async getAllowance(params) {
|
|
2108
|
-
return this.log.wrap(
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
3230
|
+
return this.log.wrap(
|
|
3231
|
+
"getAllowance",
|
|
3232
|
+
params,
|
|
3233
|
+
async () => getTokenAllowance(this.ctx.rpc, params)
|
|
3234
|
+
);
|
|
2112
3235
|
}
|
|
2113
3236
|
async getBalance(params) {
|
|
2114
|
-
return this.log.wrap(
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
3237
|
+
return this.log.wrap(
|
|
3238
|
+
"getBalance",
|
|
3239
|
+
params,
|
|
3240
|
+
async () => getTokenBalance(this.ctx.rpc, params)
|
|
3241
|
+
);
|
|
2118
3242
|
}
|
|
2119
3243
|
};
|
|
2120
3244
|
|
|
2121
3245
|
// src/universal/api/nabu/tokens.ts
|
|
2122
|
-
var
|
|
3246
|
+
var import_viem6 = require("viem");
|
|
2123
3247
|
|
|
2124
3248
|
// src/universal/types/token-metadata.ts
|
|
2125
3249
|
var TokenLogoUrl = (value) => value;
|
|
@@ -2289,7 +3413,7 @@ function assertOk(response) {
|
|
|
2289
3413
|
}
|
|
2290
3414
|
function checksummed(address) {
|
|
2291
3415
|
try {
|
|
2292
|
-
return (0,
|
|
3416
|
+
return (0, import_viem6.getAddress)(address);
|
|
2293
3417
|
} catch (_) {
|
|
2294
3418
|
throw new ValidationError(`Invalid EVM contract address: "${address}"`);
|
|
2295
3419
|
}
|
|
@@ -2488,6 +3612,7 @@ var CoinListServerImpl = class {
|
|
|
2488
3612
|
});
|
|
2489
3613
|
const ctx = {
|
|
2490
3614
|
api: this.api,
|
|
3615
|
+
rpc: publicClients(this.api, _config.rpc, _config.logger ?? null),
|
|
2491
3616
|
logger,
|
|
2492
3617
|
ensureUserAuthenticated: () => this.ensureAuthenticated(void 0),
|
|
2493
3618
|
ensureAuthenticated: (clientCreds) => this.ensureAuthenticated(clientCreds)
|