Skip to content

fix(web): popup appear when transaction confirmed & other stakewithdr… #1132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ interface IActionButton {
const StakeWithdrawButton: React.FC<IActionButton> = ({
parsedAmount,
action,
setAmount,
isSending,
setIsSending,
setIsPopupOpen,
Expand Down Expand Up @@ -92,23 +91,18 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
};

const { config: setStakeConfig } = usePrepareKlerosCoreSetStake({
enabled: !isUndefined(targetStake) && !isUndefined(id),
enabled: !isUndefined(targetStake) && !isUndefined(id) && isStaking && !isAllowance,
args: [BigInt(id ?? 0), targetStake],
});
const { writeAsync: setStake } = useKlerosCoreSetStake(setStakeConfig);
const handleStake = () => {
if (typeof setStake !== "undefined") {
setIsSending(true);
wrapWithToast(
async () =>
await setStake().then((response) => {
setIsPopupOpen(true);
return response.hash;
}),
publicClient
).finally(() => {
setIsSending(false);
});
wrapWithToast(async () => await setStake().then((response) => response.hash), publicClient)
.then(() => setIsPopupOpen(true))
.finally(() => {
setIsSending(false);
});
}
};

Expand Down Expand Up @@ -136,7 +130,13 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
<Button
text={text}
isLoading={isSending}
disabled={isSending || parsedAmount == 0n || !!isUndefined(targetStake) || checkDisabled()}
disabled={
isSending ||
parsedAmount == 0n ||
!!isUndefined(targetStake) ||
checkDisabled() ||
isUndefined(setStakeConfig.request)
}
onClick={onClick}
/>
</EnsureChain>
Expand Down