Skip to content

Commit

Permalink
Feat: upgrade to 1.4.1 (#4645)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh authored Dec 19, 2024
1 parent ad43394 commit b344122
Show file tree
Hide file tree
Showing 34 changed files with 956 additions and 669 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@safe-global/protocol-kit": "^4.1.3",
"@safe-global/safe-apps-sdk": "^9.1.0",
"@safe-global/safe-client-gateway-sdk": "v1.60.1",
"@safe-global/safe-gateway-typescript-sdk": "3.22.4",
"@safe-global/safe-gateway-typescript-sdk": "3.22.5-beta.0",
"@safe-global/safe-modules-deployments": "^2.2.1",
"@sentry/react": "^7.91.0",
"@spindl-xyz/attribution-lite": "^1.4.0",
Expand Down
1 change: 1 addition & 0 deletions src/components/common/ExternalLink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const ExternalLink = ({
display: 'inline-flex',
alignItems: 'center',
gap: 0.2,
cursor: 'pointer',
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,36 @@ describe('NetworkMultiSelector', () => {
.with({ chainId: '1' })
.with({ chainName: 'Ethereum' })
.with({ shortName: 'eth' })
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ features: [FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ recommendedMasterCopyVersion: '1.4.1' })
.build(),
chainBuilder()
.with({ chainId: '10' })
.with({ chainName: 'Optimism' })
.with({ shortName: 'oeth' })
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ features: [FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ recommendedMasterCopyVersion: '1.4.1' })
.build(),
chainBuilder()
.with({ chainId: '100' })
.with({ chainName: 'Gnosis Chain' })
.with({ shortName: 'gno' })
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ features: [FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ recommendedMasterCopyVersion: '1.4.1' })
.build(),
chainBuilder()
.with({ chainId: '324' })
.with({ chainName: 'ZkSync Era' })
.with({ shortName: 'zksync' })
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL] as any })
.with({ features: [FEATURES.COUNTERFACTUAL] as any })
.with({ recommendedMasterCopyVersion: '1.4.1' })
.build(),
chainBuilder()
.with({ chainId: '480' })
.with({ chainName: 'Worldchain' })
.with({ shortName: 'wc' })
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ features: [FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ recommendedMasterCopyVersion: '1.4.1' })
.build(),
]

Expand Down
19 changes: 10 additions & 9 deletions src/components/new-safe/create/logic/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
getReadOnlyProxyFactoryContract,
} from '@/services/contracts/safeContracts'
import { FEATURES, getLatestSafeVersion } from '@/utils/chains'
import { type FEATURES as GatewayFeatures } from '@safe-global/safe-gateway-typescript-sdk'
import { chainBuilder } from '@/tests/builders/chains'
import { type ReplayedSafeProps } from '@/store/slices'
import { faker } from '@faker-js/faker'
Expand All @@ -39,9 +38,7 @@ import { Safe_to_l2_setup__factory } from '@/types/contracts'
const provider = new JsonRpcProvider(undefined, { name: 'ethereum', chainId: 1 })

const latestSafeVersion = getLatestSafeVersion(
chainBuilder()
.with({ chainId: '1', features: [FEATURES.SAFE_141 as unknown as GatewayFeatures] })
.build(),
chainBuilder().with({ chainId: '1', recommendedMasterCopyVersion: '1.4.1' }).build(),
)

const safeToL2SetupDeployment = getSafeToL2SetupDeployment()
Expand All @@ -57,7 +54,7 @@ describe('create/logic', () => {
.with({
chainId: '1',
l2: false,
features: [FEATURES.SAFE_141 as unknown as GatewayFeatures],
recommendedMasterCopyVersion: '1.4.1',
})
.build()

Expand Down Expand Up @@ -209,7 +206,7 @@ describe('create/logic', () => {
chainBuilder()
.with({ chainId: '1' })
// Multichain creation is toggled off
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL] as any })
.with({ features: [FEATURES.COUNTERFACTUAL] as any })
.with({ l2: false })
.build(),
),
Expand Down Expand Up @@ -239,7 +236,8 @@ describe('create/logic', () => {
chainBuilder()
.with({ chainId: '137' })
// Multichain creation is toggled off
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL] as any })
.with({ features: [FEATURES.COUNTERFACTUAL] as any })
.with({ recommendedMasterCopyVersion: '1.4.1' })
.with({ l2: true })
.build(),
),
Expand Down Expand Up @@ -269,7 +267,8 @@ describe('create/logic', () => {
chainBuilder()
.with({ chainId: '137' })
// Multichain creation is toggled on
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ features: [FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ recommendedMasterCopyVersion: '1.3.0' })
.with({ l2: true })
.build(),
),
Expand Down Expand Up @@ -303,7 +302,8 @@ describe('create/logic', () => {
chainBuilder()
.with({ chainId: '137' })
// Multichain creation is toggled on
.with({ features: [FEATURES.SAFE_141, FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ features: [FEATURES.COUNTERFACTUAL, FEATURES.MULTI_CHAIN_SAFE_CREATION] as any })
.with({ recommendedMasterCopyVersion: '1.4.1' })
.with({ l2: true })
.build(),
),
Expand Down Expand Up @@ -336,6 +336,7 @@ describe('create/logic', () => {
.with({ chainId: '324' })
// Multichain and 1.4.1 creation is toggled off
.with({ features: [FEATURES.COUNTERFACTUAL] as any })
.with({ recommendedMasterCopyVersion: '1.3.0' })
.with({ l2: true })
.build(),
),
Expand Down
10 changes: 6 additions & 4 deletions src/components/settings/ContractVersion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ export const ContractVersion = () => {
sx={{ mt: 2, borderRadius: '2px', borderColor: '#B0FFC9' }}
icon={<SvgIcon component={InfoIcon} inheritViewBox color="secondary" />}
>
<AlertTitle sx={{ fontWeight: 700 }}>New version is available: {latestSafeVersion}</AlertTitle>
<AlertTitle sx={{ fontWeight: 700 }}>
New version is available: {latestSafeVersion} (
<ExternalLink href={safeMasterCopy?.deployerRepoUrl}>changelog</ExternalLink>)
</AlertTitle>

<Typography mb={3}>
<Typography mb={2}>
Update now to take advantage of new features and the highest security standards available. You will need to
confirm this update just like any other transaction.{' '}
<ExternalLink href={safeMasterCopy?.deployerRepoUrl}>GitHub</ExternalLink>
confirm this update just like any other transaction.
</Typography>

<CheckWallet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import MethodCall from './MethodCall'
import useSafeAddress from '@/hooks/useSafeAddress'
import { sameAddress } from '@/utils/addresses'
import { DelegateCallWarning } from '@/components/transactions/Warning'
import { isMigrateToL2TxData } from '@/utils/transaction-guards'

interface Props {
txData: TransactionDetails['txData']
Expand Down Expand Up @@ -58,11 +57,9 @@ export const DecodedData = ({ txData, toInfo }: Props): ReactElement | null => {
decodedData = <HexEncodedData title="Data (hex-encoded)" hexData={txData.hexData} />
}

const isL2Migration = isMigrateToL2TxData(txData, chainInfo?.chainId)

return (
<Stack spacing={2}>
{isDelegateCall && <DelegateCallWarning showWarning={!txData.trustedDelegateCallTarget && !isL2Migration} />}
{isDelegateCall && <DelegateCallWarning showWarning={!txData.trustedDelegateCallTarget} />}

{method ? (
<MethodCall contractAddress={toAddress} contractName={name} contractLogo={avatar} method={method} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { zeroPadValue } from 'ethers'
import DecodedData from '../DecodedData'
import ErrorMessage from '@/components/tx/ErrorMessage'
import { useSafeSDK } from '@/hooks/coreSDK/safeCoreSDK'
import { MigrateToL2Information } from '@/components/tx/SignOrExecuteForm/MigrateToL2Information'
import { MigrateToL2Information } from '@/components/tx/confirmation-views/MigrateToL2Information'
import { Box } from '@mui/material'
import { isMultisigDetailedExecutionInfo } from '@/utils/transaction-guards'

Expand Down Expand Up @@ -73,7 +73,8 @@ export const MigrationToL2TxData = ({ txDetails }: { txDetails: TransactionDetai

return (
<Box>
<MigrateToL2Information variant="history" />
<MigrateToL2Information variant="history" txData={txDetails.txData} />

{realSafeTxError ? (
<ErrorMessage>{realSafeTxError.message}</ErrorMessage>
) : decodedRealTxError ? (
Expand Down
25 changes: 25 additions & 0 deletions src/components/transactions/TxDetails/TxData/SafeUpdate/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Box, Stack } from '@mui/material'
import type { TransactionData } from '@safe-global/safe-gateway-typescript-sdk'
import DecodedData from '../DecodedData'

function SafeUpdate({ txData }: { txData?: TransactionData }) {
return (
<Stack mr={5} spacing={2}>
<Box
bgcolor="border.background"
p={2}
textAlign="center"
fontWeight={700}
fontSize={18}
borderRadius={1}
width="100%"
>
Safe version update
</Box>

<DecodedData txData={txData} toInfo={txData?.to} />
</Stack>
)
}

export default SafeUpdate
12 changes: 11 additions & 1 deletion src/components/transactions/TxDetails/TxData/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import SettingsChangeTxInfo from '@/components/transactions/TxDetails/TxData/SettingsChange'
import type { SpendingLimitMethods } from '@/utils/transaction-guards'
import { isExecTxData, isOnChainConfirmationTxData, isStakingTxWithdrawInfo } from '@/utils/transaction-guards'
import {
isExecTxData,
isOnChainConfirmationTxData,
isSafeUpdateTxData,
isStakingTxWithdrawInfo,
} from '@/utils/transaction-guards'
import { isStakingTxExitInfo } from '@/utils/transaction-guards'
import {
isCancellationTxInfo,
Expand Down Expand Up @@ -28,6 +33,7 @@ import StakingTxExitDetails from '@/features/stake/components/StakingTxExitDetai
import StakingTxWithdrawDetails from '@/features/stake/components/StakingTxWithdrawDetails'
import { OnChainConfirmation } from './NestedTransaction/OnChainConfirmation'
import { ExecTransaction } from './NestedTransaction/ExecTransaction'
import SafeUpdate from './SafeUpdate'

const TxData = ({
txDetails,
Expand Down Expand Up @@ -87,6 +93,10 @@ const TxData = ({
return <ExecTransaction data={txDetails.txData} />
}

if (isSafeUpdateTxData(txDetails.txData)) {
return <SafeUpdate txData={txDetails.txData} />
}

return <DecodedData txData={txDetails.txData} toInfo={toInfo} />
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/tx-flow/SafeTxProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Errors, logError } from '@/services/exceptions'
import type { EIP712TypedData } from '@safe-global/safe-gateway-typescript-sdk'
import useSafeInfo from '@/hooks/useSafeInfo'
import { useCurrentChain } from '@/hooks/useChains'
import { prependSafeToL2Migration } from '@/utils/transactions'
import { prependSafeToL2Migration } from '@/utils/safe-migrations'
import { useSelectAvailableSigner } from '@/hooks/wallets/useSelectAvailableSigner'

export type SafeTxContextParams = {
Expand Down
42 changes: 6 additions & 36 deletions src/components/tx-flow/flows/UpdateSafe/UpdateSafeReview.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,25 @@
import { useContext } from 'react'
import { Typography } from '@mui/material'

import ExternalLink from '@/components/common/ExternalLink'
import { useCurrentChain } from '@/hooks/useChains'
import useSafeInfo from '@/hooks/useSafeInfo'
import { createUpdateSafeTxs } from '@/services/tx/safeUpdateParams'
import { createMultiSendCallOnlyTx } from '@/services/tx/tx-sender'
import { createMultiSendCallOnlyTx, createTx } from '@/services/tx/tx-sender'
import { SafeTxContext } from '../../SafeTxProvider'
import SignOrExecuteForm from '@/components/tx/SignOrExecuteForm'
import useAsync from '@/hooks/useAsync'
import { getLatestSafeVersion } from '@/utils/chains'

export const UpdateSafeReview = () => {
const { safe, safeLoaded } = useSafeInfo()
const chain = useCurrentChain()
const { setSafeTx, setSafeTxError } = useContext(SafeTxContext)

const latestSafeVersion = getLatestSafeVersion(chain)

useAsync(async () => {
if (!chain || !safeLoaded) {
return
}
if (!chain || !safeLoaded) return

const txs = await createUpdateSafeTxs(safe, chain)
createMultiSendCallOnlyTx(txs).then(setSafeTx).catch(setSafeTxError)
}, [safe, safeLoaded, chain, setSafeTx, setSafeTxError])
const safeTxPromise = txs.length > 1 ? createMultiSendCallOnlyTx(txs) : createTx(txs[0])

return (
<SignOrExecuteForm>
<Typography mb={2}>
Update now to take advantage of new features and the highest security standards available.
</Typography>

<Typography mb={2}>
To check details about updates added by this smart contract version please visit{' '}
<ExternalLink href={`https://github.com/safe-global/safe-contracts/releases/tag/v${latestSafeVersion}`}>
latest Safe Account contracts changelog
</ExternalLink>
</Typography>

<Typography mb={2}>
You will need to confirm this update just like any other transaction. This means other signers will have to
confirm the update in case more than one confirmation is required for this Safe Account.
</Typography>
safeTxPromise.then(setSafeTx).catch(setSafeTxError)
}, [safe, safeLoaded, chain, setSafeTx, setSafeTxError])

<Typography mb={2}>
<b>Warning:</b> this upgrade will invalidate all unexecuted transactions. This means you will be unable to
access or execute them after the upgrade. Please make sure to execute any remaining transactions before
upgrading.
</Typography>
</SignOrExecuteForm>
)
return <SignOrExecuteForm />
}
Loading

0 comments on commit b344122

Please sign in to comment.