2021-11-10 03:07:10 +01:00
|
|
|
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,
|
2021-11-18 20:08:29 +01:00
|
|
|
transaction: PropTypes.object,
|
2021-11-10 03:07:10 +01:00
|
|
|
minimumGasLimit: PropTypes.string,
|
|
|
|
editGasMode: PropTypes.string,
|
|
|
|
};
|