Skip to content

Commit 40bb9f3

Browse files
committed
chore: inject public client into hypercert client
injecting our own public client into the hypercert client will ensure we use our own rpc url's within the hypercert exchange client. this prevents the viem defaults being used which error out regularly
1 parent 0a29cbc commit 40bb9f3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

hooks/use-hypercert-client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ import { HypercertClient } from "@hypercerts-org/sdk";
33
import { useEffect, useState } from "react";
44
import { useAccount, useWalletClient } from "wagmi";
55
import { ENVIRONMENT, SUPPORTED_CHAINS } from "@/configs/constants";
6+
import { EvmClientFactory } from "@/lib/evmClient";
67

78
export const useHypercertClient = () => {
89
const { data: walletClient } = useWalletClient();
910
const { isConnected } = useAccount();
1011
const [client, setClient] = useState<HypercertClient>();
1112

13+
const publicClient = walletClient?.chain.id
14+
? EvmClientFactory.createClient(walletClient.chain.id)
15+
: undefined;
16+
1217
useEffect(() => {
1318
if (!walletClient || !isConnected) {
1419
return;
@@ -22,6 +27,8 @@ export const useHypercertClient = () => {
2227
environment: ENVIRONMENT,
2328
// @ts-ignore - wagmi and viem have different typing
2429
walletClient,
30+
// @ts-ignore - wagmi and viem have different typing
31+
publicClient,
2532
}),
2633
);
2734
}, [walletClient, isConnected]);

0 commit comments

Comments
 (0)