Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Fix: gas estimation in 1.1.1 Safes #3985

Merged
merged 2 commits into from
Jun 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const TxModalWrapper = ({
isSubmitDisabled,
isRejectTx = false,
}: Props): React.ReactElement => {
const [manualSafeTxGas, setManualSafeTxGas] = useState<string>('0')
const [manualSafeTxGas, setManualSafeTxGas] = useState<string>()
const [manualGasPrice, setManualGasPrice] = useState<string>()
const [manualMaxPrioFee, setManualMaxPrioFee] = useState<string>()
const [manualGasLimit, setManualGasLimit] = useState<string>()
Expand All @@ -120,6 +120,15 @@ export const TxModalWrapper = ({
const isOffChainSignature = checkIfOffChainSignatureIsPossible(doExecute, isSmartContract, safeVersion)
const approvalAndExecution = isApproveAndExecute(Number(threshold), confirmationsLen, preApprovingOwner)

const { result: safeTxGasEstimation, error: safeTxGasError } = useEstimateSafeTxGas({
isRejectTx,
txData,
txRecipient: txTo || safeAddress,
txAmount: txValue,
operation,
})
if (safeTxGas == null) safeTxGas = safeTxGasEstimation
iamacook marked this conversation as resolved.
Show resolved Hide resolved

const txParameters = useMemo(
() => ({
safeAddress,
Expand All @@ -133,7 +142,7 @@ export const TxModalWrapper = ({
gasPrice: '0',
gasToken: ZERO_ADDRESS,
refundReceiver: ZERO_ADDRESS,
safeTxGas: safeTxGas || manualSafeTxGas || '0',
safeTxGas: manualSafeTxGas || safeTxGas || '0',
approvalAndExecution,
}),
[
Expand Down Expand Up @@ -161,15 +170,6 @@ export const TxModalWrapper = ({
return checkTransactionExecution({ ...txParameters, gasLimit })
}, [gasLimit, txParameters])

const { result: safeTxGasEstimation, error: safeTxGasError } = useEstimateSafeTxGas({
isRejectTx,
txData,
txRecipient: txTo || safeAddress,
txAmount: txValue,
operation,
})
if (safeTxGas == null) safeTxGas = safeTxGasEstimation

const { gasPriceFormatted, gasPrice, gasMaxPrioFee, gasMaxPrioFeeFormatted } = useEstimateTransactionGas({
manualGasPrice,
manualMaxPrioFee,
Expand Down