Skip to content

Commit e14322e

Browse files
committed
fix(web): return hash correctly on all functions
1 parent 09301b2 commit e14322e

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

web/src/pages/Cases/CaseDetails/Appeal/Classic/Fund.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const Fund: React.FC = () => {
7979
onClick={() => {
8080
if (fundAppeal) {
8181
setIsSending(true);
82-
wrapWithToast(fundAppeal, publicClient)
82+
wrapWithToast(async () => await fundAppeal().then((response) => response.hash), publicClient)
8383
.then(() => {
8484
setAmount("");
8585
close();

web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({ parsedAmount, action, se
4040
});
4141
const { data: jurorBalance } = useKlerosCoreGetJurorBalance({
4242
enabled: !isUndefined(address),
43-
args: [address, id],
43+
args: [address ?? "0x", BigInt(id ?? 0)],
4444
watch: true,
4545
});
4646
const { data: allowance } = usePNKAllowance(address);
@@ -59,20 +59,23 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({ parsedAmount, action, se
5959
return jurorBalance[0] - parsedAmount;
6060
}
6161
}
62-
}, [action, jurorBalance, parsedAmount]);
62+
return 0n;
63+
}, [jurorBalance, parsedAmount, isAllowance, isStaking]);
6364

6465
const klerosCore = getKlerosCore({});
6566
const { config: increaseAllowanceConfig } = usePreparePnkIncreaseAllowance({
66-
enabled: !isUndefined(klerosCore) && !isUndefined(targetStake) && !isUndefined(allowance),
67+
enabled: isAllowance && !isUndefined(klerosCore) && !isUndefined(targetStake) && !isUndefined(allowance),
6768
args: [klerosCore?.address, BigInt(targetStake ?? 0) - BigInt(allowance ?? 0)],
6869
});
6970
const { writeAsync: increaseAllowance } = usePnkIncreaseAllowance(increaseAllowanceConfig);
7071
const handleAllowance = () => {
7172
if (!isUndefined(increaseAllowance)) {
7273
setIsSending(true);
73-
wrapWithToast(increaseAllowance, publicClient).finally(() => {
74-
setIsSending(false);
75-
});
74+
wrapWithToast(async () => await increaseAllowance().then((response) => response.hash), publicClient).finally(
75+
() => {
76+
setIsSending(false);
77+
}
78+
);
7679
}
7780
};
7881

@@ -84,7 +87,7 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({ parsedAmount, action, se
8487
const handleStake = () => {
8588
if (typeof setStake !== "undefined") {
8689
setIsSending(true);
87-
wrapWithToast(setStake, publicClient)
90+
wrapWithToast(async () => await setStake().then((response) => response.hash), publicClient)
8891
.then(() => {
8992
setAmount("");
9093
})

web/src/utils/wrapWithToast.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ export const OPTIONS = {
1313

1414
export async function wrapWithToast(contractWrite: () => Promise<`0x${string}`>, publicClient: any) {
1515
toast.info("Transaction initiated", OPTIONS);
16-
console.log("1 before contractwrite");
17-
const { hash } = await contractWrite();
18-
console.log("2 after contractwrite, hash:", hash);
16+
const hash = await contractWrite();
1917
await publicClient
2018
.waitForTransactionReceipt({ hash, confirmations: 2 })
2119
.then(() => {
22-
console.log("3 inside waitfortransactionreceipt");
2320
toast.success("Transaction mined!", OPTIONS);
2421
})
2522
.catch((error) => {
26-
console.log("4 inside waitfortransaction catch", error);
2723
toast.error(error.message, OPTIONS);
2824
});
2925
}

0 commit comments

Comments
 (0)