Skip to content

Commit

Permalink
fix: dont add setupToL2 for older safe version
Browse files Browse the repository at this point in the history
  • Loading branch information
schmanu committed Sep 19, 2024
1 parent 91f0566 commit f6a43d8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/components/new-safe/create/logic/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,36 @@ describe('create/logic', () => {
})
})

it('should use l2 masterCopy and no migration on l2s with multichain feature but on old version', () => {
const safeSetup = {
owners: [faker.finance.ethereumAddress()],
threshold: 1,
}
expect(
createNewUndeployedSafeWithoutSalt(
'1.3.0',
safeSetup,
chainBuilder()
.with({ chainId: '137' })
// Multichain creation is toggled off
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ l2: true })
.build(),
),
).toEqual({
safeAccountConfig: {
...safeSetup,
fallbackHandler: getFallbackHandlerDeployment({ version: '1.3.0', network: '137' })?.defaultAddress,
to: ZERO_ADDRESS,
data: EMPTY_DATA,
paymentReceiver: ECOSYSTEM_ID_ADDRESS,
},
safeVersion: '1.3.0',
masterCopy: getSafeL2SingletonDeployment({ version: '1.3.0', network: '137' })?.defaultAddress,
factoryAddress: getProxyFactoryDeployment({ version: '1.3.0', network: '137' })?.defaultAddress,
})
})

it('should use l1 masterCopy and migration on l2s with multichain feature', () => {
const safeSetup = {
owners: [faker.finance.ethereumAddress()],
Expand Down
3 changes: 2 additions & 1 deletion src/components/new-safe/create/logic/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { SafeVersion } from '@safe-global/safe-core-sdk-types'
import { Interface, type Eip1193Provider, type Provider } from 'ethers'
import semverSatisfies from 'semver/functions/satisfies'

import { getSafeInfo, type SafeInfo, type ChainInfo, relayTransaction } from '@safe-global/safe-gateway-typescript-sdk'
import { getReadOnlyProxyFactoryContract } from '@/services/contracts/safeContracts'
Expand Down Expand Up @@ -225,7 +226,7 @@ export const createNewUndeployedSafeWithoutSalt = (
}

// Only do migration if the chain supports multiChain deployments.
const includeMigration = hasMultiChainCreationFeatures(chain)
const includeMigration = hasMultiChainCreationFeatures(chain) && semverSatisfies(safeVersion, '>=1.4.1')

const masterCopy = includeMigration ? safeL1Address : chain.l2 ? safeL2Address : safeL1Address

Expand Down

0 comments on commit f6a43d8

Please sign in to comment.