mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-04 23:14:56 +01:00
27 lines
760 B
JavaScript
27 lines
760 B
JavaScript
|
import { useCallback, useState } from 'react';
|
||
|
|
||
|
/**
|
||
|
* Determine whether a transaction can be approved and provide a method to
|
||
|
* kick off the approval process.
|
||
|
*
|
||
|
* Provides a reusable hook that, given a transactionGroup, will manage
|
||
|
* the process of editing gas for approvals
|
||
|
* @param {Object} transactionGroup
|
||
|
* @return {[boolean, Function]}
|
||
|
*/
|
||
|
export function useApproveTransaction() {
|
||
|
const [showCustomizeGasPopover, setShowCustomizeGasPopover] = useState(false);
|
||
|
|
||
|
const closeCustomizeGasPopover = () => setShowCustomizeGasPopover(false);
|
||
|
|
||
|
const approveTransaction = useCallback(() => {
|
||
|
return setShowCustomizeGasPopover(true);
|
||
|
}, []);
|
||
|
|
||
|
return {
|
||
|
approveTransaction,
|
||
|
showCustomizeGasPopover,
|
||
|
closeCustomizeGasPopover,
|
||
|
};
|
||
|
}
|