From 4e9c7874c8ba824950ae1ae5828d648724caffc9 Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Mon, 23 Sep 2024 14:54:45 +0200 Subject: [PATCH 1/2] fix: Pass options for safe creation --- src/components/new-safe/create/logic/index.ts | 5 +++-- .../new-safe/create/steps/ReviewStep/index.tsx | 2 +- src/features/counterfactual/ActivateAccountFlow.tsx | 4 ++-- src/features/counterfactual/utils.ts | 10 ++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/new-safe/create/logic/index.ts b/src/components/new-safe/create/logic/index.ts index 332497b162..19d8249215 100644 --- a/src/components/new-safe/create/logic/index.ts +++ b/src/components/new-safe/create/logic/index.ts @@ -53,15 +53,16 @@ export const createNewSafe = async ( undeployedSafeProps: UndeployedSafeProps, safeVersion: SafeVersion, chain: ChainInfo, + options: DeploySafeProps['options'], callback: (txHash: string) => void, isL1SafeSingleton?: boolean, ): Promise => { const safeFactory = await getSafeFactory(provider, safeVersion, isL1SafeSingleton) if (isPredictedSafeProps(undeployedSafeProps)) { - await safeFactory.deploySafe({ ...undeployedSafeProps, callback }) + await safeFactory.deploySafe({ ...undeployedSafeProps, options, callback }) } else { - const txResponse = await activateReplayedSafe(chain, undeployedSafeProps, createWeb3(provider)) + const txResponse = await activateReplayedSafe(chain, undeployedSafeProps, createWeb3(provider), options) callback(txResponse.hash) } } diff --git a/src/components/new-safe/create/steps/ReviewStep/index.tsx b/src/components/new-safe/create/steps/ReviewStep/index.tsx index e3d87b916e..1802ff4f74 100644 --- a/src/components/new-safe/create/steps/ReviewStep/index.tsx +++ b/src/components/new-safe/create/steps/ReviewStep/index.tsx @@ -139,7 +139,6 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps(false) const [submitError, setSubmitError] = useState() const isCounterfactualEnabled = useHasFeature(FEATURES.COUNTERFACTUAL) - const isMultiChainDeploymentEnabled = useHasFeature(FEATURES.MULTI_CHAIN_SAFE_CREATION) const isEIP1559 = chain && hasFeature(chain, FEATURES.EIP1559) const ownerAddresses = useMemo(() => data.owners.map((owner) => owner.address), [data.owners]) @@ -281,6 +280,7 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps { onSubmitCallback(undefined, txHash) }, diff --git a/src/features/counterfactual/ActivateAccountFlow.tsx b/src/features/counterfactual/ActivateAccountFlow.tsx index 361feda378..34372eeda2 100644 --- a/src/features/counterfactual/ActivateAccountFlow.tsx +++ b/src/features/counterfactual/ActivateAccountFlow.tsx @@ -94,8 +94,7 @@ const ActivateAccountFlow = () => { if (!undeployedSafe || !undeployedSafeSetup) return null - const { owners, threshold } = undeployedSafeSetup - const { saltNonce, safeVersion } = undeployedSafeSetup + const { owners, threshold, safeVersion } = undeployedSafeSetup const onSubmit = (txHash?: string) => { trackEvent({ ...TX_EVENTS.CREATE, label: TX_TYPES.activate_without_tx }) @@ -128,6 +127,7 @@ const ActivateAccountFlow = () => { undeployedSafe.props, safeVersion ?? getLatestSafeVersion(chain), chain, + options, onSubmit, isMultichainSafe ? true : undefined, ) diff --git a/src/features/counterfactual/utils.ts b/src/features/counterfactual/utils.ts index 77a1fff5fa..c02c58d173 100644 --- a/src/features/counterfactual/utils.ts +++ b/src/features/counterfactual/utils.ts @@ -435,10 +435,16 @@ export const extractCounterfactualSafeSetup = ( } } -export const activateReplayedSafe = async (chain: ChainInfo, props: ReplayedSafeProps, provider: BrowserProvider) => { - const data = await encodeSafeCreationTx(props, chain) +export const activateReplayedSafe = async ( + chain: ChainInfo, + props: ReplayedSafeProps, + provider: BrowserProvider, + options: DeploySafeProps['options'], +) => { + const data = encodeSafeCreationTx(props, chain) return (await provider.getSigner()).sendTransaction({ + ...options, to: props.factoryAddress, data, value: '0', From 90c9b7714acb09cd9a88b39268f67ff51d28b871 Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Mon, 23 Sep 2024 15:13:28 +0200 Subject: [PATCH 2/2] fix: Don't spread newSafeProps --- .../new-safe/create/steps/ReviewStep/index.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/new-safe/create/steps/ReviewStep/index.tsx b/src/components/new-safe/create/steps/ReviewStep/index.tsx index 1802ff4f74..58a8f9f9b3 100644 --- a/src/components/new-safe/create/steps/ReviewStep/index.tsx +++ b/src/components/new-safe/create/steps/ReviewStep/index.tsx @@ -165,11 +165,17 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps { + return newSafeProps + ? { + ...newSafeProps, + saltNonce: Date.now().toString(), + } + : undefined + }, [newSafeProps]) + // We estimate with a random nonce as we'll just slightly overestimates like this - const { gasLimit } = useEstimateSafeCreationGas( - newSafeProps ? { ...newSafeProps, saltNonce: Date.now().toString() } : undefined, - data.safeVersion, - ) + const { gasLimit } = useEstimateSafeCreationGas(safePropsForGasEstimation, data.safeVersion) const maxFeePerGas = gasPrice?.maxFeePerGas const maxPriorityFeePerGas = gasPrice?.maxPriorityFeePerGas