Skip to content

Commit

Permalink
Fix: use recommendedMasterCopyVersion only for Safe upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Jan 8, 2025
1 parent ebfb7f4 commit 89906f3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/components/settings/ContractVersion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const ContractVersion = () => {
const showUpdateDialog = safeMasterCopy?.deployer === MasterCopyDeployer.GNOSIS && needsUpdate
const isLatestVersion = safe.version && !showUpdateDialog

const latestSafeVersion = getLatestSafeVersion(currentChain)
const latestSafeVersion = getLatestSafeVersion(currentChain, true)

return (
<>
Expand Down
13 changes: 7 additions & 6 deletions apps/web/src/features/multichain/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ export const predictAddressBasedOnReplayData = async (safeCreationData: Replayed
return getCreate2Address(safeCreationData.factoryAddress, salt, keccak256(initCode))
}

const canMultichain = (chain: ChainInfo) => {
const MIN_SAFE_VERSION = '1.4.1'
return hasFeature(chain, FEATURES.COUNTERFACTUAL) && semverSatisfies(LATEST_SAFE_VERSION, `>=${MIN_SAFE_VERSION}`)
}

export const hasMultiChainCreationFeatures = (chain: ChainInfo): boolean => {
return hasFeature(chain, FEATURES.MULTI_CHAIN_SAFE_CREATION) && hasFeature(chain, FEATURES.COUNTERFACTUAL)
return hasFeature(chain, FEATURES.MULTI_CHAIN_SAFE_CREATION) && canMultichain(chain)
}

export const hasMultiChainAddNetworkFeature = (chain: ChainInfo | undefined): boolean => {
if (!chain) return false
return (
hasFeature(chain, FEATURES.MULTI_CHAIN_SAFE_ADD_NETWORK) &&
hasFeature(chain, FEATURES.COUNTERFACTUAL) &&
semverSatisfies(chain.recommendedMasterCopyVersion || LATEST_SAFE_VERSION, '>=1.4.1')
)
return hasFeature(chain, FEATURES.MULTI_CHAIN_SAFE_ADD_NETWORK) && canMultichain(chain)
}
2 changes: 1 addition & 1 deletion apps/web/src/services/tx/safeUpdateParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const createUpdateSafeTxs = async (safe: SafeInfo, chain: ChainInfo): Pro
).getAddress()
const currentReadOnlySafeContract = await getReadOnlyGnosisSafeContract(chain, safe.version)

const updatedReadOnlySafeContract = await getReadOnlyGnosisSafeContract(chain, getLatestSafeVersion(chain))
const updatedReadOnlySafeContract = await getReadOnlyGnosisSafeContract(chain, getLatestSafeVersion(chain, true))

// @ts-expect-error this was removed in 1.3.0 but we need to support it for older safe versions
const changeMasterCopyCallData = currentReadOnlySafeContract.encode('changeMasterCopy', [latestMasterCopyAddress])
Expand Down
7 changes: 5 additions & 2 deletions apps/web/src/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ export const isRouteEnabled = (route: string, chain?: ChainInfo) => {
return !featureRoute || hasFeature(chain, featureRoute)
}

export const getLatestSafeVersion = (chain: ChainInfo | undefined): SafeVersion => {
const latestSafeVersion = chain?.recommendedMasterCopyVersion || LATEST_SAFE_VERSION
export const getLatestSafeVersion = (chain: ChainInfo | undefined, isUpgrade = false): SafeVersion => {
const latestSafeVersion = isUpgrade
? chain?.recommendedMasterCopyVersion || LATEST_SAFE_VERSION // for upgrades, use the recommended version
: LATEST_SAFE_VERSION // for Safe creation, always use the latest version

// Without version filter it will always return the LATEST_SAFE_VERSION constant to avoid automatically updating to the newest version if the deployments change
const latestDeploymentVersion = (getSafeSingletonDeployment({ network: chain?.chainId, released: true })?.version ??
FALLBACK_SAFE_VERSION) as SafeVersion
Expand Down

0 comments on commit 89906f3

Please sign in to comment.