1- import { getPublicClient } from "@wagmi/core " ;
2- import { GetTransactionReceiptReturnType , decodeEventLog , getEventSelector } from "viem" ;
1+ import { GetTransactionReceiptReturnType , createPublicClient , decodeEventLog , getEventSelector , http } from "viem " ;
2+ import * as chains from "viem/chains " ;
33
44import { iArbitrableV2Abi } from "hooks/contracts/generated" ;
55import { isUndefined } from "utils/index" ;
66
7+ /**
8+ * Gets the chain object for the given chain id.
9+ * @param chainId - Chain id of the target EVM chain.
10+ * @returns Viem's chain object.
11+ */
12+ const getChain = ( chainId : number ) => {
13+ for ( const chain of Object . values ( chains ) ) {
14+ if ( "id" in chain ) {
15+ if ( chain . id === chainId ) {
16+ return chain ;
17+ }
18+ }
19+ }
20+
21+ throw new Error ( `Chain with id ${ chainId } not found` ) ;
22+ } ;
23+
24+ // Warning : do not import this in any pages except DisputeTemplatePreview, this has a large bundle size.
725export const getDisputeRequestParamsFromTxn = async ( hash : `0x${string } `, chainId : number ) => {
826 try {
9- const publicClient = getPublicClient ( { chainId } ) ;
27+ const publicClient = createPublicClient ( {
28+ chain : getChain ( chainId ) ,
29+ transport : http ( ) ,
30+ } ) ;
1031
1132 const txn : GetTransactionReceiptReturnType = await publicClient . getTransactionReceipt ( {
1233 hash,
@@ -28,6 +49,8 @@ export const getDisputeRequestParamsFromTxn = async (hash: `0x${string}`, chainI
2849 _arbitrable : disputeRequestEvent . address ,
2950 } ;
3051 } catch ( e ) {
52+ console . log ( "Error getting txn :" , { e } ) ;
53+
3154 return undefined ;
3255 }
3356} ;
0 commit comments