mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-22 11:38:26 +00:00
Fix providers initialization
This commit is contained in:
parent
1114351ead
commit
4b74ce20dc
@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NftFaucet.Components;
|
||||
using NftFaucet.Components.CardList;
|
||||
using NftFaucet.Plugins.ProviderPlugins;
|
||||
@ -7,12 +8,21 @@ namespace NftFaucet.Pages;
|
||||
|
||||
public partial class ProvidersPage : BasicComponent
|
||||
{
|
||||
protected override void OnInitialized()
|
||||
[Inject]
|
||||
public IServiceProvider ServiceProvider { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Providers = AppState.PluginStorage.Providers.Where(x => AppState.SelectedNetwork != null && x.IsNetworkSupported(AppState.SelectedNetwork)).ToArray();
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
if (!provider.IsInitialized)
|
||||
{
|
||||
await provider.InitializeAsync(ServiceProvider);
|
||||
}
|
||||
}
|
||||
RefreshCards();
|
||||
RefreshMediator.NotifyStateHasChangedSafe();
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
private IProvider[] Providers { get; set; }
|
||||
|
@ -10,6 +10,7 @@ public interface IProvider
|
||||
public string Name { get; }
|
||||
public string ShortName { get; }
|
||||
public string ImageName { get; }
|
||||
public bool IsInitialized { get; }
|
||||
public bool IsSupported { get; }
|
||||
public bool IsConfigured { get; }
|
||||
|
||||
|
@ -20,6 +20,7 @@ public class EthereumKeygenProvider : IProvider
|
||||
public string Name { get; } = "Ethereum keygen";
|
||||
public string ShortName { get; } = "EthKeygen";
|
||||
public string ImageName { get; } = "ecdsa.svg";
|
||||
public bool IsInitialized { get; } = true;
|
||||
public bool IsSupported { get; } = true;
|
||||
public bool IsConfigured { get; private set; }
|
||||
public EthereumKey Key { get; private set; }
|
||||
|
@ -22,6 +22,7 @@ public class SolanaKeygenProvider : IProvider
|
||||
public string Name { get; } = "Solana keygen";
|
||||
public string ShortName { get; } = "SolKeygen";
|
||||
public string ImageName { get; } = "ecdsa.svg";
|
||||
public bool IsInitialized { get; } = true;
|
||||
public bool IsSupported { get; } = true;
|
||||
public bool IsConfigured { get; private set; }
|
||||
public SolanaKey Key { get; private set; }
|
||||
|
@ -14,6 +14,7 @@ public class MetamaskProvider : IProvider
|
||||
public string Name { get; } = "Metamask";
|
||||
public string ShortName { get; } = "Metamask";
|
||||
public string ImageName { get; } = "metamask_fox.svg";
|
||||
public bool IsInitialized { get; private set; }
|
||||
public bool IsSupported { get; } = true;
|
||||
public bool IsConfigured => IsMetamaskAvailable && IsSiteConnected && !string.IsNullOrEmpty(Address);
|
||||
|
||||
@ -41,6 +42,8 @@ public class MetamaskProvider : IProvider
|
||||
Address = await MetaMaskService.GetSelectedAccountAsync();
|
||||
ChainId = await MetaMaskService.GetSelectedChainAsync();
|
||||
}
|
||||
|
||||
IsInitialized = true;
|
||||
}
|
||||
|
||||
public CardListItemProperty[] GetProperties()
|
||||
|
@ -11,6 +11,7 @@ public class PhantomProvider : IProvider
|
||||
public string Name { get; } = "Phantom";
|
||||
public string ShortName { get; } = "Phantom";
|
||||
public string ImageName { get; } = "phantom.svg";
|
||||
public bool IsInitialized { get; } = true;
|
||||
public bool IsSupported { get; } = false;
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user