public ConnectionStatus GetConnectionProperties()
{
try
{
var version = EthereumService.GetWeb3ClientVersion();
}
catch (Exception)
{
return ConnectionStatus.CouldNotConnect;
}
try
{
var ethAccounts = EthereumService.GetAccounts();
foreach (var ethAccount in ethAccounts)
{
var account = BlockStudioProjectService.BlockStudioProject.Accounts.FirstOrDefault(x => x.Address == ethAccount);
if (account==null)
{
account = new Account();
account.Address = ethAccount;
account.LockState = LockedState.Locked;
}
if (!string.IsNullOrEmpty(account.Password))
{
try
{
var unlockSuccessful = EthereumService.UnlockAccount(account.Address, account.Password);
if (unlockSuccessful)
{
account.Balance = EthereumService.GetBalance(account.Address, BlockTag.Latest);
account.LockState = LockedState.Unlocked;
}
else
{
account.ImageIconIndex = 6;
account.LockState = LockedState.WrongPassword;
}
}
catch (Exception exception)
{
return ConnectionStatus.ConnectedButPersonalNotSuppored;
}
}
else
{
account.LockState = LockedState.Locked;
}
BlockStudioProjectService.BlockStudioProject.UpsertAccount(account);
}
BlockStudioProjectService.BlockStudioProject.SaveToDisk();
return ConnectionStatus.Connected;
}
catch (Exception exception)
{
throw exception;
}
}