From 44925c9769bdcb857ee185530a99dee38a4fc8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Uzdo=C4=9Fan?= Date: Mon, 3 Jul 2023 17:53:44 +0200 Subject: [PATCH] Revert chainId to number in monitor --- .../SourcifyEventManager.ts | 20 ++++++++-------- src/monitor/monitor.ts | 23 +++++++++++-------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/common/SourcifyEventManager/SourcifyEventManager.ts b/src/common/SourcifyEventManager/SourcifyEventManager.ts index 80f585abc..386aaa158 100644 --- a/src/common/SourcifyEventManager/SourcifyEventManager.ts +++ b/src/common/SourcifyEventManager/SourcifyEventManager.ts @@ -4,48 +4,48 @@ import { EventManager, GenericEvents } from "../EventManager"; interface Events extends GenericEvents { "*": (event: string, argument: any) => void; "Verification.MatchStored": (match: Match) => void; - "Monitor.Error.CantStart": (e: { chainId: number; message: string }) => void; + "Monitor.Error.CantStart": (e: { chainId: string; message: string }) => void; "Monitor.Started": (obj: { - chainId: number; + chainId: string; providerURL: string; lastBlockNumber: number; startBlock: number; }) => void; - "Monitor.Stopped": (chainId: number) => void; + "Monitor.Stopped": (chainId: string) => void; "Monitor.ProcessingBlock": (obj: { blockNumber: number; - chainId: number; + chainId: string; getBlockPause: number; }) => void; "Monitor.Verified": (match: Match) => void; "Monitor.AlreadyVerified": (obj: { address: string; - chainId: number; + chainId: string; }) => void; - "Monitor.NewContract": (obj: { address: string; chainId: number }) => void; + "Monitor.NewContract": (obj: { address: string; chainId: string }) => void; "Monitor.Error": (obj: { message: string; stack?: string }) => void; "Monitor.Error.ProcessingBlock": (obj: { message: string; stack: string; blockNumber: number; - chainId: number; + chainId: string; }) => void; "Monitor.Error.ProcessingBytecode": (obj: { message: string; stack: string; - chainId: number; + chainId: string; address: string; }) => void; "Monitor.Error.GettingBytecode": (obj: { message: string; stack: string; - chainId: number; + chainId: string; address: string; }) => void; "Monitor.Error.VerifyError": (obj: { message: string; stack: string; - chainId: number; + chainId: string; address: string; }) => void; "SourceFetcher.UsingFallback": (obj: { diff --git a/src/monitor/monitor.ts b/src/monitor/monitor.ts index ccec43f28..3c93a01d6 100755 --- a/src/monitor/monitor.ts +++ b/src/monitor/monitor.ts @@ -105,7 +105,7 @@ class ChainMonitor extends EventEmitter { : lastBlockNumber; SourcifyEventManager.trigger("Monitor.Started", { - chainId: this.sourcifyChain.chainId, + chainId: this.sourcifyChain.chainId.toString(), providerURL, lastBlockNumber, startBlock, @@ -119,7 +119,7 @@ class ChainMonitor extends EventEmitter { if (!found) { SourcifyEventManager.trigger("Monitor.Error.CantStart", { - chainId: this.sourcifyChain.chainId, + chainId: this.sourcifyChain.chainId.toString(), message: "Couldn't find a working RPC node.", }); } @@ -129,7 +129,10 @@ class ChainMonitor extends EventEmitter { * Stops the monitor after executing all pending requests. */ stop = (): void => { - SourcifyEventManager.trigger("Monitor.Stopped", this.sourcifyChain.chainId); + SourcifyEventManager.trigger( + "Monitor.Stopped", + this.sourcifyChain.chainId.toString() + ); this.running = false; }; @@ -151,7 +154,7 @@ class ChainMonitor extends EventEmitter { SourcifyEventManager.trigger("Monitor.ProcessingBlock", { blockNumber, - chainId: this.sourcifyChain.chainId, + chainId: this.sourcifyChain.chainId.toString(), getBlockPause: this.getBlockPause, }); @@ -161,7 +164,7 @@ class ChainMonitor extends EventEmitter { if (this.isVerified(address)) { SourcifyEventManager.trigger("Monitor.AlreadyVerified", { address, - chainId: this.sourcifyChain.chainId, + chainId: this.sourcifyChain.chainId.toString(), }); this.emit( "contract-already-verified", @@ -171,7 +174,7 @@ class ChainMonitor extends EventEmitter { } else { SourcifyEventManager.trigger("Monitor.NewContract", { address, - chainId: this.sourcifyChain.chainId, + chainId: this.sourcifyChain.chainId.toString(), }); this.processBytecode( tx.hash, @@ -188,7 +191,7 @@ class ChainMonitor extends EventEmitter { SourcifyEventManager.trigger("Monitor.Error.ProcessingBlock", { message: err.message, stack: err.stack, - chainId: this.sourcifyChain.chainId, + chainId: this.sourcifyChain.chainId.toString(), blockNumber, }); }) @@ -251,7 +254,7 @@ class ChainMonitor extends EventEmitter { SourcifyEventManager.trigger("Monitor.Error.ProcessingBytecode", { message: err.message, stack: err.stack, - chainId: this.sourcifyChain.chainId, + chainId: this.sourcifyChain.chainId.toString(), address, }); } @@ -260,7 +263,7 @@ class ChainMonitor extends EventEmitter { SourcifyEventManager.trigger("Monitor.Error.GettingBytecode", { message: err.message, stack: err.stack, - chainId: this.sourcifyChain.chainId, + chainId: this.sourcifyChain.chainId.toString(), address, }); this.mySetTimeout( @@ -296,7 +299,7 @@ class ChainMonitor extends EventEmitter { SourcifyEventManager.trigger("Monitor.Error.VerifyError", { message: err.message, stack: err.stack, - chainId: this.sourcifyChain.chainId, + chainId: this.sourcifyChain.chainId.toString(), address, }); }