Skip to content

Commit 09301b2

Browse files
committed
feat: latest changes to wrapper and calling functions
1 parent 7f60bec commit 09301b2

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

web/src/pages/Cases/CaseDetails/Evidence/SubmitEvidenceModal.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ const SubmitEvidenceModal: React.FC<{
4242
functionName: "submitEvidence",
4343
args: [BigInt(evidenceGroup), cid],
4444
});
45-
await wrapWithToast(() => walletClient.writeContract(request), publicClient).then(() => {
46-
setMessage("");
47-
close();
48-
});
45+
await wrapWithToast(async () => await walletClient.writeContract(request), publicClient).then(
46+
() => {
47+
setMessage("");
48+
close();
49+
}
50+
);
4951
}
5052
})
5153
.catch()

web/src/pages/Cases/CaseDetails/Voting/Binary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const Binary: React.FC<{ arbitrable: `0x${string}`; voteIDs: string[] }> = ({ ar
7070
],
7171
});
7272
if (walletClient) {
73-
wrapWithToast(() => walletClient.writeContract(request), publicClient).finally(() => {
73+
wrapWithToast(async () => await walletClient.writeContract(request), publicClient).finally(() => {
7474
setChosenOption(-1);
7575
setIsSending(false);
7676
});

web/src/utils/wrapWithToast.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { toast, ToastPosition, Theme } from "react-toastify";
2-
import { WriteContractResult } from "wagmi/dist/actions";
32

43
export const OPTIONS = {
54
position: "top-center" as ToastPosition,
@@ -12,15 +11,19 @@ export const OPTIONS = {
1211
theme: "colored" as Theme,
1312
};
1413

15-
export async function wrapWithToast(contractWrite: () => Promise<WriteContractResult>, publicClient: any) {
14+
export async function wrapWithToast(contractWrite: () => Promise<`0x${string}`>, publicClient: any) {
1615
toast.info("Transaction initiated", OPTIONS);
16+
console.log("1 before contractwrite");
1717
const { hash } = await contractWrite();
18+
console.log("2 after contractwrite, hash:", hash);
1819
await publicClient
1920
.waitForTransactionReceipt({ hash, confirmations: 2 })
2021
.then(() => {
22+
console.log("3 inside waitfortransactionreceipt");
2123
toast.success("Transaction mined!", OPTIONS);
2224
})
2325
.catch((error) => {
26+
console.log("4 inside waitfortransaction catch", error);
2427
toast.error(error.message, OPTIONS);
2528
});
2629
}

0 commit comments

Comments
 (0)