Skip to content

Commit c24a669

Browse files
committed
External wallet improvements
Do not double sign user ops during simulation / switch before falling back to add
1 parent af37b3b commit c24a669

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
0 Bytes
Binary file not shown.

Assets/Thirdweb/Runtime/Unity/Wallets/Core/MetaMaskWallet.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,19 @@ public static async Task EnsureCorrectNetwork(BigInteger chainId)
203203
{
204204
if (WebGLMetaMask.Instance.GetActiveChainId() != chainId)
205205
{
206-
await AddNetwork(chainId);
207-
if (WebGLMetaMask.Instance.GetActiveChainId() == chainId)
206+
try
208207
{
209-
return;
208+
await SwitchNetwork(chainId);
209+
}
210+
catch
211+
{
212+
await AddNetwork(chainId);
213+
if (WebGLMetaMask.Instance.GetActiveChainId() == chainId)
214+
{
215+
return;
216+
}
217+
await SwitchNetwork(chainId);
210218
}
211-
await SwitchNetwork(chainId);
212219
}
213220
}
214221

0 commit comments

Comments
 (0)