diff --git a/Assets/MirageSDK/Plugins/WalletConnect.VersionShared/Utils/WalletDownloadHelper.cs b/Assets/MirageSDK/Plugins/WalletConnect.VersionShared/Utils/WalletDownloadHelper.cs index 90f7d4dd..c94fe149 100644 --- a/Assets/MirageSDK/Plugins/WalletConnect.VersionShared/Utils/WalletDownloadHelper.cs +++ b/Assets/MirageSDK/Plugins/WalletConnect.VersionShared/Utils/WalletDownloadHelper.cs @@ -12,7 +12,7 @@ namespace MirageSDK.WalletConnect.VersionShared.Utils { public static class WalletDownloadHelper { - private static Dictionary _walletEntriesCache = new Dictionary(); + private static Dictionary _walletEntriesCache; public static async UniTask FindWalletEntryByName(string walletName, bool invalidateCache = false) { @@ -84,21 +84,36 @@ public static async UniTask> FetchWalletList(boo return supportedWallets; } - var filteredSupportedWallets = GetAllSupportedWallets(walletconnectSupportedWallets: supportedWallets); - foreach (var wallet in filteredSupportedWallets.Values) + var filteredSupportedWallets = GetAllSupportedWallets(walletConnectSupportedWallets: supportedWallets); + + if (filteredSupportedWallets != null) { - await wallet.DownloadImages(); + var listOfTasks = new List(); + foreach (var wallet in filteredSupportedWallets.Values) + { + var downloadTask = wallet.DownloadImages(); + listOfTasks.Add(downloadTask); + } + + await UniTask.WhenAll(listOfTasks); } + _walletEntriesCache = filteredSupportedWallets; + return filteredSupportedWallets; } } private static Dictionary GetAllSupportedWallets( - Dictionary walletconnectSupportedWallets) + Dictionary walletConnectSupportedWallets) { + if (walletConnectSupportedWallets == null) + { + return null; + } + var walletsSupportedBySDK = WalletNameHelper.GetSupportedWalletNames(); - return walletconnectSupportedWallets + return walletConnectSupportedWallets .Where(predicate: w => walletsSupportedBySDK.Contains(value: w.Value.name)) .ToDictionary(keySelector: i => i.Key, elementSelector: i => i.Value); }