1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 11:46:13 +02:00
metamask-extension/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-save/advanced-gas-fee-save.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { PRIORITY_LEVELS } from '../../../../../shared/constants/gas';
import { useTransactionModalContext } from '../../../../contexts/transaction-modal';
import { useGasFeeContext } from '../../../../contexts/gasFee';
import Button from '../../../ui/button';
import I18nValue from '../../../ui/i18n-value';
import { useAdvancedGasFeePopoverContext } from '../context';
import { decGWEIToHexWEI } from '../../../../../shared/modules/conversion.utils';
const AdvancedGasFeeSaveButton = () => {
2022-01-06 23:40:31 +01:00
const { closeAllModals } = useTransactionModalContext();
const { updateTransaction } = useGasFeeContext();
const {
gasLimit,
hasErrors,
maxFeePerGas,
maxPriorityFeePerGas,
} = useAdvancedGasFeePopoverContext();
const onSave = () => {
updateTransaction({
estimateUsed: PRIORITY_LEVELS.CUSTOM,
maxFeePerGas: decGWEIToHexWEI(maxFeePerGas),
maxPriorityFeePerGas: decGWEIToHexWEI(maxPriorityFeePerGas),
gasLimit,
});
2022-01-06 23:40:31 +01:00
closeAllModals();
};
return (
<Button type="primary" disabled={hasErrors} onClick={onSave}>
<I18nValue messageKey="save" />
</Button>
);
};
export default AdvancedGasFeeSaveButton;