-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9489b4
commit 0e14417
Showing
10 changed files
with
132 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Chainflow Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
RPC_WS_ENDPOINT_URL_LIST= | ||
START_BLOCK= | ||
KAFKA_CONNECTION_URL= | ||
MONGO_URL= | ||
PRODUCER_TOPIC=polygon.1.blocks | ||
|
||
#LOGGER_ENV | ||
SENTRY_DSN= | ||
SENTRY_ENVIRONMENT= | ||
DATADOG_API_KEY= | ||
DATADOG_APP_KEY= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
env: { | ||
es2021: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
}, | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
rules: { | ||
}, | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "ethereum-producer", | ||
"version": "1.0.0", | ||
"description": "", | ||
"exports": "./dist/", | ||
"type": "module", | ||
"scripts": { | ||
"tests": "echo here will be Unit test run", | ||
"tests:integration": "echo 'Hello integration tests'", | ||
"lint": "eslint src/**/*.ts", | ||
"lint:fix": "eslint --fix ./src/**/*.ts", | ||
"build": "tsup", | ||
"start": "node --experimental-import-meta-resolve --trace-warnings dist/index.js", | ||
"link:lib": "npm link @maticnetwork/chainflow", | ||
"link:lib:build": "npm run link:lib && npm run build" | ||
}, | ||
"author": "nitinmittal23", | ||
"license": "ISC", | ||
"dependencies": { | ||
"dotenv": "^16.0.1", | ||
"@maticnetwork/chainflow": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.31.0", | ||
"@typescript-eslint/parser": "^5.31.0", | ||
"eslint": "^8.20.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"tsup": "^6.2.3", | ||
"typescript": "^4.8.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { produceBlocks } from "@maticnetwork/chainflow/block_producers/produce_blocks"; | ||
import { Logger } from "@maticnetwork/chainflow/logger"; | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
Logger.create({ | ||
sentry: { | ||
dsn: process.env.SENTRY_DSN, | ||
level: 'error' | ||
}, | ||
datadog: { | ||
api_key: process.env.DATADOG_API_KEY, | ||
service_name: process.env.DATADOG_APP_KEY | ||
}, | ||
console: { | ||
level: "debug" | ||
} | ||
}); | ||
|
||
const producer = produceBlocks({ | ||
startBlock: parseInt(process.env.START_BLOCK as string), | ||
rpcWsEndpoints: process.env.RPC_WS_ENDPOINT_URL_LIST?.split(','), | ||
topic: process.env.PRODUCER_TOPIC || "polygon.1.blocks", | ||
maxReOrgDepth: 96, | ||
maxRetries: 5, | ||
mongoUrl: process.env.MONGO_URL, | ||
blockSubscriptionTimeout: 120000, | ||
"bootstrap.servers": process.env.KAFKA_CONNECTION_URL || "localhost:9092", | ||
"security.protocol": "plaintext", | ||
type: "erigon" | ||
}) | ||
|
||
producer.on("blockProducer.fatalError", (error: any) => { | ||
Logger.error(`Block producer exited. ${error.message}`); | ||
|
||
process.exit(1); //Exiting process on fatal error. Process manager needs to restart the process. | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "NodeNext", | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"target": "esnext", | ||
"moduleResolution": "nodenext", | ||
"sourceMap": true, | ||
"outDir": "dist", | ||
"declaration": true, | ||
"alwaysStrict": true, | ||
"strict": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from 'tsup'; | ||
|
||
export default defineConfig({ | ||
entry: [ | ||
'./src/index.ts' | ||
], | ||
splitting: false, | ||
sourcemap: true, | ||
clean: true, | ||
format: 'esm', | ||
bundle: false, | ||
platform: 'node', | ||
dts: true | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters