StakeCooldownActions.tsx
1 import { ProtocolAction } from '@aave/contract-helpers'; 2 import { Trans } from '@lingui/macro'; 3 import { BoxProps } from '@mui/material'; 4 import { useRootStore } from 'src/store/root'; 5 6 import { useTransactionHandler } from '../../../helpers/useTransactionHandler'; 7 import { TxActionsWrapper } from '../TxActionsWrapper'; 8 9 export interface StakeCooldownActionsProps extends BoxProps { 10 isWrongNetwork: boolean; 11 customGasPrice?: string; 12 blocked: boolean; 13 selectedToken: string; 14 amountToCooldown: string; 15 } 16 17 export const StakeCooldownActions = ({ 18 isWrongNetwork, 19 sx, 20 blocked, 21 selectedToken, 22 amountToCooldown, 23 ...props 24 }: StakeCooldownActionsProps) => { 25 const cooldown = useRootStore((state) => state.cooldown); 26 27 const { action, loadingTxns, mainTxState, requiresApproval } = useTransactionHandler({ 28 tryPermit: false, 29 handleGetTxns: async () => { 30 return cooldown(selectedToken); 31 }, 32 skip: blocked, 33 deps: [], 34 protocolAction: ProtocolAction.stakeCooldown, 35 eventTxInfo: { 36 amount: amountToCooldown, 37 assetName: selectedToken, 38 }, 39 }); 40 41 return ( 42 <TxActionsWrapper 43 requiresApproval={requiresApproval} 44 blocked={blocked} 45 preparingTransactions={loadingTxns} 46 handleAction={action} 47 actionText={<Trans>Activate Cooldown</Trans>} 48 actionInProgressText={<Trans>Activate Cooldown</Trans>} 49 mainTxState={mainTxState} 50 isWrongNetwork={isWrongNetwork} 51 sx={sx} 52 {...props} 53 /> 54 ); 55 };