From 338a74d7903776bf1c2bfd3e8f194253c1c65a15 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Mon, 18 Nov 2024 07:24:14 +0100 Subject: [PATCH] Fix: adda a guard for a possibly undefined safeAccountConfig --- src/features/counterfactual/utils.ts | 31 +++++++++++----------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/features/counterfactual/utils.ts b/src/features/counterfactual/utils.ts index e04772b29b..6e65e96063 100644 --- a/src/features/counterfactual/utils.ts +++ b/src/features/counterfactual/utils.ts @@ -356,27 +356,20 @@ export const extractCounterfactualSafeSetup = ( saltNonce: string | undefined } | undefined => { - if (!undeployedSafe || !chainId) { + if (!undeployedSafe || !chainId || !undeployedSafe.props.safeAccountConfig) { return undefined } - if (isPredictedSafeProps(undeployedSafe.props)) { - return { - owners: undeployedSafe.props.safeAccountConfig.owners, - threshold: undeployedSafe.props.safeAccountConfig.threshold, - fallbackHandler: undeployedSafe.props.safeAccountConfig.fallbackHandler, - safeVersion: undeployedSafe.props.safeDeploymentConfig?.safeVersion, - saltNonce: undeployedSafe.props.safeDeploymentConfig?.saltNonce, - } - } else { - const { owners, threshold, fallbackHandler } = undeployedSafe.props.safeAccountConfig - - return { - owners, - threshold: Number(threshold), - fallbackHandler, - safeVersion: undeployedSafe.props.safeVersion, - saltNonce: undeployedSafe.props.saltNonce, - } + const { owners, threshold, fallbackHandler } = undeployedSafe.props.safeAccountConfig + const { safeVersion, saltNonce } = isPredictedSafeProps(undeployedSafe.props) + ? undeployedSafe.props.safeDeploymentConfig ?? {} + : undeployedSafe.props + + return { + owners, + threshold: Number(threshold), + fallbackHandler, + safeVersion, + saltNonce, } }