diff --git a/src/services/tx/__tests__/safeUpdateParams.test.ts b/src/services/tx/__tests__/safeUpdateParams.test.ts index 1adc17e7a3..d3e74623e2 100644 --- a/src/services/tx/__tests__/safeUpdateParams.test.ts +++ b/src/services/tx/__tests__/safeUpdateParams.test.ts @@ -30,7 +30,7 @@ describe('safeUpgradeParams', () => { jest.spyOn(sdkHelpers, 'getSafeProvider').mockImplementation(() => getMockSafeProviderForChain(1)) - it('Should add empty setFallbackHandler transaction data for older Safes', async () => { + it('Should add setFallbackHandler transaction data for 1.0.0 Safes', async () => { const mockSafe = { address: { value: MOCK_SAFE_ADDRESS, @@ -58,7 +58,12 @@ describe('safeUpgradeParams', () => { // Check setFallbackHandler expect(sameAddress(fallbackHandlerTx.to, MOCK_SAFE_ADDRESS)).toBeTruthy() expect(fallbackHandlerTx.value).toEqual('0') - expect(fallbackHandlerTx.data).toEqual('0x') + expect( + sameAddress( + decodeSetFallbackHandlerAddress(fallbackHandlerTx.data), + getFallbackHandlerDeployment({ version: getLatestSafeVersion(mockChainInfo), network: '1' })?.defaultAddress, + ), + ).toBeTruthy() }) it('Should upgrade L1 safe to L1 1.4.1', async () => { diff --git a/src/services/tx/safeUpdateParams.ts b/src/services/tx/safeUpdateParams.ts index 3d9fff40b9..9b0fc5f320 100644 --- a/src/services/tx/safeUpdateParams.ts +++ b/src/services/tx/safeUpdateParams.ts @@ -9,11 +9,10 @@ import { hasSafeFeature } from '@/utils/safe-versions' import { getLatestSafeVersion } from '@/utils/chains' const getChangeFallbackHandlerCallData = async ( - safe: SafeInfo, safeContractInstance: SafeContractImplementationType, chain: ChainInfo, ): Promise => { - if (!hasSafeFeature(SAFE_FEATURES.SAFE_FALLBACK_HANDLER, safe.version)) { + if (!hasSafeFeature(SAFE_FEATURES.SAFE_FALLBACK_HANDLER, getLatestSafeVersion(chain))) { return '0x' } @@ -36,11 +35,13 @@ export const createUpdateSafeTxs = async (safe: SafeInfo, chain: ChainInfo): Pro const latestMasterCopyAddress = await ( await getReadOnlyGnosisSafeContract(chain, getLatestSafeVersion(chain)) ).getAddress() - const readOnlySafeContract = await getReadOnlyGnosisSafeContract(chain, safe.version) + const currentReadOnlySafeContract = await getReadOnlyGnosisSafeContract(chain, safe.version) + + const updatedReadOnlySafeContract = await getReadOnlyGnosisSafeContract(chain, getLatestSafeVersion(chain)) // @ts-expect-error this was removed in 1.3.0 but we need to support it for older safe versions - const changeMasterCopyCallData = readOnlySafeContract.encode('changeMasterCopy', [latestMasterCopyAddress]) - const changeFallbackHandlerCallData = await getChangeFallbackHandlerCallData(safe, readOnlySafeContract, chain) + const changeMasterCopyCallData = currentReadOnlySafeContract.encode('changeMasterCopy', [latestMasterCopyAddress]) + const changeFallbackHandlerCallData = await getChangeFallbackHandlerCallData(updatedReadOnlySafeContract, chain) const txs: MetaTransactionData[] = [ {