You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
46 lines
1.4 KiB
import React from 'react';
|
|
|
|
import { PRIORITY_LEVELS } from '../../../../../shared/constants/gas';
|
|
import { decGWEIToHexWEI } from '../../../../../shared/modules/conversion.utils';
|
|
import { useTransactionModalContext } from '../../../../contexts/transaction-modal';
|
|
import { useGasFeeContext } from '../../../../contexts/gasFee';
|
|
import { useTransactionEventFragment } from '../../../../hooks/useTransactionEventFragment';
|
|
import Button from '../../../ui/button';
|
|
import I18nValue from '../../../ui/i18n-value';
|
|
|
|
import { useAdvancedGasFeePopoverContext } from '../context';
|
|
|
|
const AdvancedGasFeeSaveButton = () => {
|
|
const { closeAllModals } = useTransactionModalContext();
|
|
const { updateTransactionEventFragment } = useTransactionEventFragment();
|
|
const { updateTransaction } = useGasFeeContext();
|
|
const {
|
|
gasLimit,
|
|
hasErrors,
|
|
maxFeePerGas,
|
|
maxPriorityFeePerGas,
|
|
} = useAdvancedGasFeePopoverContext();
|
|
|
|
const onSave = () => {
|
|
updateTransaction({
|
|
estimateUsed: PRIORITY_LEVELS.CUSTOM,
|
|
maxFeePerGas: decGWEIToHexWEI(maxFeePerGas),
|
|
maxPriorityFeePerGas: decGWEIToHexWEI(maxPriorityFeePerGas),
|
|
gasLimit,
|
|
});
|
|
updateTransactionEventFragment({
|
|
properties: {
|
|
gas_edit_type: 'advanced',
|
|
},
|
|
});
|
|
closeAllModals();
|
|
};
|
|
|
|
return (
|
|
<Button type="primary" disabled={hasErrors} onClick={onSave}>
|
|
<I18nValue messageKey="save" />
|
|
</Button>
|
|
);
|
|
};
|
|
|
|
export default AdvancedGasFeeSaveButton;
|
|
|