diff --git a/apps/dashboard/src/components/configure-networks/ConfigureNetworkForm.tsx b/apps/dashboard/src/components/configure-networks/ConfigureNetworkForm.tsx index a5cbe33f45e..c1a5640f4c4 100644 --- a/apps/dashboard/src/components/configure-networks/ConfigureNetworkForm.tsx +++ b/apps/dashboard/src/components/configure-networks/ConfigureNetworkForm.tsx @@ -28,6 +28,7 @@ export type NetworkConfigFormData = { type: "testnet" | "mainnet"; icon: string; slug: string; + stackType?: string; }; // lowercase it, replace all spaces with hyphens, and then strip all non-alphanumeric characters @@ -71,6 +72,7 @@ export const ConfigureNetworkForm: React.FC = ({ type: editingChain?.testnet ? "testnet" : "mainnet", icon: editingChain?.icon?.url || "", slug: prefillSlug || editingChain?.slug || "", + stackType: "", }, mode: "onChange", }); @@ -146,6 +148,7 @@ export const ConfigureNetworkForm: React.FC = ({ format: "", }, testnet: data.type === "testnet", + stackType: data.stackType || "", }; } else { configuredNetwork = { @@ -170,6 +173,7 @@ export const ConfigureNetworkForm: React.FC = ({ format: "", } : undefined, + stackType: data.stackType || "", }; } diff --git a/apps/dashboard/src/contract-ui/tabs/embed/components/embed-setup.tsx b/apps/dashboard/src/contract-ui/tabs/embed/components/embed-setup.tsx index 04b613d7c3e..9f90151f381 100644 --- a/apps/dashboard/src/contract-ui/tabs/embed/components/embed-setup.tsx +++ b/apps/dashboard/src/contract-ui/tabs/embed/components/embed-setup.tsx @@ -243,6 +243,7 @@ export const EmbedSetup: React.FC = ({ shortName: "unknown", slug: "unknown", testnet: false, + stackType: "", }; const { register, watch } = useForm<{ diff --git a/packages/thirdweb/src/chains/types.ts b/packages/thirdweb/src/chains/types.ts index cb3cd41e24c..7a9298c92eb 100644 --- a/packages/thirdweb/src/chains/types.ts +++ b/packages/thirdweb/src/chains/types.ts @@ -82,6 +82,7 @@ export type ChainMetadata = { type: string; bridges?: Readonly>; }; + stackType: string; }; /** diff --git a/packages/thirdweb/src/chains/utils.ts b/packages/thirdweb/src/chains/utils.ts index 769e88eb96f..5ce4eefa70d 100644 --- a/packages/thirdweb/src/chains/utils.ts +++ b/packages/thirdweb/src/chains/utils.ts @@ -365,5 +365,6 @@ function createChainMetadata( url: e.url, standard: "EIP3091", })) || data?.explorers, + stackType: data?.stackType || "", }; } diff --git a/packages/thirdweb/src/utils/any-evm/zksync/isZkSyncChain.ts b/packages/thirdweb/src/utils/any-evm/zksync/isZkSyncChain.ts index 91a13b1f0c3..4b6901f7f39 100644 --- a/packages/thirdweb/src/utils/any-evm/zksync/isZkSyncChain.ts +++ b/packages/thirdweb/src/utils/any-evm/zksync/isZkSyncChain.ts @@ -1,5 +1,5 @@ import type { Chain } from "../../../chains/types.js"; -import { withCache } from "../../promise/withCache.js"; +import { getChainMetadata } from "../../../chains/utils.js"; export async function isZkSyncChain(chain: Chain) { if (chain.id === 1337 || chain.id === 31337) { @@ -12,36 +12,20 @@ export async function isZkSyncChain(chain: Chain) { chain.id === 300 || chain.id === 302 || chain.id === 11124 || - chain.id === 282 || // cronos zkevm testnet - chain.id === 388 // cronos zkevm mainnet + chain.id === 282 || + chain.id === 388 || + chain.id === 4654 || + chain.id === 333271 ) { return true; } // fallback to checking the stack on rpc try { - const stack = await getChainStack(chain.id); - return stack === "zksync-stack"; + const chainMetadata = await getChainMetadata(chain); + return chainMetadata.stackType === "zksync_stack"; } catch { // If the network check fails, assume it's not a ZkSync chain return false; } } - -async function getChainStack(chainId: number): Promise { - return withCache( - async () => { - const res = await fetch(`https://${chainId}.rpc.thirdweb.com/stack`); - - if (!res.ok) { - res.body?.cancel(); - throw new Error(`Error fetching stack for ${chainId}`); - } - - const data = await res.json(); - - return data.stack; - }, - { cacheKey: `stack:${chainId}`, cacheTime: 24 * 60 * 60 * 1000 }, - ); -}