Skip to content

Commit

Permalink
fix: Get gas limit estimations in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Feb 5, 2024
1 parent 95502d8 commit d10c7aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/features/counterfactual/hooks/useDeployGasLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ const useDeployGasLimit = (safeTx?: SafeTransaction) => {

const sdk = await getSafeSDKWithSigner(onboard, chainId)

const gas = await estimateTxBaseGas(sdk, safeTx)
const safeTxGas = await estimateSafeTxGas(sdk, safeTx)
const safeDeploymentGas = await estimateSafeDeploymentGas(sdk)
const [gas, safeTxGas, safeDeploymentGas] = await Promise.all([
estimateTxBaseGas(sdk, safeTx),
estimateSafeTxGas(sdk, safeTx),
estimateSafeDeploymentGas(sdk),
])

return BigInt(gas) + BigInt(safeTxGas) + BigInt(safeDeploymentGas)
}, [onboard, chainId, safeTx])
Expand Down
7 changes: 3 additions & 4 deletions src/features/counterfactual/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,18 @@ export const dispatchTxExecutionAndDeploySafe = async (

let result: ContractTransactionResponse | undefined
try {
const wallet = await assertWalletChain(onboard, chainId)

const signedTx = await sdkUnchecked.signTransaction(safeTx)
const deploymentTx = await sdkUnchecked.wrapSafeTransactionIntoDeploymentBatch(signedTx, txOptions)

const wallet = await assertWalletChain(onboard, chainId)
const provider = createWeb3(wallet.provider)
const signer = await provider.getSigner()

const deploymentTx = await sdkUnchecked.wrapSafeTransactionIntoDeploymentBatch(signedTx, txOptions)

// @ts-ignore TODO: Check if the other type also works
result = await signer.sendTransaction(deploymentTx)
} catch (e) {
// TODO: Dispatch tx event?
console.log(e)
throw e
}

Expand Down

0 comments on commit d10c7aa

Please sign in to comment.