Skip to content

Commit

Permalink
fix: Redirect user to dashboard after safe creation
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Sep 25, 2024
1 parent 3ff63d4 commit 3404907
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/components/new-safe/create/steps/ReviewStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps<NewSafe
gtmSetSafeAddress(safeAddress)

trackEvent({ ...OVERVIEW_EVENTS.PROCEED_WITH_TX, label: 'counterfactual', category: CREATE_SAFE_CATEGORY })
replayCounterfactualSafeDeployment(chain.chainId, safeAddress, props, data.name, dispatch)
replayCounterfactualSafeDeployment(chain.chainId, safeAddress, props, data.name, dispatch, payMethod)
trackEvent({ ...CREATE_SAFE_EVENTS.CREATED_SAFE, label: 'counterfactual' })
return
}
Expand All @@ -261,7 +261,7 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps<NewSafe

const onSubmitCallback = async (taskId?: string, txHash?: string) => {
// Create a counterfactual Safe
replayCounterfactualSafeDeployment(chain.chainId, safeAddress, props, data.name, dispatch)
replayCounterfactualSafeDeployment(chain.chainId, safeAddress, props, data.name, dispatch, payMethod)

if (taskId) {
safeCreationDispatch(SafeCreationEvent.RELAYING, { groupKey: CF_TX_GROUP_KEY, taskId, safeAddress })
Expand Down
7 changes: 4 additions & 3 deletions src/features/counterfactual/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getLatestSafeVersion } from '@/utils/chains'
import { POLLING_INTERVAL } from '@/config/constants'
import { PayMethod } from '@/features/counterfactual/PayNowPayLater'
import type { PayMethod } from '@/features/counterfactual/PayNowPayLater'
import { safeCreationDispatch, SafeCreationEvent } from '@/features/counterfactual/services/safeCreationEvents'
import {
addUndeployedSafe,
Expand Down Expand Up @@ -151,11 +151,12 @@ export const replayCounterfactualSafeDeployment = (
replayedSafeProps: ReplayedSafeProps,
name: string,
dispatch: AppDispatch,
payMethod: PayMethod,
) => {
const undeployedSafe = {
chainId,
address: safeAddress,
type: PayMethod.PayLater,
type: payMethod,
safeProps: replayedSafeProps,
}

Expand All @@ -164,7 +165,7 @@ export const replayCounterfactualSafeDeployment = (
props: replayedSafeProps,
status: {
status: PendingSafeStatus.AWAITING_EXECUTION,
type: PayMethod.PayLater,
type: payMethod,
},
},
chainId,
Expand Down
20 changes: 11 additions & 9 deletions src/features/multichain/components/CreateSafeOnNewChain/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import ChainIndicator from '@/components/common/ChainIndicator'
import ExternalLink from '@/components/common/ExternalLink'
import ModalDialog from '@/components/common/ModalDialog'
import NetworkInput from '@/components/common/NetworkInput'
import ErrorMessage from '@/components/tx/ErrorMessage'
import { OVERVIEW_EVENTS, trackEvent } from '@/services/analytics'
import { Box, Button, CircularProgress, DialogActions, DialogContent, Stack, Typography } from '@mui/material'
import { FormProvider, useForm } from 'react-hook-form'
import { useSafeCreationData } from '../../hooks/useSafeCreationData'
import { predictAddressBasedOnReplayData } from '@/components/welcome/MyAccounts/utils/multiChainSafe'
import { PayMethod } from '@/features/counterfactual/PayNowPayLater'
import { replayCounterfactualSafeDeployment } from '@/features/counterfactual/utils'

import useChains from '@/hooks/useChains'
import { createWeb3ReadOnly } from '@/hooks/wallets/web3'
import { OVERVIEW_EVENTS, trackEvent } from '@/services/analytics'
import { useAppDispatch, useAppSelector } from '@/store'
import { selectRpc } from '@/store/settingsSlice'
import { createWeb3ReadOnly } from '@/hooks/wallets/web3'
import { predictAddressBasedOnReplayData } from '@/components/welcome/MyAccounts/utils/multiChainSafe'
import { sameAddress } from '@/utils/addresses'
import ExternalLink from '@/components/common/ExternalLink'
import { useRouter } from 'next/router'
import ChainIndicator from '@/components/common/ChainIndicator'
import { Box, Button, CircularProgress, DialogActions, DialogContent, Stack, Typography } from '@mui/material'
import { type ChainInfo } from '@safe-global/safe-gateway-typescript-sdk'
import { useRouter } from 'next/router'
import { useMemo, useState } from 'react'
import { FormProvider, useForm } from 'react-hook-form'
import { useCompatibleNetworks } from '../../hooks/useCompatibleNetworks'
import { useSafeCreationData } from '../../hooks/useSafeCreationData'

type CreateSafeOnNewChainForm = {
chainId: string
Expand Down Expand Up @@ -99,6 +100,7 @@ const ReplaySafeDialog = ({
safeCreationData,
currentName || '',
dispatch,
PayMethod.PayLater,
)

router.push({
Expand Down

0 comments on commit 3404907

Please sign in to comment.