mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Ensure gas fees update in popover on poll for new values (#11760)
This commit is contained in:
parent
0dcdbdd99e
commit
b9d5c431c1
@ -206,41 +206,51 @@ export function useGasFeeInputs(
|
|||||||
estimatedGasFeeTimeBounds,
|
estimatedGasFeeTimeBounds,
|
||||||
} = useGasFeeEstimates();
|
} = useGasFeeEstimates();
|
||||||
|
|
||||||
|
const [initialMaxFeePerGas] = useState(
|
||||||
|
Number(hexWEIToDecGWEI(transaction?.txParams?.maxFeePerGas)),
|
||||||
|
);
|
||||||
|
const [initialMaxPriorityFeePerGas] = useState(
|
||||||
|
Number(hexWEIToDecGWEI(transaction?.txParams?.maxPriorityFeePerGas)),
|
||||||
|
);
|
||||||
|
const [initialGasPrice] = useState(
|
||||||
|
Number(hexWEIToDecGWEI(transaction?.txParams?.gasPrice)),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [initialMatchingEstimateLevel] = useState(
|
||||||
|
getMatchingEstimateFromGasFees(
|
||||||
|
gasFeeEstimates,
|
||||||
|
initialMaxFeePerGas,
|
||||||
|
initialMaxPriorityFeePerGas,
|
||||||
|
initialGasPrice,
|
||||||
|
networkAndAccountSupports1559,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
// This hook keeps track of a few pieces of transitional state. It is
|
// This hook keeps track of a few pieces of transitional state. It is
|
||||||
// transitional because it is only used to modify a transaction in the
|
// transitional because it is only used to modify a transaction in the
|
||||||
// metamask (background) state tree.
|
// metamask (background) state tree.
|
||||||
const [maxFeePerGas, setMaxFeePerGas] = useState(
|
const [maxFeePerGas, setMaxFeePerGas] = useState(
|
||||||
transaction?.txParams?.maxFeePerGas
|
initialMaxFeePerGas && !initialMatchingEstimateLevel
|
||||||
? Number(hexWEIToDecGWEI(transaction.txParams.maxFeePerGas))
|
? initialMaxFeePerGas
|
||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
const [maxPriorityFeePerGas, setMaxPriorityFeePerGas] = useState(
|
const [maxPriorityFeePerGas, setMaxPriorityFeePerGas] = useState(
|
||||||
transaction?.txParams?.maxPriorityFeePerGas
|
initialMaxPriorityFeePerGas && !initialMatchingEstimateLevel
|
||||||
? Number(hexWEIToDecGWEI(transaction.txParams.maxPriorityFeePerGas))
|
? initialMaxPriorityFeePerGas
|
||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
const [gasPriceHasBeenManuallySet, setGasPriceHasBeenManuallySet] = useState(
|
const [gasPriceHasBeenManuallySet, setGasPriceHasBeenManuallySet] = useState(
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
const [gasPrice, setGasPrice] = useState(
|
const [gasPrice, setGasPrice] = useState(
|
||||||
transaction?.txParams?.gasPrice
|
initialGasPrice && !initialMatchingEstimateLevel ? initialGasPrice : null,
|
||||||
? Number(hexWEIToDecGWEI(transaction.txParams.gasPrice))
|
|
||||||
: null,
|
|
||||||
);
|
);
|
||||||
const [gasLimit, setGasLimit] = useState(
|
const [gasLimit, setGasLimit] = useState(
|
||||||
Number(hexToDecimal(transaction?.txParams?.gas ?? minimumGasLimit)),
|
Number(hexToDecimal(transaction?.txParams?.gas ?? minimumGasLimit)),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [estimateToUse, setInternalEstimateToUse] = useState(
|
const [estimateToUse, setInternalEstimateToUse] = useState(
|
||||||
transaction
|
transaction ? initialMatchingEstimateLevel : defaultEstimateToUse,
|
||||||
? getMatchingEstimateFromGasFees(
|
|
||||||
gasFeeEstimates,
|
|
||||||
maxFeePerGas,
|
|
||||||
maxPriorityFeePerGas,
|
|
||||||
gasPrice,
|
|
||||||
networkAndAccountSupports1559,
|
|
||||||
)
|
|
||||||
: defaultEstimateToUse,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// We specify whether to use the estimate value by checking if the state
|
// We specify whether to use the estimate value by checking if the state
|
||||||
|
Loading…
Reference in New Issue
Block a user