Skip to content

Commit c4e386f

Browse files
committed
add back and deprecate eventSignatures
1 parent b36eff4 commit c4e386f

File tree

2 files changed

+21
-31
lines changed

2 files changed

+21
-31
lines changed

examples/live.ts

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,18 @@ setTimeout(() => {
1616

1717
let latest = 23815440n;
1818

19-
for (let i = 0; i < 10; i++) {
20-
(async () => {
21-
const query = queryLive({
22-
//abortSignal: controller.signal,
23-
//startBlock: async () => (latest + 1n),
24-
apiKey: "a22448a73d2253b683757995d6889b78",
25-
apiUrl: "http://localhost:8000/v2",
26-
chainId: 8453n,
27-
signatures: [
28-
"Transfer(address indexed from, address indexed to, uint256 v)",
29-
],
30-
query: "select tx_hash, block_num from transfer limit 1",
31-
formatRow: ([tx_hash, block_num]) => {
32-
return {
33-
tx: tx_hash as Hex,
34-
block: BigInt(block_num),
35-
};
36-
},
37-
});
38-
39-
for await (const { rows } of query) {
40-
rows.forEach((row) => {
41-
if (row.block > latest) {
42-
latest = row.block;
43-
}
44-
console.log(row);
45-
});
46-
}
47-
})();
48-
}
19+
const query = queryLive({
20+
abortSignal: controller.signal,
21+
startBlock: async () => (latest + 1n),
22+
chainId: 8453n,
23+
signatures: [
24+
"Transfer(address indexed from, address indexed to, uint256 v)",
25+
],
26+
query: "select tx_hash, block_num from transfer limit 1",
27+
formatRow: ([tx_hash, block_num]) => {
28+
return {
29+
tx: tx_hash as Hex,
30+
block: BigInt(block_num),
31+
};
32+
},
33+
});

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ type BaseRequest<T> = {
134134
apiUrl?: string;
135135
/** Optional API key for authentication. Unauthenticated requests limited to 5 per minute */
136136
apiKey?: string;
137+
/** @deprecated use `signatures` */
138+
eventSignatures?: ReadonlyArray<string>;
137139
/** Optional array of signatures to filter transactions and events */
138140
signatures?: ReadonlyArray<string>;
139141
/** SQL query to execute */
@@ -204,9 +206,12 @@ async function url<T>(
204206
if (request.cursor) {
205207
params.set("cursor", encodeCursor(request.cursor));
206208
}
209+
request.eventSignatures?.forEach((sig) => {
210+
params.append("signatures", sig);
211+
});
207212
request.signatures?.forEach((sig) => {
208213
params.append("signatures", sig);
209-
})
214+
});
210215
params.set("query", request.query);
211216

212217
let apiUrl = "https://api.indexsupply.net/v2";

0 commit comments

Comments
 (0)