Skip to content

Commit 42c9012

Browse files
committed
Improve behavior for unknown chainId w/ rpc available
1 parent 8b232a1 commit 42c9012

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Assets/Thirdweb/Core/Scripts/ThirdwebSession.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,23 @@ public static ThirdwebChainData FetchChainData(BigInteger chainId, string rpcOve
225225
allChainsData.AddRange(additionalChainsData);
226226

227227
ChainIDNetworkData currentNetwork = allChainsData.Find(x => x.chainId == chainId.ToString());
228+
if (currentNetwork == null)
229+
{
230+
return new ThirdwebChainData()
231+
{
232+
chainId = chainId.ToHex(false, true),
233+
blockExplorerUrls = new string[] { "https://etherscan.io" },
234+
chainName = $"Unknown Chain - {chainId}",
235+
iconUrls = new string[] { "ipfs://QmdwQDr6vmBtXmK2TmknkEuZNoaDqTasFdZdu3DRw8b2wt" },
236+
nativeCurrency = new ThirdwebNativeCurrency()
237+
{
238+
name = "Ether",
239+
symbol = "ETH",
240+
decimals = 18
241+
},
242+
rpcUrls = rpcOverride != null ? new string[] { rpcOverride } : new string[] { $"https://{chainId}.rpc.thirdweb.com" }
243+
};
244+
}
228245

229246
var explorerUrls = new List<string>();
230247
if (currentNetwork.explorers != null)

0 commit comments

Comments
 (0)