Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(Multichain): no setupTol2 for legacy versions #4213

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading