-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimatronik.ts
37 lines (32 loc) · 976 Bytes
/
animatronik.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { JsonRpcProvider } from "@ethersproject/providers"
import type { ethers } from "ethers"
import { useAtom } from "jotai"
import { signerAtom } from "~/atoms/signer"
import { AnimatronikContractAbi__factory as animatronikContract } from "~/generated/contracts/types"
import type { AnimatronikContractAbi as AnimatronikContract } from "~/generated/contracts/types/contracts/Animatronik.sol/AnimatronikContractAbi"
export function useAnimatronikContract({
address,
}: {
address: string
}): AnimatronikContract | undefined {
const [signer] = useAtom(signerAtom)
if (!signer) {
return undefined
}
return animatronikContract.connect(
address,
signer as unknown as ethers.JsonRpcSigner,
)
}
export function getAnimatronikContract({
provider,
address,
}: {
provider: JsonRpcProvider
address: string
}): AnimatronikContract {
return animatronikContract.connect(
address,
provider as unknown as ethers.JsonRpcProvider,
)
}