Skip to content

Commit

Permalink
Fix: adda a guard for a possibly undefined safeAccountConfig (#4529)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh authored Nov 19, 2024
1 parent 7ff7532 commit 6b64842
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/features/counterfactual/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down

0 comments on commit 6b64842

Please sign in to comment.