File tree Expand file tree Collapse file tree 2 files changed +4
-21
lines changed Expand file tree Collapse file tree 2 files changed +4
-21
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ export type ChainMetadata = {
8282 type : string ;
8383 bridges ?: Readonly < Array < { url : string } > > ;
8484 } ;
85+ stackType : string ;
8586} ;
8687
8788/**
Original file line number Diff line number Diff line change 1+ import { getChainMetadata } from "src/chains/utils.js" ;
12import type { Chain } from "../../../chains/types.js" ;
2- import { withCache } from "../../promise/withCache.js" ;
33
44export async function isZkSyncChain ( chain : Chain ) {
55 if ( chain . id === 1337 || chain . id === 31337 ) {
@@ -20,28 +20,10 @@ export async function isZkSyncChain(chain: Chain) {
2020
2121 // fallback to checking the stack on rpc
2222 try {
23- const stack = await getChainStack ( chain . id ) ;
24- return stack === "zksync-stack" ;
23+ const chainMetadata = await getChainMetadata ( chain ) ;
24+ return chainMetadata . stackType === "zksync-stack" ;
2525 } catch {
2626 // If the network check fails, assume it's not a ZkSync chain
2727 return false ;
2828 }
2929}
30-
31- async function getChainStack ( chainId : number ) : Promise < string > {
32- return withCache (
33- async ( ) => {
34- const res = await fetch ( `https://${ chainId } .rpc.thirdweb.com/stack` ) ;
35-
36- if ( ! res . ok ) {
37- res . body ?. cancel ( ) ;
38- throw new Error ( `Error fetching stack for ${ chainId } ` ) ;
39- }
40-
41- const data = await res . json ( ) ;
42-
43- return data . stack ;
44- } ,
45- { cacheKey : `stack:${ chainId } ` , cacheTime : 24 * 60 * 60 * 1000 } ,
46- ) ;
47- }
You can’t perform that action at this time.
0 commit comments