|
@@ -1,124 +0,0 @@
|
|
-using System.Threading.Tasks;
|
|
|
|
-using HyperCube.Models;
|
|
|
|
-using Microsoft.AspNetCore.Components;
|
|
|
|
-
|
|
|
|
-namespace HyperCube.Pages
|
|
|
|
-{
|
|
|
|
- public partial class Wallet
|
|
|
|
- {
|
|
|
|
- [Inject]
|
|
|
|
- AppData AppData { get; set; }
|
|
|
|
- private AccountModel account = new();
|
|
|
|
- string myBalance = "";
|
|
|
|
- string address = "";
|
|
|
|
-
|
|
|
|
- protected override async Task OnInitializedAsync()
|
|
|
|
- {
|
|
|
|
- account = AppData.CurrentAccount;
|
|
|
|
- var bc = await account.GetSelectedBlockChain();
|
|
|
|
- address = account.GetActualAddress(bc);
|
|
|
|
- if (bc != null)
|
|
|
|
- myBalance = await account.GetBalance();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private async Task<AccountModel> GetCurrentAcc()
|
|
|
|
- {
|
|
|
|
- AccountModel account = new();
|
|
|
|
-
|
|
|
|
- var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
|
|
|
- var user = authState.User;
|
|
|
|
-
|
|
|
|
- if (user.Identity.IsAuthenticated)
|
|
|
|
- {
|
|
|
|
- var currentUser = await UserManager.GetUserAsync(user);
|
|
|
|
- var acc = AccountModel.Find(currentUser.Id);
|
|
|
|
- if (acc != null)
|
|
|
|
- account = acc;
|
|
|
|
-
|
|
|
|
- account.LoadRoles();
|
|
|
|
- return account;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- bool admin
|
|
|
|
- {
|
|
|
|
- get { return account.Roles.Contains(Role.Admin); }
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- if (!account.Roles.Contains(Role.Admin))
|
|
|
|
- {
|
|
|
|
- account.AddRole(Role.Admin);
|
|
|
|
- InsertRole(Role.Admin);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- account.RemoveRole(Role.Admin);
|
|
|
|
- DeleteRole(Role.Admin);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- bool initiator
|
|
|
|
- {
|
|
|
|
- get { return account.Roles.Contains(Role.Miner); }
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- if (!account.Roles.Contains(Role.Miner))
|
|
|
|
- {
|
|
|
|
- account.AddRole(Role.Miner);
|
|
|
|
- InsertRole(Role.Miner);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- account.RemoveRole(Role.Miner);
|
|
|
|
- DeleteRole(Role.Miner);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- bool verifier
|
|
|
|
- {
|
|
|
|
- get { return account.Roles.Contains(Role.Expert); }
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- if (!account.Roles.Contains(Role.Expert))
|
|
|
|
- {
|
|
|
|
- account.AddRole(Role.Expert);
|
|
|
|
- InsertRole(Role.Expert);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- account.RemoveRole(Role.Expert);
|
|
|
|
- DeleteRole(Role.Expert);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- bool requester
|
|
|
|
- {
|
|
|
|
- get { return account.Roles.Contains(Role.Customer); }
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- if (!account.Roles.Contains(Role.Customer))
|
|
|
|
- {
|
|
|
|
- account.AddRole(Role.Customer);
|
|
|
|
- InsertRole(Role.Customer);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- account.RemoveRole(Role.Customer);
|
|
|
|
- DeleteRole(Role.Customer);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void InsertRole(Role role)
|
|
|
|
- {
|
|
|
|
- MySQLConnector.Instance().SQLInsert($"insert into account_roles (account_uuid, role_id) values ('{account.UUID}', {(int)role})");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void DeleteRole(Role role)
|
|
|
|
- {
|
|
|
|
- MySQLConnector.Instance().SQLInsert($"delete from account_roles where account_uuid = '{account.UUID}' and role_id={(int)role}");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|