Add CanBeConfigured property to IProvider

This commit is contained in:
Ivan Yaremenchuk 2022-09-04 11:49:41 -05:00
parent 4ded842c9e
commit 31beec9bd9
6 changed files with 25 additions and 23 deletions

View File

@ -61,10 +61,10 @@ public partial class ProvidersPage : BasicComponent
}.Where(x => x != null).ToArray(),
Buttons = new[]
{
!provider.IsInitialized
? new CardListItemButton { Name = "Initialize", Style = ButtonStyle.Secondary, Action = () =>
provider.CanBeConfigured
? new CardListItemButton { Icon = "build", Style = ButtonStyle.Secondary, Action = () =>
{
provider.Initialize();
provider.Configure();
RefreshCards();
}}
: null,

View File

@ -9,9 +9,11 @@ public interface IProvider
public string ShortName { get; }
public string ImageName { get; }
public bool IsSupported { get; }
public bool IsInitialized { get; }
public void Initialize();
public bool CanBeConfigured { get; }
public bool IsConfigured { get; }
public void Configure();
public List<(string Name, string Value)> GetProperties();
public bool IsNetworkSupported(INetwork network);
}

View File

@ -10,14 +10,14 @@ public class EthereumKeygenProvider : IProvider
public string ShortName { get; } = "EthKeygen";
public string ImageName { get; } = "ecdsa.svg";
public bool IsSupported { get; } = true;
public bool IsInitialized { get; private set; }
public bool CanBeConfigured { get; } = true;
public bool IsConfigured { get; private set; }
public EthereumKey Key { get; private set; }
public void Initialize()
public void Configure()
{
Key = EthereumKey.GenerateNew();
IsInitialized = true;
IsConfigured = true;
}
public List<(string Name, string Value)> GetProperties()

View File

@ -10,14 +10,14 @@ public class SolanaKeygenProvider : IProvider
public string ShortName { get; } = "SolKeygen";
public string ImageName { get; } = "ecdsa.svg";
public bool IsSupported { get; } = true;
public bool IsInitialized { get; private set; }
public bool CanBeConfigured { get; } = true;
public bool IsConfigured { get; private set; }
public SolanaKey Key { get; private set; }
public void Initialize()
public void Configure()
{
Key = SolanaKey.GenerateNew();
IsInitialized = true;
IsConfigured = true;
}
public List<(string Name, string Value)> GetProperties()

View File

@ -9,19 +9,19 @@ public class MetamaskProvider : IProvider
public string ShortName { get; } = "Metamask";
public string ImageName { get; } = "metamask_fox.svg";
public bool IsSupported { get; } = true;
public bool CanBeConfigured { get; } = true;
public bool IsConfigured { get; private set; }
public bool IsInitialized { get; private set; }
public void Initialize()
public void Configure()
{
IsInitialized = true;
IsConfigured = true;
}
public List<(string Name, string Value)> GetProperties()
=> new List<(string Name, string Value)>
{
("Installed", "YES"),
("Connected", IsInitialized ? "YES" : "NO"),
("Connected", IsConfigured ? "YES" : "NO"),
};
public bool IsNetworkSupported(INetwork network)

View File

@ -9,19 +9,19 @@ public class PhantomProvider : IProvider
public string ShortName { get; } = "Phantom";
public string ImageName { get; } = "phantom.svg";
public bool IsSupported { get; } = true;
public bool CanBeConfigured { get; } = true;
public bool IsConfigured { get; private set; }
public bool IsInitialized { get; private set; }
public void Initialize()
public void Configure()
{
IsInitialized = true;
IsConfigured = true;
}
public List<(string Name, string Value)> GetProperties()
=> new List<(string Name, string Value)>
{
("Installed", "YES"),
("Connected", IsInitialized ? "YES" : "NO"),
("Connected", IsConfigured ? "YES" : "NO"),
};
public bool IsNetworkSupported(INetwork network)