Skip to content

Commit

Permalink
fix: gasFeeEstimates property undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistevam committed Dec 18, 2024
1 parent edd7b25 commit 0c8d002
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ui/pages/confirmations/hooks/useTransactionFunction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,16 @@ describe('useMaxPriorityFeePerGasInput', () => {
userFeeLevel: 'dappSuggested',
});
});

it('returns early when gasFeeEstimates is undefined', () => {
const mockUpdateTransaction = jest
.spyOn(Actions, 'updateTransactionGasFees')
.mockImplementation(() => ({ type: '' }));

const { result } = renderUseTransactionFunctions({
gasFeeEstimates: undefined,
});
result.current.updateTransactionUsingEstimate(GasRecommendations.low);
expect(mockUpdateTransaction).not.toHaveBeenCalled();
});
});
5 changes: 5 additions & 0 deletions ui/pages/confirmations/hooks/useTransactionFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,14 @@ export const useTransactionFunctions = ({

const updateTransactionUsingEstimate = useCallback(
(gasFeeEstimateToUse) => {
if (!gasFeeEstimates) {
return;
}

if (!gasFeeEstimates[gasFeeEstimateToUse]) {
return;
}

const { suggestedMaxFeePerGas, suggestedMaxPriorityFeePerGas } =
gasFeeEstimates[gasFeeEstimateToUse];
updateTransaction({
Expand Down

0 comments on commit 0c8d002

Please sign in to comment.