@gearbox-protocol/sdk 7.3.1 → 7.4.0
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/cjs/sdk/utils/viem/getLogsPaginated.js +54 -0
- package/dist/cjs/sdk/utils/viem/index.js +2 -0
- package/dist/esm/sdk/utils/viem/getLogsPaginated.js +30 -0
- package/dist/esm/sdk/utils/viem/index.js +1 -0
- package/dist/types/sdk/sdk-legacy/core/creditAccount.d.ts +1 -1
- package/dist/types/sdk/utils/viem/getLogsPaginated.d.ts +13 -0
- package/dist/types/sdk/utils/viem/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getLogsPaginated_exports = {};
|
|
20
|
+
__export(getLogsPaginated_exports, {
|
|
21
|
+
getLogsPaginated: () => getLogsPaginated
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getLogsPaginated_exports);
|
|
24
|
+
var import_actions = require("viem/actions");
|
|
25
|
+
async function getLogsPaginated(client, params) {
|
|
26
|
+
const from_ = params.fromBlock;
|
|
27
|
+
const to_ = params.toBlock;
|
|
28
|
+
const pageSize = params.pageSize;
|
|
29
|
+
const requests = [];
|
|
30
|
+
for (let fromBlock = from_; fromBlock < to_; fromBlock += pageSize) {
|
|
31
|
+
let toBlock = fromBlock + pageSize - 1n;
|
|
32
|
+
if (toBlock > to_) {
|
|
33
|
+
toBlock = to_;
|
|
34
|
+
}
|
|
35
|
+
requests.push({
|
|
36
|
+
...params,
|
|
37
|
+
fromBlock,
|
|
38
|
+
toBlock
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const responses = await Promise.all(
|
|
42
|
+
requests.map(
|
|
43
|
+
(r) => (0, import_actions.getLogs)(
|
|
44
|
+
client,
|
|
45
|
+
r
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
return responses.flat();
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
getLogsPaginated
|
|
54
|
+
});
|
|
@@ -16,6 +16,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var viem_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(viem_exports);
|
|
18
18
|
__reExport(viem_exports, require("./cast.js"), module.exports);
|
|
19
|
+
__reExport(viem_exports, require("./getLogsPaginated.js"), module.exports);
|
|
19
20
|
__reExport(viem_exports, require("./getLogsSafe.js"), module.exports);
|
|
20
21
|
__reExport(viem_exports, require("./sendRawTx.js"), module.exports);
|
|
21
22
|
__reExport(viem_exports, require("./simulateMulticall.js"), module.exports);
|
|
@@ -23,6 +24,7 @@ __reExport(viem_exports, require("./simulateWithPriceUpdates.js"), module.export
|
|
|
23
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
25
|
0 && (module.exports = {
|
|
25
26
|
...require("./cast.js"),
|
|
27
|
+
...require("./getLogsPaginated.js"),
|
|
26
28
|
...require("./getLogsSafe.js"),
|
|
27
29
|
...require("./sendRawTx.js"),
|
|
28
30
|
...require("./simulateMulticall.js"),
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getLogs } from "viem/actions";
|
|
2
|
+
async function getLogsPaginated(client, params) {
|
|
3
|
+
const from_ = params.fromBlock;
|
|
4
|
+
const to_ = params.toBlock;
|
|
5
|
+
const pageSize = params.pageSize;
|
|
6
|
+
const requests = [];
|
|
7
|
+
for (let fromBlock = from_; fromBlock < to_; fromBlock += pageSize) {
|
|
8
|
+
let toBlock = fromBlock + pageSize - 1n;
|
|
9
|
+
if (toBlock > to_) {
|
|
10
|
+
toBlock = to_;
|
|
11
|
+
}
|
|
12
|
+
requests.push({
|
|
13
|
+
...params,
|
|
14
|
+
fromBlock,
|
|
15
|
+
toBlock
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const responses = await Promise.all(
|
|
19
|
+
requests.map(
|
|
20
|
+
(r) => getLogs(
|
|
21
|
+
client,
|
|
22
|
+
r
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
return responses.flat();
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
getLogsPaginated
|
|
30
|
+
};
|
|
@@ -133,7 +133,7 @@ export declare class CreditAccountData_Legacy {
|
|
|
133
133
|
setDeleteInProgress(d: boolean): void;
|
|
134
134
|
static sortBalances(balances: Record<Address, bigint>, prices: Record<Address, bigint>, tokens: Record<Address, TokenData>): Array<[Address, bigint]>;
|
|
135
135
|
static sortAssets(balances: Array<Asset>, prices: Record<Address, bigint>, tokens: Record<Address, TokenData>): Asset[];
|
|
136
|
-
static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 |
|
|
136
|
+
static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | -1 | 0;
|
|
137
137
|
static amountAbcComparator(t1: bigint, t2: bigint): 1 | -1;
|
|
138
138
|
isForbidden(token: Address): boolean;
|
|
139
139
|
isQuoted(token: Address): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AbiEvent } from "abitype";
|
|
2
|
+
import type { BlockNumber, Chain, Client, GetLogsParameters, GetLogsReturnType, MaybeAbiEventName, Transport } from "viem";
|
|
3
|
+
export type GetLogsPaginatedParameters<abiEvent extends AbiEvent | undefined = undefined, abiEvents extends readonly AbiEvent[] | readonly unknown[] | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined, _eventName extends string | undefined = MaybeAbiEventName<abiEvent>> = GetLogsParameters<abiEvent, abiEvents, strict, BlockNumber, BlockNumber, _eventName> & {
|
|
4
|
+
pageSize: bigint;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Get logs in pages, to avoid rate limiting
|
|
8
|
+
* Must be used with client that has batching enabled
|
|
9
|
+
* @param client
|
|
10
|
+
* @param params
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function getLogsPaginated<chain extends Chain | undefined, const abiEvent extends AbiEvent | undefined = undefined, const abiEvents extends readonly AbiEvent[] | readonly unknown[] | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(client: Client<Transport, chain>, params: GetLogsPaginatedParameters<abiEvent, abiEvents, strict>): Promise<GetLogsReturnType<abiEvent, abiEvents, strict, BlockNumber, BlockNumber>>;
|