1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 11:01:41 +01:00
metamask-extension/ui/contexts/gasFee.js
2021-11-19 00:38:29 +05:30

38 lines
893 B
JavaScript

import React, { createContext, useContext } from 'react';
import PropTypes from 'prop-types';
import { useGasFeeInputs } from '../hooks/gasFeeInput/useGasFeeInputs';
export const GasFeeContext = createContext({});
export const GasFeeContextProvider = ({
children,
defaultEstimateToUse,
transaction,
minimumGasLimit,
editGasMode,
}) => {
const gasFeeDetails = useGasFeeInputs(
defaultEstimateToUse,
transaction,
minimumGasLimit,
editGasMode,
);
return (
<GasFeeContext.Provider value={gasFeeDetails}>
{children}
</GasFeeContext.Provider>
);
};
export function useGasFeeContext() {
return useContext(GasFeeContext);
}
GasFeeContextProvider.propTypes = {
children: PropTypes.node.isRequired,
defaultEstimateToUse: PropTypes.string,
transaction: PropTypes.object,
minimumGasLimit: PropTypes.string,
editGasMode: PropTypes.string,
};