Skip to content

Commit

Permalink
fix: upgrade transactions for 1.0.0 Safes (#4460)
Browse files Browse the repository at this point in the history
* fix: upgrade transactions for 1.0.0 Safes

* fix: test description

Co-authored-by: Aaron Cook <[email protected]>

---------

Co-authored-by: Aaron Cook <[email protected]>
  • Loading branch information
schmanu and iamacook authored Dec 10, 2024
1 parent 608d004 commit cff8b41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/services/tx/__tests__/safeUpdateParams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 () => {
Expand Down
11 changes: 6 additions & 5 deletions src/services/tx/safeUpdateParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> => {
if (!hasSafeFeature(SAFE_FEATURES.SAFE_FALLBACK_HANDLER, safe.version)) {
if (!hasSafeFeature(SAFE_FEATURES.SAFE_FALLBACK_HANDLER, getLatestSafeVersion(chain))) {
return '0x'
}

Expand All @@ -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[] = [
{
Expand Down

0 comments on commit cff8b41

Please sign in to comment.