Skip to content

Commit e1072a4

Browse files
committed
feat: useContractAutoLoad
1 parent e0f89aa commit e1072a4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/hooks/useContractAutoLoad.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { useNetwork } from 'wagmi'
2+
3+
export function useContractAutoLoad(contract: string, chainId?: number): any {
4+
const { chain } = useNetwork()
5+
switch (chainId || chain?.id) {
6+
case 1:
7+
switch (contract) {
8+
case 'Contract':
9+
return {
10+
address: '',
11+
abi: [],
12+
}
13+
default:
14+
throw new Error(`Unknown contract ${contract}`)
15+
}
16+
default:
17+
throw new Error(`Unknown network ${chain?.id}`)
18+
}
19+
}

0 commit comments

Comments
 (0)