Rimmon vor 3 Jahren
Ursprung
Commit
e2a3843beb
4 geänderte Dateien mit 11 neuen und 205 gelöschten Zeilen
  1. 2 2
      Models/Blockchain.cs
  2. 9 4
      Pages/ModalAssets.razor
  3. 0 75
      Pages/Wallet.razor
  4. 0 124
      Pages/Wallet.razor.cs

+ 2 - 2
Models/Blockchain.cs

@@ -223,9 +223,9 @@ namespace HyperCube.Models
                 //query = $"update aspnetusers set eth_address='{res}' where UserName='{account.Name}'";
                 var addr = account.GetActualAddress(this);
                 if (addr == null)
-                    query = $"insert into account_wallets (uuid, blockchain_id, account_uuid, password_plain) values ('{res}',{id},'{account.UUID}','{account.PWDHash}')";
+                    query = $"insert into account_wallets (uuid, blockchain_id, account_uuid, password_plain, added) values ('{res}',{id},'{account.UUID}','{account.PWDHash}', NOW())";
                 else
-                    query = $"update account_wallets set uuid='{res}', password_plain='{account.PWDHash}' where account_uuid='{account.UUID}' and blockchain_id={id}";
+                    query = $"update account_wallets set uuid='{res}', password_plain='{account.PWDHash}', added = NOW() where account_uuid='{account.UUID}' and blockchain_id={id}";
                 account.SetActualAddress(res, this);
                 Console.WriteLine($"CreateBlockchainAccount query {query}");
                 await MySQLConnector.Instance().SQLInsert(query);

+ 9 - 4
Pages/ModalAssets.razor

@@ -15,12 +15,12 @@
             <div class="modal__body__container">
                 <div class="modal__body__container__left">
                     <div class="modal__body__calc__balance__header">
-                        <p>БАЛАНС</p>
+                        <p>БАЛАНСЫ [@bc_selected]</p>
                         @*<button class="btn_orange">История</button>*@
                     </div>
                     <div class="modal__body__calc__balance__numbers">
                         <div class="modal__body__calc__balance__numbers__name">
-                            <p>Системы</p>
+                            <p>Система</p>
                         </div>
                         <div class="modal__body__calc__balance__numbers__value">
                             <div class="modal__body__calc__balance__numbers__value__item">
@@ -36,7 +36,7 @@
                     </div>
                     <div class="modal__body__calc__balance__numbers">
                         <div class="modal__body__calc__balance__numbers__name">
-                            <p>Ваше</p>
+                            <p>Аккаунт @_account.Name</p>
                         </div>
                         <div class="modal__body__calc__balance__numbers__value">
                             <div class="modal__body__calc__balance__numbers__value__item">
@@ -95,6 +95,7 @@
     public RenderFragment Title { get; set; }
     string ethBalance;
     string tokenBalance;
+    string bc_selected;
 
     string elementid = "modal_assets";
 
@@ -106,7 +107,11 @@
     {
         ethBalance = await _account.GetBalance();
         var bc = await _account.GetSelectedBlockChain();
-        tokenBalance = await bc.BalanceOf("0xe5D682717955d6C35d465A3485625C64655a04f4", _account.GetActualAddress(bc));
+        bc_selected = bc.name;
+        if (bc.port == 8666)
+            tokenBalance = await bc.BalanceOf("0xe5D682717955d6C35d465A3485625C64655a04f4", _account.GetActualAddress(bc));
+        else
+            tokenBalance = "0";
     }
 
     public async Task Open(Models.AccountModel account)

+ 0 - 75
Pages/Wallet.razor

@@ -1,75 +0,0 @@
-@page "/wallet"
-
-@using HyperCube.Models;
-@using Microsoft.AspNetCore.Identity;
-@inject AuthenticationStateProvider AuthenticationStateProvider
-@inject UserManager<IdentityUser> UserManager
-
-@attribute [Authorize]
-
-<div class="tabs__content">
-    <div class="tabs__controls">
-        @if (account.Roles.Contains(Role.Admin) || account.Roles.Contains(Role.Miner))
-        {
-            <a href="DocEdit" class="tabs__btn">Загрузка материалов</a>
-        }
-        @if (account.Roles.Contains(Role.Admin) || account.Roles.Contains(Role.Expert))
-        {
-            <a href="Verifying" class="tabs__btn">Верификация</a>
-        }
-        <a class="tabs__btn">Библиотеки</a>
-        @if (account.Roles.Contains(Role.Admin) || account.Roles.Contains(Role.Customer))
-        {
-            <a class="tabs__btn">Заказы</a>
-        }
-    </div>
-    <div class="upload">
-        <h2 class="upload__title">Кошелек</h2>
-    </div>
-    <table class="table-bordered" cellspacing="5" cellpadding="5">
-        <tbody>
-            <tr>
-                <td>UUID:</td>
-                <td>@account.UUID</td>
-            </tr>
-            <tr>
-                <td>Name:</td>
-                <td>@account.Name</td>
-            </tr>
-            <tr>
-                <td>Email:</td>
-                <td>@account.Email</td>
-            </tr>
-            <tr>
-                <td>ETH Address:</td>
-                <td>@address)</td>
-            </tr>
-            <tr>
-                <td>Balance:</td>
-                <td>@myBalance WEI</td>
-            </tr>
-            <tr>
-                <td>Администратор:</td>
-                <td><input @bind="admin"  type="checkbox" name="admin" /></td>
-            </tr>
-            <tr>
-                <td>Инициатор:</td>
-                <td><input @bind="initiator" type="checkbox" name="init" /></td>
-            </tr>
-            <tr>
-                <td>Заказчик:</td>
-                <td><input @bind="verifier" type="checkbox" name="request" /></td>
-            </tr>
-            <tr>
-                <td>Верификатор:</td>
-                <td><input @bind="requester" type="checkbox" name="vaerify" /></td>
-            </tr>
-            @*<p>
-                @foreach (var role in account.Roles)
-                    @role
-                <br />
-                @admin
-            </p>*@
-        </tbody>
-    </table>
-</div>

+ 0 - 124
Pages/Wallet.razor.cs

@@ -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}");
-        }
-    }
-}