diff --git a/src/components/tx-flow/flows/ChangeThreshold/context.tsx b/src/components/tx-flow/flows/ChangeThreshold/context.tsx index 037a1fe6b7..5acdc018cf 100644 --- a/src/components/tx-flow/flows/ChangeThreshold/context.tsx +++ b/src/components/tx-flow/flows/ChangeThreshold/context.tsx @@ -1,5 +1,3 @@ import { createContext } from 'react' -export const ChangeThresholdReviewContext = createContext({ - newThreshold: 0, -}) +export const ChangeThresholdReviewContext = createContext<{ newThreshold?: number }>({}) diff --git a/src/components/tx/confirmation-views/ChangeThreshold/ChangeThreshold.stories.tsx b/src/components/tx/confirmation-views/ChangeThreshold/ChangeThreshold.stories.tsx index 694b4a720c..40b6a280d7 100644 --- a/src/components/tx/confirmation-views/ChangeThreshold/ChangeThreshold.stories.tsx +++ b/src/components/tx/confirmation-views/ChangeThreshold/ChangeThreshold.stories.tsx @@ -30,4 +30,6 @@ const meta = { export default meta type Story = StoryObj -export const Default: Story = {} +export const Default: Story = { + args: {}, +} diff --git a/src/components/tx/confirmation-views/ChangeThreshold/index.tsx b/src/components/tx/confirmation-views/ChangeThreshold/index.tsx index 857c8fb185..3d4c7ca7a3 100644 --- a/src/components/tx/confirmation-views/ChangeThreshold/index.tsx +++ b/src/components/tx/confirmation-views/ChangeThreshold/index.tsx @@ -5,10 +5,17 @@ import commonCss from '@/components/tx-flow/common/styles.module.css' import useSafeInfo from '@/hooks/useSafeInfo' import { ChangeThresholdReviewContext } from '@/components/tx-flow/flows/ChangeThreshold/context' import { ChangeSignerSetupWarning } from '@/features/multichain/components/SignerSetupWarning/ChangeSignerSetupWarning' +import { type TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' +import { isChangeThresholdView } from '../utils' -function ChangeThreshold() { +interface ChangeThresholdProps { + txDetails?: TransactionDetails +} + +function ChangeThreshold({ txDetails }: ChangeThresholdProps) { const { safe } = useSafeInfo() const { newThreshold } = useContext(ChangeThresholdReviewContext) + const threshold = txDetails && isChangeThresholdView(txDetails.txInfo) && txDetails.txInfo.settingsInfo?.threshold return ( <> @@ -20,7 +27,7 @@ function ChangeThreshold() { - {newThreshold} out of {safe.owners.length} signer(s) + {newThreshold || threshold} out of {safe.owners.length} signer(s) diff --git a/src/components/tx/confirmation-views/index.tsx b/src/components/tx/confirmation-views/index.tsx index 759e8dcfc1..fe79c010f4 100644 --- a/src/components/tx/confirmation-views/index.tsx +++ b/src/components/tx/confirmation-views/index.tsx @@ -39,7 +39,7 @@ const getConfirmationViewComponent = ({ txInfo, txFlow, }: NarrowConfirmationViewProps & { txFlow?: JSX.Element }) => { - if (isChangeThresholdView(txInfo)) return + if (isChangeThresholdView(txInfo)) return if (isConfirmBatchView(txFlow)) return diff --git a/src/components/tx/confirmation-views/utils.ts b/src/components/tx/confirmation-views/utils.ts index 5329b31aa2..4e7e395221 100644 --- a/src/components/tx/confirmation-views/utils.ts +++ b/src/components/tx/confirmation-views/utils.ts @@ -1,4 +1,4 @@ -import type { TransactionInfo } from '@safe-global/safe-gateway-typescript-sdk' +import type { ChangeThreshold, SettingsChange, TransactionInfo } from '@safe-global/safe-gateway-typescript-sdk' import { SettingsInfoType, TransactionInfoType } from '@safe-global/safe-gateway-typescript-sdk' import { ConfirmBatchFlow } from '@/components/tx-flow/flows' @@ -6,5 +6,7 @@ export const isSettingsChangeView = (txInfo: TransactionInfo) => txInfo.type === export const isConfirmBatchView = (txFlow?: JSX.Element) => txFlow?.type === ConfirmBatchFlow -export const isChangeThresholdView = (txInfo: TransactionInfo) => +export const isChangeThresholdView = ( + txInfo: TransactionInfo, +): txInfo is SettingsChange & { settingsInfo: ChangeThreshold } => txInfo.type === TransactionInfoType.SETTINGS_CHANGE && txInfo.settingsInfo?.type === SettingsInfoType.CHANGE_THRESHOLD