Skip to content

Commit

Permalink
fix: Add counterfactual check to widget
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Feb 8, 2024
1 parent c6cccc1 commit b86b66c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/components/dashboard/FirstSteps/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { TxModalContext } from '@/components/tx-flow'
import { ActivateAccountFlow } from '@/features/counterfactual/ActivateAccount'
import useBalances from '@/hooks/useBalances'
import useSafeInfo from '@/hooks/useSafeInfo'
import { useAppSelector } from '@/store'
import { selectOutgoingTransactions } from '@/store/txHistorySlice'
import { useMemo } from 'react'
import React, { useContext, useMemo } from 'react'
import { Card, WidgetBody, WidgetContainer } from '@/components/dashboard/styled'
import { Button, CircularProgress, Grid, Link, Typography } from '@mui/material'
import CircleOutlinedIcon from '@mui/icons-material/CircleOutlined'
Expand Down Expand Up @@ -69,7 +72,9 @@ const FirstStepsContent: StatusProgressItems = [

const FirstSteps = () => {
const { balances } = useBalances()
const { safe } = useSafeInfo()
const outgoingTransactions = useAppSelector(selectOutgoingTransactions)
const { setTxFlow } = useContext(TxModalContext)

const hasNonZeroBalance = balances && (balances.items.length > 1 || BigInt(balances.items[0]?.balance || 0) > 0)
const hasOutgoingTransactions = !!outgoingTransactions && outgoingTransactions.length > 0
Expand All @@ -83,14 +88,13 @@ const FirstSteps = () => {
)

const activateAccount = () => {
// TODO: Open safe deployment flow
setTxFlow(<ActivateAccountFlow />)
}

const progress = calculateProgress(items)
const stepsCompleted = items.filter((item) => item.completed).length
const isCounterfactual = false // TODO: Add real check here

if (!isCounterfactual) return null
if (safe.deployed) return null

return (
<WidgetContainer>
Expand Down
2 changes: 1 addition & 1 deletion src/features/counterfactual/ActivateAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const useActivateAccount = () => {
return { options, totalFee, walletCanPay }
}

const ActivateAccountFlow = () => {
export const ActivateAccountFlow = () => {
const [isSubmittable, setIsSubmittable] = useState<boolean>(true)
const [submitError, setSubmitError] = useState<Error | undefined>()
const [executionMethod, setExecutionMethod] = useState(ExecutionMethod.RELAY)
Expand Down

0 comments on commit b86b66c

Please sign in to comment.