Skip to content

Commit

Permalink
fix: Wait for relayed deployment before clearing counterfactual state
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Feb 6, 2024
1 parent 8df3a03 commit bc36309
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/features/counterfactual/ActivateAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { createNewSafe, relaySafeCreation } from '@/components/new-safe/create/logic'
import NetworkWarning from '@/components/new-safe/create/NetworkWarning'
import { NetworkFee, SafeSetupOverview } from '@/components/new-safe/create/steps/ReviewStep'
import { SafeCreationStatus } from '@/components/new-safe/create/steps/StatusStep/useSafeCreation'
import ReviewRow from '@/components/new-safe/ReviewRow'
import { TxModalContext } from '@/components/tx-flow'
import TxCard from '@/components/tx-flow/common/TxCard'

import TxLayout from '@/components/tx-flow/common/TxLayout'
import ErrorMessage from '@/components/tx/ErrorMessage'
import { ExecutionMethod, ExecutionMethodSelector } from '@/components/tx/ExecutionMethodSelector'
import useDeployGasLimit from '@/features/counterfactual/hooks/useDeployGasLimit'
Expand All @@ -28,8 +31,6 @@ import type { DeploySafeProps } from '@safe-global/protocol-kit'
import { FEATURES } from '@safe-global/safe-gateway-typescript-sdk'
import React, { useContext, useState } from 'react'

import TxLayout from '@/components/tx-flow/common/TxLayout'

const useActivateAccount = () => {
const chain = useCurrentChain()
const [gasPrice] = useGasPrice()
Expand Down Expand Up @@ -78,6 +79,10 @@ const ActivateAccountFlow = () => {

if (!undeployedSafe) return null

const onSuccess = () => {
dispatch(removeUndeployedSafe({ chainId, address: safeAddress }))
}

const createSafe = async () => {
if (!provider || !chain) return

Expand All @@ -94,16 +99,18 @@ const ActivateAccountFlow = () => {
)

waitForCreateSafeTx(taskId, (status) => {
console.log(status)
if (status === SafeCreationStatus.SUCCESS) {
onSuccess()
}
})
} else {
await createNewSafe(provider, {
safeAccountConfig: undeployedSafe.safeAccountConfig,
saltNonce: undeployedSafe.safeDeploymentConfig?.saltNonce,
options,
})
onSuccess()
}
dispatch(removeUndeployedSafe({ chainId, address: safeAddress }))
} catch (_err) {
const err = asError(_err)
setIsSubmittable(true)
Expand Down

0 comments on commit bc36309

Please sign in to comment.