From d4e1d16ca14ce16affacaa5293e41e2eee5806bc Mon Sep 17 00:00:00 2001 From: schmanu Date: Fri, 1 Nov 2024 17:10:14 +0100 Subject: [PATCH 1/2] fix: upgrade transactions for 1.0.0 Safes --- src/services/tx/__tests__/safeUpdateParams.test.ts | 9 +++++++-- src/services/tx/safeUpdateParams.ts | 11 ++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/services/tx/__tests__/safeUpdateParams.test.ts b/src/services/tx/__tests__/safeUpdateParams.test.ts index 1adc17e7a3..e49692ce94 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 older 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[] = [ { From 045c7d521ca6ea894fa0713f0aa0f4d2851586ce Mon Sep 17 00:00:00 2001 From: Manuel Gellfart Date: Mon, 4 Nov 2024 08:43:17 +0100 Subject: [PATCH 2/2] fix: test description Co-authored-by: Aaron Cook --- src/services/tx/__tests__/safeUpdateParams.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/tx/__tests__/safeUpdateParams.test.ts b/src/services/tx/__tests__/safeUpdateParams.test.ts index e49692ce94..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 setFallbackHandler transaction data for older 1.0.0 Safes', async () => { + it('Should add setFallbackHandler transaction data for 1.0.0 Safes', async () => { const mockSafe = { address: { value: MOCK_SAFE_ADDRESS,