From d3d739b4b6046c19ffe8d2927252b12a44a01858 Mon Sep 17 00:00:00 2001 From: nicholaspai Date: Tue, 10 Oct 2023 11:08:27 -0400 Subject: [PATCH] fix(adapter-manager): Handle undefined chain-specific wrapEther config --- src/clients/InventoryClient.ts | 2 +- src/clients/bridges/AdapterManager.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/clients/InventoryClient.ts b/src/clients/InventoryClient.ts index ffca512bc..ac656f125 100644 --- a/src/clients/InventoryClient.ts +++ b/src/clients/InventoryClient.ts @@ -636,7 +636,7 @@ export class InventoryClient { async wrapL2EthIfAboveThreshold(): Promise { // If inventoryConfig is defined, there will be a default wrapEtherTarget and wrapEtherThreshold // set by RelayerConfig.ts - if (!this?.inventoryConfig) { + if (!this?.inventoryConfig?.wrapEtherThreshold || !this?.inventoryConfig?.wrapEtherTarget) { return; } this.log("Checking ETH->WETH Wrap status"); diff --git a/src/clients/bridges/AdapterManager.ts b/src/clients/bridges/AdapterManager.ts index d3329d518..50e3b0efc 100644 --- a/src/clients/bridges/AdapterManager.ts +++ b/src/clients/bridges/AdapterManager.ts @@ -84,8 +84,8 @@ export class AdapterManager { await utils.mapAsync( this.chainsToWrapEtherOn.filter((chainId) => isDefined(this.spokePoolClients[chainId])), async (chainId) => { - const wrapThreshold = inventoryConfig.wrapEtherThresholdPerChain[chainId] ?? inventoryConfig.wrapEtherThreshold; - const wrapTarget = inventoryConfig.wrapEtherTargetPerChain[chainId] ?? inventoryConfig.wrapEtherTarget; + const wrapThreshold = inventoryConfig?.wrapEtherThresholdPerChain?.[chainId] ?? inventoryConfig.wrapEtherThreshold; + const wrapTarget = inventoryConfig?.wrapEtherTargetPerChain?.[chainId] ?? inventoryConfig.wrapEtherTarget; assert( wrapThreshold.gte(wrapTarget), `wrapEtherThreshold ${wrapThreshold.toString()} must be >= wrapEtherTarget ${wrapTarget.toString()}`