File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
apps/dashboard/src/components/contract-components Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
145
145
146
146
const customFactoryAbi = useCustomFactoryAbi (
147
147
customFactoryAddress ,
148
- Number ( customFactoryNetwork ) ,
148
+ customFactoryNetwork ? Number ( customFactoryNetwork ) : undefined ,
149
149
) ;
150
150
151
151
const isTWPublisher = checkTwPublisher ( metadata ?. publisher ) ;
Original file line number Diff line number Diff line change @@ -212,19 +212,32 @@ export function useContractEvents(abi: Abi) {
212
212
return abi . filter ( ( a ) => a . type === "event" ) ;
213
213
}
214
214
215
- export function useCustomFactoryAbi ( contractAddress : string , chainId : number ) {
215
+ export function useCustomFactoryAbi (
216
+ contractAddress : string ,
217
+ chainId : number | undefined ,
218
+ ) {
216
219
const chain = useV5DashboardChain ( chainId ) ;
217
220
const client = useThirdwebClient ( ) ;
218
221
const contract = useMemo ( ( ) => {
222
+ if ( ! chain ) {
223
+ return undefined ;
224
+ }
225
+
219
226
return getContract ( {
220
227
client,
221
228
address : contractAddress ,
222
229
chain,
223
230
} ) ;
224
231
} , [ contractAddress , chain , client ] ) ;
232
+
225
233
return useQuery ( {
226
234
queryKey : [ "custom-factory-abi" , contract ] ,
227
- queryFn : ( ) => resolveContractAbi < Abi > ( contract ) ,
235
+ queryFn : ( ) => {
236
+ if ( ! contract ) {
237
+ throw new Error ( "Contract not found" ) ;
238
+ }
239
+ return resolveContractAbi < Abi > ( contract ) ;
240
+ } ,
228
241
enabled : ! ! contract ,
229
242
} ) ;
230
243
}
You can’t perform that action at this time.
0 commit comments