Perform eth_getLogs query only if subgraph event handlers exist (#14)

Part of [Generate watchers for sushiswap subgraphs deployed in graph-node](https://www.notion.so/Generate-watchers-for-sushiswap-subgraphs-deployed-in-graph-node-b3f2e475373d4ab1887d9f8720bd5ae6)

Reviewed-on: #14
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
Nabarun 2024-06-20 05:14:14 +00:00 committed by ashwin
parent 45177bb2ce
commit 419747e60a
12 changed files with 142 additions and 87 deletions

View File

@ -3,6 +3,6 @@
"packages/*"
],
"useWorkspaces": true,
"version": "0.1.4",
"version": "0.1.5",
"npmClient": "yarn"
}

View File

@ -1,6 +1,6 @@
{
"name": "@cerc-io/blocks-watcher",
"version": "0.1.0",
"version": "0.1.5",
"description": "blocks-watcher",
"private": true,
"main": "dist/index.js",
@ -39,11 +39,11 @@
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/cli": "^0.2.98",
"@cerc-io/ipld-eth-client": "^0.2.98",
"@cerc-io/solidity-mapper": "^0.2.98",
"@cerc-io/util": "^0.2.98",
"@cerc-io/graph-node": "^0.2.98",
"@cerc-io/cli": "^0.2.100",
"@cerc-io/graph-node": "^0.2.100",
"@cerc-io/ipld-eth-client": "^0.2.100",
"@cerc-io/solidity-mapper": "^0.2.100",
"@cerc-io/util": "^0.2.100",
"@ethersproject/providers": "^5.4.4",
"debug": "^4.3.1",
"decimal.js": "^10.3.1",

View File

@ -651,7 +651,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events and txs only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {

View File

@ -1,6 +1,6 @@
{
"name": "@cerc-io/route-processor-watcher",
"version": "0.1.0",
"version": "0.1.5",
"description": "route-processor-watcher",
"private": true,
"main": "dist/index.js",
@ -39,11 +39,11 @@
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/cli": "^0.2.98",
"@cerc-io/ipld-eth-client": "^0.2.98",
"@cerc-io/solidity-mapper": "^0.2.98",
"@cerc-io/util": "^0.2.98",
"@cerc-io/graph-node": "^0.2.98",
"@cerc-io/cli": "0.2.100",
"@cerc-io/graph-node": "0.2.100",
"@cerc-io/ipld-eth-client": "0.2.100",
"@cerc-io/solidity-mapper": "0.2.100",
"@cerc-io/util": "0.2.100",
"@ethersproject/providers": "^5.4.4",
"debug": "^4.3.1",
"decimal.js": "^10.3.1",

View File

@ -657,7 +657,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events and txs only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {

View File

@ -1,6 +1,6 @@
{
"name": "@cerc-io/sushiswap-watcher",
"version": "0.1.0",
"version": "0.1.5",
"description": "sushiswap-watcher",
"private": true,
"main": "dist/index.js",
@ -39,11 +39,11 @@
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/cli": "^0.2.98",
"@cerc-io/ipld-eth-client": "^0.2.98",
"@cerc-io/solidity-mapper": "^0.2.98",
"@cerc-io/util": "^0.2.98",
"@cerc-io/graph-node": "^0.2.98",
"@cerc-io/cli": "0.2.100",
"@cerc-io/graph-node": "0.2.100",
"@cerc-io/ipld-eth-client": "0.2.100",
"@cerc-io/solidity-mapper": "0.2.100",
"@cerc-io/util": "0.2.100",
"@ethersproject/providers": "^5.4.4",
"debug": "^4.3.1",
"decimal.js": "^10.3.1",

View File

@ -1165,7 +1165,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events and txs only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {

View File

@ -1,6 +1,6 @@
{
"name": "@cerc-io/v2-watcher",
"version": "0.1.0",
"version": "0.1.5",
"description": "v2-watcher",
"private": true,
"main": "dist/index.js",
@ -39,11 +39,11 @@
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/cli": "^0.2.98",
"@cerc-io/ipld-eth-client": "^0.2.98",
"@cerc-io/solidity-mapper": "^0.2.98",
"@cerc-io/util": "^0.2.98",
"@cerc-io/graph-node": "^0.2.98",
"@cerc-io/cli": "0.2.100",
"@cerc-io/graph-node": "0.2.100",
"@cerc-io/ipld-eth-client": "0.2.100",
"@cerc-io/solidity-mapper": "0.2.100",
"@cerc-io/util": "0.2.100",
"@ethersproject/providers": "^5.4.4",
"debug": "^4.3.1",
"decimal.js": "^10.3.1",

View File

@ -1040,7 +1040,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events and txs only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {

View File

@ -1,6 +1,6 @@
{
"name": "@cerc-io/v3-watcher",
"version": "0.1.0",
"version": "0.1.5",
"description": "v3-watcher",
"private": true,
"main": "dist/index.js",
@ -39,11 +39,11 @@
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/cli": "^0.2.98",
"@cerc-io/ipld-eth-client": "^0.2.98",
"@cerc-io/solidity-mapper": "^0.2.98",
"@cerc-io/util": "^0.2.98",
"@cerc-io/graph-node": "^0.2.98",
"@cerc-io/cli": "0.2.100",
"@cerc-io/graph-node": "0.2.100",
"@cerc-io/ipld-eth-client": "0.2.100",
"@cerc-io/solidity-mapper": "0.2.100",
"@cerc-io/util": "0.2.100",
"@ethersproject/providers": "^5.4.4",
"debug": "^4.3.1",
"decimal.js": "^10.3.1",

View File

@ -1424,7 +1424,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {

102
yarn.lock
View File

@ -194,10 +194,10 @@
binaryen "101.0.0-nightly.20210723"
long "^4.0.0"
"@cerc-io/cache@^0.2.98":
version "0.2.98"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fcache/-/0.2.98/cache-0.2.98.tgz#acbd54b0e3b0379652020f3dac832ed04cf392dc"
integrity sha512-scrDlufZIs0DDehEUL+eaab4Rz2r4G2fgvy2USeY3AnItreXMgUwTUAR7pXqh3FOCuj9crNfysH09Et+49/F/w==
"@cerc-io/cache@^0.2.100":
version "0.2.100"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fcache/-/0.2.100/cache-0.2.100.tgz#59b5d575f51ab23dfcf8165dde73ce4f075ae4cf"
integrity sha512-hPS40QcF9YGazFrzieFgA+r71ONsEV746qrVrVIMavekE/ocAXY6ZwDLy1fG0Nkib8MbA45kBavHgdvsUkVVMw==
dependencies:
canonical-json "^0.0.4"
debug "^4.3.1"
@ -205,19 +205,19 @@
fs-extra "^10.0.0"
level "^7.0.0"
"@cerc-io/cli@^0.2.98":
version "0.2.98"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fcli/-/0.2.98/cli-0.2.98.tgz#b29046fe48260e3e465c240d0aa64da84ad2338d"
integrity sha512-d79Gm3YOLn+CEidPBHaQhm1zu873O75LnFyH7fbIOubC4cBDWQk+RdH5U+8jU4b54EPZeVRotSoo7rQ5V8HsDg==
"@cerc-io/cli@0.2.100", "@cerc-io/cli@^0.2.100":
version "0.2.100"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fcli/-/0.2.100/cli-0.2.100.tgz#474ce337f187c0f21858a8d229bf4692e0d3c8ea"
integrity sha512-katc0+o86CR2mtAe4lVx9Lf44q943wUbsoqKtbvbHFLypYuyMVkAOs6xgKEwhiHkryJlBLFRaxkpV7HSFbgc+g==
dependencies:
"@apollo/client" "^3.7.1"
"@cerc-io/cache" "^0.2.98"
"@cerc-io/ipld-eth-client" "^0.2.98"
"@cerc-io/cache" "^0.2.100"
"@cerc-io/ipld-eth-client" "^0.2.100"
"@cerc-io/libp2p" "^0.42.2-laconic-0.1.4"
"@cerc-io/nitro-node" "^0.1.15"
"@cerc-io/peer" "^0.2.98"
"@cerc-io/rpc-eth-client" "^0.2.98"
"@cerc-io/util" "^0.2.98"
"@cerc-io/peer" "^0.2.100"
"@cerc-io/rpc-eth-client" "^0.2.100"
"@cerc-io/util" "^0.2.100"
"@ethersproject/providers" "^5.4.4"
"@graphql-tools/utils" "^9.1.1"
"@ipld/dag-cbor" "^8.0.0"
@ -238,16 +238,16 @@
typeorm "0.2.37"
yargs "^17.0.1"
"@cerc-io/graph-node@^0.2.98":
version "0.2.98"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fgraph-node/-/0.2.98/graph-node-0.2.98.tgz#06b7eb0feb1e1c4ae4e203b6007b8f0c0ac3c218"
integrity sha512-6PGVnPyRihW1f+yyU2TL61ALnsVN1f5MffmHxiJ+Co02F5t/RP7sfYjJPdT63S+W6mlwpnnmGyX0LuklOXpezQ==
"@cerc-io/graph-node@0.2.100", "@cerc-io/graph-node@^0.2.100":
version "0.2.100"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fgraph-node/-/0.2.100/graph-node-0.2.100.tgz#00d00e1fdd766c5035f2f492cd84d6f956187de9"
integrity sha512-8YmEo2xn3/c7ccAHsc+L70j0L0Tqtu3eGJaQdAePgO5KunvcXdjvVlJ9o31HqnQkU/AUSwVfOYNhb0GvCDUugw==
dependencies:
"@apollo/client" "^3.3.19"
"@cerc-io/assemblyscript" "0.19.10-watcher-ts-0.1.2"
"@cerc-io/cache" "^0.2.98"
"@cerc-io/ipld-eth-client" "^0.2.98"
"@cerc-io/util" "^0.2.98"
"@cerc-io/cache" "^0.2.100"
"@cerc-io/ipld-eth-client" "^0.2.100"
"@cerc-io/util" "^0.2.100"
"@types/json-diff" "^0.5.2"
"@types/yargs" "^17.0.0"
bn.js "^4.11.9"
@ -264,14 +264,14 @@
typeorm-naming-strategies "^2.0.0"
yargs "^17.0.1"
"@cerc-io/ipld-eth-client@^0.2.98":
version "0.2.98"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fipld-eth-client/-/0.2.98/ipld-eth-client-0.2.98.tgz#c1a7128be1e81fb4d1ec9a9888b7e5e94ae710ac"
integrity sha512-qCnz7foqf+9+X/zEGAu5HGXlvzNwahcsKu6Rtreh8bxhR5VTuuF3KrEeFcQeL1Bhv5+w7KXs5I+ivEgo4ZvHSA==
"@cerc-io/ipld-eth-client@0.2.100", "@cerc-io/ipld-eth-client@^0.2.100":
version "0.2.100"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fipld-eth-client/-/0.2.100/ipld-eth-client-0.2.100.tgz#89a764100c42651db466881249f01168fb6ffd76"
integrity sha512-COmHp2/VSvox4OQ43jD/Go1o6WiPtJL2dj6Pq3XBiK10ZiRa5AHzfcYRiUDMm43ocEibHkDerVQWi67qCGP+PA==
dependencies:
"@apollo/client" "^3.7.1"
"@cerc-io/cache" "^0.2.98"
"@cerc-io/util" "^0.2.98"
"@cerc-io/cache" "^0.2.100"
"@cerc-io/util" "^0.2.100"
cross-fetch "^3.1.4"
debug "^4.3.1"
ethers "^5.4.4"
@ -394,10 +394,10 @@
lodash "^4.17.21"
uint8arrays "^4.0.3"
"@cerc-io/peer@^0.2.65":
version "0.2.97"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fpeer/-/0.2.97/peer-0.2.97.tgz#6b386a53220bb4b026337eb2ef4246b3eeb947f9"
integrity sha512-ylJslts/q6uGVlHS27GiHKYVpTTTv/4vryexxqDPA45YJRk0vCleqRDPehRQr40kCgBQjG9W92Uwcwr7HcSQxQ==
"@cerc-io/peer@^0.2.100":
version "0.2.100"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fpeer/-/0.2.100/peer-0.2.100.tgz#e5affefe078b8bdaf905c3a125265c8fb28a7ca1"
integrity sha512-1xa9++Hb5kHlGPf/sQt5epLXkDzzOVcII4Jyw5txk1fKKbnMB7tXa2mn33XM9fi6fYjImR9Ki8V+Tow3GlCYIQ==
dependencies:
"@cerc-io/libp2p" "^0.42.2-laconic-0.1.4"
"@cerc-io/prometheus-metrics" "1.1.4"
@ -424,10 +424,10 @@
unique-names-generator "^4.7.1"
yargs "^17.0.1"
"@cerc-io/peer@^0.2.98":
version "0.2.98"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fpeer/-/0.2.98/peer-0.2.98.tgz#650c771be2a3767456f38c93cb86e6667f2867ec"
integrity sha512-b8sCTzFxfTgrlscNutBzML0y4rzkZvzjCpHDEp3P4fMRHIK9SM5o8yYaPS9g1NwoedjbLKCnCDrmaIGpLEbmqA==
"@cerc-io/peer@^0.2.65":
version "0.2.97"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fpeer/-/0.2.97/peer-0.2.97.tgz#6b386a53220bb4b026337eb2ef4246b3eeb947f9"
integrity sha512-ylJslts/q6uGVlHS27GiHKYVpTTTv/4vryexxqDPA45YJRk0vCleqRDPehRQr40kCgBQjG9W92Uwcwr7HcSQxQ==
dependencies:
"@cerc-io/libp2p" "^0.42.2-laconic-0.1.4"
"@cerc-io/prometheus-metrics" "1.1.4"
@ -466,23 +466,23 @@
it-stream-types "^1.0.4"
promjs "^0.4.2"
"@cerc-io/rpc-eth-client@^0.2.98":
version "0.2.98"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Frpc-eth-client/-/0.2.98/rpc-eth-client-0.2.98.tgz#005546cf25a245e60fa00b0c972239748ac1c29e"
integrity sha512-SjR621w5WxrhLsXyy17mTXo1UwvcPz9QPL4/mwQcwsvzDXoFff1bgxR7UGKInQG5QzGgwTJjAaozVqxQA1X3+g==
"@cerc-io/rpc-eth-client@^0.2.100":
version "0.2.100"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Frpc-eth-client/-/0.2.100/rpc-eth-client-0.2.100.tgz#527bd2560c3440a2035c4a0508c2f4606e4a3a48"
integrity sha512-KvnzsxeI9eWYiGHM+VjPL19n+oKeDGlO8ADhg4rwXuL3RuTcgkhm6J7z04NnkK+V0WmB9W/3AoYK3JFJPOosLQ==
dependencies:
"@cerc-io/cache" "^0.2.98"
"@cerc-io/ipld-eth-client" "^0.2.98"
"@cerc-io/util" "^0.2.98"
"@cerc-io/cache" "^0.2.100"
"@cerc-io/ipld-eth-client" "^0.2.100"
"@cerc-io/util" "^0.2.100"
chai "^4.3.4"
ethers "^5.4.4"
left-pad "^1.3.0"
mocha "^8.4.0"
"@cerc-io/solidity-mapper@^0.2.98":
version "0.2.98"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fsolidity-mapper/-/0.2.98/solidity-mapper-0.2.98.tgz#6fc8dfcaf872e31964a6cca1ea9fbd7900119f8a"
integrity sha512-RmGmcgN0fZEZU0r4q14qPm2hVHUK/OQVPIEgyLEbcStHXupYLaTn79li1WpURI7yeVuJ7mFVaauviWA2DeG7dw==
"@cerc-io/solidity-mapper@0.2.100", "@cerc-io/solidity-mapper@^0.2.100":
version "0.2.100"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fsolidity-mapper/-/0.2.100/solidity-mapper-0.2.100.tgz#c32db3f6a93c78b16011dae951e506092cc3b03b"
integrity sha512-1SDvIBhTYsRBAwi3R9xi813r0hPBdehbkdmYpcvdQzzim8ZX9zeX7Izelt/8BTjQ5BcByS403zNFaY/TzT/N8g==
dependencies:
dotenv "^10.0.0"
@ -491,15 +491,15 @@
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fts-channel/-/1.0.3-ts-nitro-0.1.1/ts-channel-1.0.3-ts-nitro-0.1.1.tgz#0768781313a167295c0bf21307f47e02dc17e936"
integrity sha512-2jFICUSyffuZ+8+qRhXuLSJq4GJ6Y02wxiXoubH0Kzv2lIKkJtWICY1ZQQhtXAvP0ncAQB85WJHqtqwH8l7J3Q==
"@cerc-io/util@^0.2.98":
version "0.2.98"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Futil/-/0.2.98/util-0.2.98.tgz#0bed961a20d43c8973d5b86b400086caa76d2d0a"
integrity sha512-s1St/bD9OjD3NIfx3gj1tDELgpiyxGl6le3mCs77jHM4KbEHW7pFjhe/5YsLXRvc5cIHwNsrCdOuSAIyVUtC2Q==
"@cerc-io/util@0.2.100", "@cerc-io/util@^0.2.100":
version "0.2.100"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Futil/-/0.2.100/util-0.2.100.tgz#6530496cfd7a9d047cd1bbbd9b2140cd250f26df"
integrity sha512-5k1La/KasXsrVXZcikFBafBwVeTMCRmuyrHsjokNq1ic+yzByotYRcYPyIZBiNVFe8/ne6d3uGuF3KouI94EYg==
dependencies:
"@apollo/utils.keyvaluecache" "^1.0.1"
"@cerc-io/nitro-node" "^0.1.15"
"@cerc-io/peer" "^0.2.98"
"@cerc-io/solidity-mapper" "^0.2.98"
"@cerc-io/peer" "^0.2.100"
"@cerc-io/solidity-mapper" "^0.2.100"
"@cerc-io/ts-channel" "1.0.3-ts-nitro-0.1.1"
"@ethersproject/properties" "^5.7.0"
"@ethersproject/providers" "^5.4.4"