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 7, 2024
1 parent 932621b commit 13e8065
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/tx/GasParams/GasParams.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('GasParams', () => {
)

expect(getByText('Estimated fee')).toBeInTheDocument()
expect(getByText('0.21 SepoliaETH')).toBeInTheDocument()
expect(getByText('0.42 SepoliaETH')).toBeInTheDocument()
})

it("Doesn't show an estimated fee if there is no gasLimit", () => {
Expand Down
17 changes: 12 additions & 5 deletions src/features/counterfactual/ActivateAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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'
import { removeUndeployedSafe, selectUndeployedSafe } from '@/features/counterfactual/store/undeployedSafeSlice'
import { removeUndeployedSafe, selectUndeployedSafe } from '@/features/counterfactual/store/undeployedSafesSlice'
import useChainId from '@/hooks/useChainId'
import { useCurrentChain } from '@/hooks/useChains'
import useGasPrice, { getTotalFeeFormatted } from '@/hooks/useGasPrice'
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
2 changes: 1 addition & 1 deletion src/features/counterfactual/CounterfactualForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TxModalContext } from '@/components/tx-flow'
import useDeployGasLimit from '@/features/counterfactual/hooks/useDeployGasLimit'
import { removeUndeployedSafe } from '@/features/counterfactual/store/undeployedSafeSlice'
import { removeUndeployedSafe } from '@/features/counterfactual/store/undeployedSafesSlice'
import { deploySafeAndExecuteTx } from '@/features/counterfactual/utils'
import useChainId from '@/hooks/useChainId'
import useSafeInfo from '@/hooks/useSafeInfo'
Expand Down

0 comments on commit 13e8065

Please sign in to comment.