From 4c618e587b85a44658fcae9bd1e20b1b675a291b Mon Sep 17 00:00:00 2001 From: Jordan Sheinfeld Date: Sun, 5 Jan 2025 15:41:43 +0200 Subject: [PATCH] Fix support for array of ethereum-endpoints received from the new management-service. --- src/index.ts | 13 ++++++++++++- src/status/.gitignore | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/status/.gitignore diff --git a/src/index.ts b/src/index.ts index acb4314..ebbc265 100644 --- a/src/index.ts +++ b/src/index.ts @@ -135,7 +135,18 @@ async function runLoopTick(config: Configuration, state: State) { async function initializeState(config: Configuration): Promise { const state = new State(); - await initWeb3Client(config.EthereumEndpoint, config.EthereumElectionsContract, state); + // check if config.EthereumEndpoint is array or single. + + let ethereumElectionsContract = ''; + + if (Array.isArray(config.EthereumEndpoint)) { + // if array, use the first one + ethereumElectionsContract = (Array)(config.EthereumElectionsContract)[0]; + } else { + ethereumElectionsContract = config.EthereumElectionsContract; + } + + await initWeb3Client(ethereumElectionsContract, config.EthereumElectionsContract, state); state.signer = new Signer(config.SignerEndpoint); return state; } diff --git a/src/status/.gitignore b/src/status/.gitignore new file mode 100644 index 0000000..ee000a4 --- /dev/null +++ b/src/status/.gitignore @@ -0,0 +1 @@ +/status.json