Skip to content

Commit

Permalink
Revert chainId to number in monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzdogan committed Jul 3, 2023
1 parent d1f658a commit 44925c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
20 changes: 10 additions & 10 deletions src/common/SourcifyEventManager/SourcifyEventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
23 changes: 13 additions & 10 deletions src/monitor/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.",
});
}
Expand All @@ -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;
};

Expand All @@ -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,
});

Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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,
});
})
Expand Down Expand Up @@ -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,
});
}
Expand All @@ -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(
Expand Down Expand Up @@ -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,
});
}
Expand Down

0 comments on commit 44925c9

Please sign in to comment.