@@ -10,6 +10,7 @@ import {
10
10
import { isUndefined } from "utils/index" ;
11
11
import { wrapWithToast } from "utils/wrapWithToast" ;
12
12
import { useTransactionDetailsContext } from "context/TransactionDetailsContext" ;
13
+ import { useQueryRefetch } from "hooks/useQueryRefetch" ;
13
14
14
15
interface IRaiseDisputeButton {
15
16
toggleModal ?: ( ) => void ;
@@ -23,6 +24,7 @@ const RaiseDisputeButton: React.FC<IRaiseDisputeButton> = ({ toggleModal, button
23
24
const publicClient = usePublicClient ( ) ;
24
25
const { buyer, id } = useTransactionDetailsContext ( ) ;
25
26
const isBuyer = useMemo ( ( ) => address ?. toLowerCase ( ) === buyer ?. toLowerCase ( ) , [ address , buyer ] ) ;
27
+ const refetchQuery = useQueryRefetch ( ) ;
26
28
27
29
const { config : payArbitrationFeeByBuyerConfig } = usePrepareEscrowUniversalPayArbitrationFeeByBuyer ( {
28
30
args : [ BigInt ( id ) ] ,
@@ -34,17 +36,20 @@ const RaiseDisputeButton: React.FC<IRaiseDisputeButton> = ({ toggleModal, button
34
36
value : arbitrationCost ,
35
37
} ) ;
36
38
37
- const { writeAsync : payArbitrationFeeByBuyer } = useEscrowUniversalPayArbitrationFeeByBuyer ( payArbitrationFeeByBuyerConfig ) ;
38
- const { writeAsync : payArbitrationFeeBySeller } = useEscrowUniversalPayArbitrationFeeBySeller ( payArbitrationFeeBySellerConfig ) ;
39
+ const { writeAsync : payArbitrationFeeByBuyer } =
40
+ useEscrowUniversalPayArbitrationFeeByBuyer ( payArbitrationFeeByBuyerConfig ) ;
41
+ const { writeAsync : payArbitrationFeeBySeller } = useEscrowUniversalPayArbitrationFeeBySeller (
42
+ payArbitrationFeeBySellerConfig
43
+ ) ;
39
44
40
45
const handleRaiseDispute = ( ) => {
41
46
if ( isBuyer && ! isUndefined ( payArbitrationFeeByBuyer ) ) {
42
47
setIsSending ( true ) ;
43
48
wrapWithToast ( async ( ) => await payArbitrationFeeByBuyer ( ) . then ( ( response ) => response . hash ) , publicClient )
44
49
. then ( ( wrapResult ) => {
45
- if ( wrapResult . status && toggleModal ) {
46
- toggleModal ( ) ;
47
- } else if ( wrapResult . status ) {
50
+ if ( wrapResult . status ) {
51
+ toggleModal && toggleModal ( ) ;
52
+ refetchQuery ( [ [ "refetchOnBlock" , "useTransactionDetailsQuery" ] ] ) ;
48
53
} else {
49
54
setIsSending ( false ) ;
50
55
}
@@ -57,9 +62,9 @@ const RaiseDisputeButton: React.FC<IRaiseDisputeButton> = ({ toggleModal, button
57
62
setIsSending ( true ) ;
58
63
wrapWithToast ( async ( ) => await payArbitrationFeeBySeller ( ) . then ( ( response ) => response . hash ) , publicClient )
59
64
. then ( ( wrapResult ) => {
60
- if ( wrapResult . status && toggleModal ) {
61
- toggleModal ( ) ;
62
- } else if ( wrapResult . status ) {
65
+ if ( wrapResult . status ) {
66
+ toggleModal && toggleModal ( ) ;
67
+ refetchQuery ( [ [ "refetchOnBlock" , "useTransactionDetailsQuery" ] ] ) ;
63
68
} else {
64
69
setIsSending ( false ) ;
65
70
}
0 commit comments