1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 12:56:01 +01:00
metamask-extension/ui/components/app/advanced-gas-fee-popover/context/advancedGasFeePopover.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

import React, { createContext, useContext, useState } from 'react';
import PropTypes from 'prop-types';
export const AdvancedGasFeePopoverContext = createContext({});
export const AdvancedGasFeePopoverContextProvider = ({ children }) => {
const [gasLimit, setGasLimit] = useState();
const [maxFeePerGas, setMaxFeePerGas] = useState();
const [maxPriorityFeePerGas, setMaxPriorityFeePerGas] = useState();
const [isDirty, setDirty] = useState();
const [hasError, setHasError] = useState(false);
return (
<AdvancedGasFeePopoverContext.Provider
value={{
gasLimit,
hasError,
isDirty,
maxFeePerGas,
maxPriorityFeePerGas,
setDirty,
setGasLimit,
setHasError,
setMaxPriorityFeePerGas,
setMaxFeePerGas,
}}
>
{children}
</AdvancedGasFeePopoverContext.Provider>
);
};
export function useAdvancedGasFeePopoverContext() {
return useContext(AdvancedGasFeePopoverContext);
}
AdvancedGasFeePopoverContextProvider.propTypes = {
children: PropTypes.node.isRequired,
};