@@ -22,7 +22,7 @@ import {
22
22
} from "@chakra-ui/react" ;
23
23
import { css , Global } from "@emotion/react" ;
24
24
import { BigNumber , BigNumberish } from "ethers" ;
25
- import React , { useEffect , useMemo , useRef , useState } from "react" ;
25
+ import React , { useEffect , useMemo , useState } from "react" ;
26
26
import ReactDOM from "react-dom" ;
27
27
import { IoDiamondOutline } from "react-icons/io5" ;
28
28
import {
@@ -78,6 +78,7 @@ interface HeaderProps extends ModuleInProps {
78
78
activeTab : Tab ;
79
79
setActiveTab : ( tab : Tab ) => void ;
80
80
tokenId : string ;
81
+ expectedChainId : number ;
81
82
}
82
83
83
84
const Header : React . FC < HeaderProps > = ( {
@@ -86,9 +87,15 @@ const Header: React.FC<HeaderProps> = ({
86
87
activeTab,
87
88
setActiveTab,
88
89
module,
90
+ expectedChainId,
89
91
tokenId,
90
92
} ) => {
91
93
const address = useAddress ( ) ;
94
+ const [ { data : network } ] = useNetwork ( ) ;
95
+ const chainId = useMemo ( ( ) => network ?. chain ?. id , [ network ] ) ;
96
+
97
+ const isEnabled = ! ! module && ! ! address && chainId === expectedChainId
98
+
92
99
const activeButtonProps : ButtonProps = {
93
100
borderBottom : "4px solid" ,
94
101
borderBottomColor : "blue.500" ,
@@ -103,7 +110,7 @@ const Header: React.FC<HeaderProps> = ({
103
110
async ( ) => {
104
111
return module ?. getActiveClaimCondition ( tokenId ) ;
105
112
} ,
106
- { enabled : ! ! module && tokenId . length > 0 } ,
113
+ { enabled : isEnabled && tokenId . length > 0 } ,
107
114
) ;
108
115
109
116
const owned = useQuery (
@@ -112,7 +119,7 @@ const Header: React.FC<HeaderProps> = ({
112
119
return module ?. balanceOf ( address || "" , tokenId ) ;
113
120
} ,
114
121
{
115
- enabled : ! ! module && tokenId . length > 0 && ! ! address ,
122
+ enabled : isEnabled && tokenId . length > 0 && ! ! address ,
116
123
} ,
117
124
) ;
118
125
0 commit comments