1- import React , { useMemo , useEffect } from "react" ;
1+ import React , { useMemo } from "react" ;
22
33import { useParams } from "react-router-dom" ;
44import { useAccount , usePublicClient } from "wagmi" ;
@@ -34,7 +34,6 @@ interface IActionButton {
3434 setIsSending : ( arg0 : boolean ) => void ;
3535 setAmount : ( arg0 : string ) => void ;
3636 setIsPopupOpen : ( arg0 : boolean ) => void ;
37- setErrorMsg : ( arg0 : string | undefined ) => void ;
3837}
3938
4039const StakeWithdrawButton : React . FC < IActionButton > = ( {
@@ -43,7 +42,6 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
4342 isSending,
4443 setIsSending,
4544 setIsPopupOpen,
46- setErrorMsg,
4745} ) => {
4846 const { id } = useParams ( ) ;
4947 const { address } = useAccount ( ) ;
@@ -82,7 +80,7 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
8280 return 0n ;
8381 } , [ jurorBalance , parsedAmount , isAllowance , isStaking ] ) ;
8482
85- const { config : increaseAllowanceConfig , error : allowanceError } = usePreparePnkIncreaseAllowance ( {
83+ const { config : increaseAllowanceConfig } = usePreparePnkIncreaseAllowance ( {
8684 enabled : isAllowance && ! isUndefined ( klerosCore ) && ! isUndefined ( targetStake ) && ! isUndefined ( allowance ) ,
8785 args : [ klerosCore ?. address , BigInt ( targetStake ?? 0 ) - BigInt ( allowance ?? 0 ) ] ,
8886 } ) ;
@@ -99,7 +97,7 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
9997 } ;
10098
10199 const { config : setStakeConfig , error : setStakeError } = usePrepareKlerosCoreSetStake ( {
102- enabled : ! isUndefined ( targetStake ) && ! isUndefined ( id ) && ! isAllowance ,
100+ enabled : ! isUndefined ( targetStake ) && ! isUndefined ( id ) && ! isAllowance && parsedAmount !== 0n ,
103101 args : [ BigInt ( id ?? 0 ) , targetStake ] ,
104102 } ) ;
105103 const { writeAsync : setStake } = useKlerosCoreSetStake ( setStakeConfig ) ;
@@ -114,14 +112,6 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
114112 }
115113 } ;
116114
117- useEffect ( ( ) => {
118- if ( isAllowance ) {
119- setErrorMsg ( allowanceError ?. shortMessage ) ;
120- } else {
121- setErrorMsg ( setStakeError ?. shortMessage ) ;
122- }
123- } , [ allowanceError , setStakeError , isAllowance , isStaking , setErrorMsg ] ) ;
124-
125115 const buttonProps = {
126116 [ ActionType . allowance ] : {
127117 text : "Allow PNK" ,
@@ -161,4 +151,4 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
161151 ) ;
162152} ;
163153
164- export default StakeWithdrawButton ;
154+ export default StakeWithdrawButton ;
0 commit comments