From a7f4147c1b167541a58fe33009da6679c905bc91 Mon Sep 17 00:00:00 2001 From: James Mealy Date: Wed, 18 Sep 2024 14:19:09 +0200 Subject: [PATCH 1/2] feat: show signer setup warning for swapping signer or changing threshold. --- src/components/tx/ErrorMessage/index.tsx | 2 +- src/components/tx/ErrorMessage/styles.module.css | 1 - src/components/tx/security/blockaid/index.tsx | 4 +--- .../ChangeOwnerSetupWarning/ChangeOwnerSetupWarning.tsx | 2 +- src/features/multichain/helpers/utils.ts | 5 ++++- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/tx/ErrorMessage/index.tsx b/src/components/tx/ErrorMessage/index.tsx index 924e944737..703b33d18e 100644 --- a/src/components/tx/ErrorMessage/index.tsx +++ b/src/components/tx/ErrorMessage/index.tsx @@ -31,7 +31,7 @@ const ErrorMessage = ({ `${palette[level].main} !important` }} /> diff --git a/src/components/tx/ErrorMessage/styles.module.css b/src/components/tx/ErrorMessage/styles.module.css index 1fda0fddc0..242085d84f 100644 --- a/src/components/tx/ErrorMessage/styles.module.css +++ b/src/components/tx/ErrorMessage/styles.module.css @@ -11,7 +11,6 @@ .container.warning { background-color: var(--color-warning-background); - color: var(--color-warning-dark); } .container.info { diff --git a/src/components/tx/security/blockaid/index.tsx b/src/components/tx/security/blockaid/index.tsx index f1c18f9736..7070f91edb 100644 --- a/src/components/tx/security/blockaid/index.tsx +++ b/src/components/tx/security/blockaid/index.tsx @@ -14,7 +14,6 @@ import BlockaidIcon from '@/public/images/transactions/blockaid-icon.svg' import { SafeTxContext } from '@/components/tx-flow/SafeTxProvider' import { type SecurityWarningProps, mapSecuritySeverity } from '../utils' import { BlockaidHint } from './BlockaidHint' -import Warning from '@/public/images/notifications/alert.svg' import { SecuritySeverity } from '@/services/security/modules/types' export const REASON_MAPPING: Record = { @@ -65,7 +64,6 @@ const BlockaidResultWarning = ({ <> } className={css.customAlert} sx={ needsRiskConfirmation @@ -136,7 +134,7 @@ const ResultDescription = ({ const BlockaidError = () => { return ( - } className={css.customAlert}> + Proceed with caution diff --git a/src/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning.tsx b/src/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning.tsx index 1708a07e5b..1ef5eb753b 100644 --- a/src/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning.tsx +++ b/src/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning.tsx @@ -12,7 +12,7 @@ export const ChangeSignerSetupWarning = () => { return ( - {`Signers are not consistent across networks on this account. Changing signers will only affect the account on ${currentChain}`} + {`Signers are not consistent across networks on this account. Changing signers will only affect the account on ${currentChain?.chainName}`} ) diff --git a/src/features/multichain/helpers/utils.ts b/src/features/multichain/helpers/utils.ts index 6c55de8282..bdbe7558d8 100644 --- a/src/features/multichain/helpers/utils.ts +++ b/src/features/multichain/helpers/utils.ts @@ -1,5 +1,8 @@ import type { DecodedDataResponse } from '@safe-global/safe-gateway-typescript-sdk' export const isChangingSignerSetup = (decodedData: DecodedDataResponse | undefined) => { - return decodedData?.method === 'addOwnerWithThreshold' || decodedData?.method === 'removeOwner' + return ( + decodedData?.method && + ['swapOwner', 'addOwnerWithThreshold', 'removeOwner', 'changeThreshold'].includes(decodedData?.method) + ) } From 0e786fad7060d1432600671f7a198ebc48724264 Mon Sep 17 00:00:00 2001 From: James Mealy Date: Fri, 20 Sep 2024 14:23:02 +0200 Subject: [PATCH 2/2] feat: move the change signer warning to the relavent block in the confirmation scree --- src/components/tx-flow/flows/AddOwner/ReviewOwner.tsx | 3 +++ .../flows/ChangeThreshold/ReviewChangeThreshold.tsx | 3 +++ .../tx-flow/flows/RemoveOwner/ReviewRemoveOwner.tsx | 3 +++ src/components/tx/SignOrExecuteForm/index.tsx | 7 ------- .../ChangeOwnerSetupWarning.tsx | 11 ++++------- src/features/multichain/helpers/utils.ts | 8 -------- 6 files changed, 13 insertions(+), 22 deletions(-) delete mode 100644 src/features/multichain/helpers/utils.ts diff --git a/src/components/tx-flow/flows/AddOwner/ReviewOwner.tsx b/src/components/tx-flow/flows/AddOwner/ReviewOwner.tsx index e2913389c5..7e9f0fc476 100644 --- a/src/components/tx-flow/flows/AddOwner/ReviewOwner.tsx +++ b/src/components/tx-flow/flows/AddOwner/ReviewOwner.tsx @@ -15,6 +15,7 @@ import { OwnerList } from '../../common/OwnerList' import MinusIcon from '@/public/images/common/minus.svg' import EthHashInfo from '@/components/common/EthHashInfo' import commonCss from '@/components/tx-flow/common/styles.module.css' +import { ChangeSignerSetupWarning } from '@/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning' export const ReviewOwner = ({ params }: { params: AddOwnerFlowProps | ReplaceOwnerFlowProps }) => { const dispatch = useAppDispatch() @@ -73,6 +74,8 @@ export const ReviewOwner = ({ params }: { params: AddOwnerFlowProps | ReplaceOwn )} + + Any transaction requires the confirmation of: diff --git a/src/components/tx-flow/flows/ChangeThreshold/ReviewChangeThreshold.tsx b/src/components/tx-flow/flows/ChangeThreshold/ReviewChangeThreshold.tsx index 78d8958f5f..adfbd435d6 100644 --- a/src/components/tx-flow/flows/ChangeThreshold/ReviewChangeThreshold.tsx +++ b/src/components/tx-flow/flows/ChangeThreshold/ReviewChangeThreshold.tsx @@ -10,6 +10,7 @@ import { ChangeThresholdFlowFieldNames } from '@/components/tx-flow/flows/Change import type { ChangeThresholdFlowProps } from '@/components/tx-flow/flows/ChangeThreshold' import commonCss from '@/components/tx-flow/common/styles.module.css' +import { ChangeSignerSetupWarning } from '@/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning' const ReviewChangeThreshold = ({ params }: { params: ChangeThresholdFlowProps }) => { const { safe } = useSafeInfo() @@ -28,6 +29,8 @@ const ReviewChangeThreshold = ({ params }: { params: ChangeThresholdFlowProps }) return ( + +
Any transaction will require the confirmation of: diff --git a/src/components/tx-flow/flows/RemoveOwner/ReviewRemoveOwner.tsx b/src/components/tx-flow/flows/RemoveOwner/ReviewRemoveOwner.tsx index 8477fb570d..1caf59dde8 100644 --- a/src/components/tx-flow/flows/RemoveOwner/ReviewRemoveOwner.tsx +++ b/src/components/tx-flow/flows/RemoveOwner/ReviewRemoveOwner.tsx @@ -13,6 +13,7 @@ import type { RemoveOwnerFlowProps } from '.' import EthHashInfo from '@/components/common/EthHashInfo' import commonCss from '@/components/tx-flow/common/styles.module.css' +import { ChangeSignerSetupWarning } from '@/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning' export const ReviewRemoveOwner = ({ params }: { params: RemoveOwnerFlowProps }): ReactElement => { const addressBook = useAddressBook() @@ -46,6 +47,8 @@ export const ReviewRemoveOwner = ({ params }: { params: RemoveOwnerFlowProps }): hasExplorer /> + + diff --git a/src/components/tx/SignOrExecuteForm/index.tsx b/src/components/tx/SignOrExecuteForm/index.tsx index ed5df1e7df..1c2a0b4a53 100644 --- a/src/components/tx/SignOrExecuteForm/index.tsx +++ b/src/components/tx/SignOrExecuteForm/index.tsx @@ -27,7 +27,6 @@ import { trackEvent } from '@/services/analytics' import useChainId from '@/hooks/useChainId' import ExecuteThroughRoleForm from './ExecuteThroughRoleForm' import { findAllowingRole, findMostLikelyRole, useRoles } from './ExecuteThroughRoleForm/hooks' -import { isSettingTwapFallbackHandler } from '@/features/swap/helpers/utils' import { isCustomTxInfo, isGenericConfirmation, isMigrateToL2MultiSend } from '@/utils/transaction-guards' import useIsSafeOwner from '@/hooks/useIsSafeOwner' import { BlockaidBalanceChanges } from '../security/blockaid/BlockaidBalanceChange' @@ -42,8 +41,6 @@ import { extractMigrationL2MasterCopyAddress } from '@/utils/transactions' import type { TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' import { useGetTransactionDetailsQuery, useLazyGetTransactionDetailsQuery } from '@/store/gateway' import { skipToken } from '@reduxjs/toolkit/query/react' -import { ChangeSignerSetupWarning } from '@/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning' -import { isChangingSignerSetup } from '@/features/multichain/helpers/utils' import NetworkWarning from '@/components/new-safe/create/NetworkWarning' export type SubmitCallback = (txId: string, isExecuted?: boolean) => void @@ -118,8 +115,6 @@ export const SignOrExecuteForm = ({ const { safe } = useSafeInfo() const isSafeOwner = useIsSafeOwner() const isCounterfactualSafe = !safe.deployed - const isChangingFallbackHandler = isSettingTwapFallbackHandler(decodedData) - const isChangingSigners = isChangingSignerSetup(decodedData) const isMultiChainMigration = isMigrateToL2MultiSend(decodedData) const multiChainMigrationTarget = extractMigrationL2MasterCopyAddress(decodedData) @@ -207,8 +202,6 @@ export const SignOrExecuteForm = ({ - {isChangingSigners && } - {!isMultiChainMigration && } diff --git a/src/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning.tsx b/src/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning.tsx index 1ef5eb753b..70b3a809b2 100644 --- a/src/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning.tsx +++ b/src/features/multichain/components/ChangeOwnerSetupWarning/ChangeOwnerSetupWarning.tsx @@ -1,6 +1,5 @@ -import { Box } from '@mui/material' +import { Alert } from '@mui/material' import { useIsMultichainSafe } from '../../hooks/useIsMultichainSafe' -import ErrorMessage from '@/components/tx/ErrorMessage' import { useCurrentChain } from '@/hooks/useChains' export const ChangeSignerSetupWarning = () => { @@ -10,10 +9,8 @@ export const ChangeSignerSetupWarning = () => { if (!isMultichainSafe) return return ( - - - {`Signers are not consistent across networks on this account. Changing signers will only affect the account on ${currentChain?.chainName}`} - - + + {`Signers are not consistent across networks on this account. Changing signers will only affect the account on ${currentChain?.chainName}`} + ) } diff --git a/src/features/multichain/helpers/utils.ts b/src/features/multichain/helpers/utils.ts deleted file mode 100644 index bdbe7558d8..0000000000 --- a/src/features/multichain/helpers/utils.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { DecodedDataResponse } from '@safe-global/safe-gateway-typescript-sdk' - -export const isChangingSignerSetup = (decodedData: DecodedDataResponse | undefined) => { - return ( - decodedData?.method && - ['swapOwner', 'addOwnerWithThreshold', 'removeOwner', 'changeThreshold'].includes(decodedData?.method) - ) -}