From 36c3691f6102e1aa9124f8e7b37397515f3e26f4 Mon Sep 17 00:00:00 2001 From: Julian Merlo Date: Tue, 5 Dec 2023 10:20:19 -0300 Subject: [PATCH] feature-798/enable-evm-celo-chain --- .../config/custom-environment-variables.json | 7 +++ blockchain-watcher/config/default.json | 8 +++ blockchain-watcher/config/mainnet.json | 4 ++ blockchain-watcher/package.json | 3 +- .../repositories/RepositoriesBuilder.ts | 2 +- .../repositories/RepositoriesBuilder.test.ts | 2 + blockchain-watcher/test/mocks/configMock.ts | 11 +++- .../workers/ethereum-1.yaml | 56 +++++++++++++++++++ 8 files changed, 89 insertions(+), 4 deletions(-) diff --git a/blockchain-watcher/config/custom-environment-variables.json b/blockchain-watcher/config/custom-environment-variables.json index 0e971d70..6d44cfc8 100644 --- a/blockchain-watcher/config/custom-environment-variables.json +++ b/blockchain-watcher/config/custom-environment-variables.json @@ -54,6 +54,13 @@ "__format": "json" } }, + "celo": { + "network": "CELO_NETWORK", + "rpcs": { + "__name": "CELO_NETWORK", + "__format": "json" + } + }, "optimism": { "network": "OPTIMISM_NETWORK", "rpcs": { diff --git a/blockchain-watcher/config/default.json b/blockchain-watcher/config/default.json index 7af6d8d8..534ff009 100644 --- a/blockchain-watcher/config/default.json +++ b/blockchain-watcher/config/default.json @@ -10,6 +10,7 @@ "fantom", "karura", "acala", + "celo", "optimism", "base" ], @@ -72,6 +73,13 @@ "rpcs": ["https://eth-rpc-acala-testnet.aca-staging.network"], "timeout": 10000 }, + "celo": { + "name": "celo", + "network": "alfajores", + "chainId": 14, + "rpcs": ["https://alfajores-forno.celo-testnet.org"], + "timeout": 10000 + }, "optimism": { "name": "optimism", "network": "goerli", diff --git a/blockchain-watcher/config/mainnet.json b/blockchain-watcher/config/mainnet.json index 7144fe18..aeeba796 100644 --- a/blockchain-watcher/config/mainnet.json +++ b/blockchain-watcher/config/mainnet.json @@ -24,6 +24,10 @@ "network": "mainnet", "rpcs": ["https://eth-rpc-acala.aca-api.network"] }, + "celo": { + "network": "mainnet", + "rpcs": ["https://forno.celo.org"] + }, "optimism": { "network": "mainnet", "rpcs": ["https://rpc.ankr.com/optimism"] diff --git a/blockchain-watcher/package.json b/blockchain-watcher/package.json index 8321fada..29bfffc7 100644 --- a/blockchain-watcher/package.json +++ b/blockchain-watcher/package.json @@ -11,7 +11,8 @@ "build": "tsc", "build:ncc": "ncc build src/start.ts -o lib", "dev": "ts-node src/start.ts", - "dev:debug": "ts-node src/start.ts start --debug --watch", + "dev:debug-testnet": "ts-node src/start.ts start --debug --watch", + "dev:debug-mainnet": "NODE_ENV=mainnet ts-node src/start.ts start --debug --watch", "prettier": "prettier --write ." }, "author": "chase-45", diff --git a/blockchain-watcher/src/infrastructure/repositories/RepositoriesBuilder.ts b/blockchain-watcher/src/infrastructure/repositories/RepositoriesBuilder.ts index f15c2fe4..00c9b7e6 100644 --- a/blockchain-watcher/src/infrastructure/repositories/RepositoriesBuilder.ts +++ b/blockchain-watcher/src/infrastructure/repositories/RepositoriesBuilder.ts @@ -15,7 +15,7 @@ import { HttpClient } from "../rpc/http/HttpClient"; import { JobRepository } from "../../domain/repositories"; const SOLANA_CHAIN = "solana"; -const EVM_CHAINS = ["ethereum", "avalanche", "fantom", "karura", "acala", "optimism", "base"]; +const EVM_CHAINS = ["ethereum", "avalanche", "fantom", "karura", "acala", "celo", "optimism", "base"]; export class RepositoriesBuilder { private cfg: Config; diff --git a/blockchain-watcher/test/infrastructure/repositories/RepositoriesBuilder.test.ts b/blockchain-watcher/test/infrastructure/repositories/RepositoriesBuilder.test.ts index c911dfe3..eb8bf08a 100644 --- a/blockchain-watcher/test/infrastructure/repositories/RepositoriesBuilder.test.ts +++ b/blockchain-watcher/test/infrastructure/repositories/RepositoriesBuilder.test.ts @@ -40,6 +40,7 @@ describe("RepositoriesBuilder", () => { "fantom", "karura", "acala", + "celo", "optimism", "base", ]) @@ -53,6 +54,7 @@ describe("RepositoriesBuilder", () => { expect(repos.getEvmBlockRepository("fantom")).toBeInstanceOf(EvmJsonRPCBlockRepository); expect(repos.getEvmBlockRepository("karura")).toBeInstanceOf(EvmJsonRPCBlockRepository); expect(repos.getEvmBlockRepository("acala")).toBeInstanceOf(EvmJsonRPCBlockRepository); + expect(repos.getEvmBlockRepository("celo")).toBeInstanceOf(EvmJsonRPCBlockRepository); expect(repos.getEvmBlockRepository("optimism")).toBeInstanceOf(EvmJsonRPCBlockRepository); expect(repos.getEvmBlockRepository("base")).toBeInstanceOf(EvmJsonRPCBlockRepository); expect(repos.getMetadataRepository()).toBeInstanceOf(FileMetadataRepository); diff --git a/blockchain-watcher/test/mocks/configMock.ts b/blockchain-watcher/test/mocks/configMock.ts index f920b957..3b13c18b 100644 --- a/blockchain-watcher/test/mocks/configMock.ts +++ b/blockchain-watcher/test/mocks/configMock.ts @@ -45,16 +45,23 @@ export const configMock = (chains: string[] = []): Config => { rpcs: ["http://localhost"], timeout: 10000, }, + celo: { + name: "celo", + network: "alfajores", + chainId: 14, + rpcs: ["http://localhost"], + timeout: 10000, + }, optimism: { name: "optimism", - network: "testnet", + network: "goerli", chainId: 12, rpcs: ["http://localhost"], timeout: 10000, }, base: { name: "base", - network: "testnet", + network: "goerli", chainId: 12, rpcs: ["http://localhost"], timeout: 10000, diff --git a/deploy/blockchain-watcher/workers/ethereum-1.yaml b/deploy/blockchain-watcher/workers/ethereum-1.yaml index adbccd80..58f05024 100644 --- a/deploy/blockchain-watcher/workers/ethereum-1.yaml +++ b/deploy/blockchain-watcher/workers/ethereum-1.yaml @@ -91,6 +91,34 @@ data: } } ] + }, + { + "id": "poll-log-message-published-celo", + "chain": "celo", + "source": { + "action": "PollEvmLogs", + "config": { + "blockBatchSize": 100, + "commitment": "latest", + "interval": 15000, + "addresses": ["0x88505117CA88e7dd2eC6EA1E13f0948db2D50D56"], + "chain": "celo" + } + }, + "handlers": [ + { + "action": "HandleEvmLogs", + "target": "sns", + "mapper": "evmLogMessagePublishedMapper", + "config": { + "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)", + "filter": { + "addresses": ["0x88505117CA88e7dd2eC6EA1E13f0948db2D50D56"], + "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"] + } + } + } + ] } ] mainnet-jobs.json: |- @@ -150,6 +178,34 @@ data: } } ] + }, + { + "id": "poll-log-message-published-celo", + "chain": "celo", + "source": { + "action": "PollEvmLogs", + "config": { + "blockBatchSize": 100, + "commitment": "latest", + "interval": 5000, + "addresses": ["0xa321448d90d4e5b0A732867c18eA198e75CAC48E"], + "chain": "celo" + } + }, + "handlers": [ + { + "action": "HandleEvmLogs", + "target": "sns", + "mapper": "evmLogMessagePublishedMapper", + "config": { + "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)", + "filter": { + "addresses": ["0xa321448d90d4e5b0A732867c18eA198e75CAC48E"], + "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"] + } + } + } + ] } ] ---