Skip to content

Commit 4487d31

Browse files
committed
Make ToWcChain async and update call sites
Refactored ToWcChain to be an async method and updated all usages to await its result. This change ensures proper asynchronous handling when retrieving chain metadata.
1 parent 0b3cf2c commit 4487d31

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Assets/Thirdweb/Runtime/Unity/Wallets/Reown/ReownWallet.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ string[] excludedWalletIds
4848
else
4949
{
5050
ThirdwebDebug.Log($"The chain with ID {activeChainId} is not supported by Reown. Adding it manually.");
51-
wcChains.Add(ToWcChain(client, activeChainId));
51+
wcChains.Add(await ToWcChain(client, activeChainId));
5252
}
5353

5454
var appKitConfig = new AppKitConfig
@@ -241,7 +241,7 @@ public Task<EIP7702Authorization> SignAuthorization(BigInteger chainId, string c
241241

242242
public async Task SwitchNetwork(BigInteger chainId)
243243
{
244-
await AppKit.NetworkController.ChangeActiveChainAsync(ToWcChain(this.Client, chainId));
244+
await AppKit.NetworkController.ChangeActiveChainAsync(await ToWcChain(this.Client, chainId));
245245
ThirdwebDebug.Log($"Switched Reown to chain ID {chainId}.");
246246
}
247247

@@ -321,7 +321,7 @@ void OnAccountConnected(object sender, AccountConnectedEventArgs args)
321321
}
322322
}
323323

324-
private static Chain ToWcChain(ThirdwebClient client, BigInteger chainId)
324+
private static async Task<Chain> ToWcChain(ThirdwebClient client, BigInteger chainId)
325325
{
326326
var wcChain = ChainConstants.Chains.All.FirstOrDefault(c => c.ChainReference == chainId.ToString());
327327

@@ -330,7 +330,7 @@ private static Chain ToWcChain(ThirdwebClient client, BigInteger chainId)
330330
return wcChain;
331331
}
332332

333-
var twChainMeta = Utils.GetChainMetadata(client, chainId).GetAwaiter().GetResult();
333+
var twChainMeta = await Utils.GetChainMetadata(client, chainId);
334334
return new Chain(
335335
chainNamespace: ChainConstants.Namespaces.Evm,
336336
chainReference: chainId.ToString(),

0 commit comments

Comments
 (0)