Commit 452f5e0c authored by smartcontracts's avatar smartcontracts Committed by GitHub

Merge pull request #2366 from ethereum-optimism/sc/fix-base-service-options

fix(cmn): have BaseService throw on missing options
parents 024e444b 51673b90
---
'@eth-optimism/common-ts': patch
---
Have BaseServiceV2 throw when options are undefined
......@@ -218,6 +218,16 @@ export abstract class BaseServiceV2<
return acc
}, {}) as TOptions
// Make sure all options are defined.
for (const [optionName, optionSpec] of Object.entries(params.optionsSpec)) {
if (
optionSpec.default === undefined &&
this.options[optionName] === undefined
) {
throw new Error(`missing required option: ${optionName}`)
}
}
// Create the metrics objects.
this.metrics = Object.keys(params.metricsSpec || {}).reduce((acc, key) => {
const spec = params.metricsSpec[key]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment