Skip to content

Commit

Permalink
fix(threshold-info): use isChangeThresholdView guard
Browse files Browse the repository at this point in the history
  • Loading branch information
clovisdasilvaneto committed Nov 4, 2024
1 parent 7b669d4 commit 98af511
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/components/tx/confirmation-views/ChangeThreshold/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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 { SettingsInfoType, type TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk'
import { isSettingsChangeTxInfo } from '@/utils/transaction-guards'
import { type TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk'
import { isChangeThresholdView } from '../utils'

interface ChangeThresholdProps {
txDetails?: TransactionDetails
Expand All @@ -15,11 +15,7 @@ interface ChangeThresholdProps {
function ChangeThreshold({ txDetails }: ChangeThresholdProps) {
const { safe } = useSafeInfo()
const { newThreshold } = useContext(ChangeThresholdReviewContext)
const threshold =
txDetails &&
isSettingsChangeTxInfo(txDetails.txInfo) &&
txDetails.txInfo.settingsInfo?.type === SettingsInfoType.CHANGE_THRESHOLD &&
txDetails.txInfo.settingsInfo.threshold
const threshold = txDetails && isChangeThresholdView(txDetails.txInfo) && txDetails.txInfo.settingsInfo?.threshold

return (
<>
Expand Down
6 changes: 4 additions & 2 deletions src/components/tx/confirmation-views/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
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'

export const isSettingsChangeView = (txInfo: TransactionInfo) => txInfo.type === TransactionInfoType.SETTINGS_CHANGE

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

0 comments on commit 98af511

Please sign in to comment.