3 Коміти 1e0c8f558e ... 288834e59f

Автор SHA1 Опис Дата
  Rimmon 288834e59f балансы 3 роки тому
  Rimmon e38751f79f Merge branch 'redesign2' of http://dev.prmsys.net:3001/Rimmon/HyperCube into redesign2 3 роки тому
  Rimmon ee513908f5 промежуточное 3 роки тому
3 змінених файлів з 75 додано та 54 видалено
  1. 13 0
      Models/Blockchain.cs
  2. 1 1
      Models/SmartContract.cs
  3. 61 53
      Pages/ModalAssets.razor

+ 13 - 0
Models/Blockchain.cs

@@ -648,6 +648,19 @@ namespace HyperCube.Models
            
         }
 
+        public async Task<string> BalanceOf(string contractAddress, string holderAddress)
+        {
+            TransactionObject transObj = new TransactionObject();
+            transObj.to = contractAddress;
+            transObj.data = await compileFunction($"function balanceOf(address account)");
+            if (address != null)
+                transObj.data += zerofill(holderAddress, 64, true);
+            //answer = await RunFunction2("eth_call", to, AccountModel.Current.GetActualAddress(this));
+            var answer = await RunFunction2("eth_call", transObj, "latest");
+            tokenBalance = ((double)AccountModel.ConvertBalance(ParseStringAnswer(answer)[0]) / 1000000000000000000.0).ToString();
+            return tokenBalance;
+        }
+
         public async void RunContractRead()
         {
             string answer = "no";

+ 1 - 1
Models/SmartContract.cs

@@ -155,7 +155,7 @@ namespace HyperCube.Models
                 var expert_value = article_value * verifier.GetRatingExpert() * edits;
                 var initiator_value = article_value * initiator.GetRatingProspector();
 
-                Console.WriteLine($"article_value {article_value} expert_value {expert_value} initiator_value {initiator_value} ");
+                Console.WriteLine($"article_value {article_value} expert_value {expert_value} initiator_value {initiator_value} CharCount {newArticle.CharCount} Keywords count {newArticle.Keywords.Split(",").Length} ");
 
                 //init notifications 2DEVS
                 return "none";

+ 61 - 53
Pages/ModalAssets.razor

@@ -7,10 +7,10 @@
                     <p>Цифровые активы</p>
                 </div>
                 @*<div class="modal__body__header__href">
-                    <a href="">Balans</a>
-                    <a href="">Swap</a>
-                    <a href="">Liquidity</a>
-                </div>*@
+                        <a href="">Balans</a>
+                        <a href="">Swap</a>
+                        <a href="">Liquidity</a>
+                    </div>*@
             </div>
             <div class="modal__body__container">
                 <div class="modal__body__container__left">
@@ -40,8 +40,8 @@
                         </div>
                         <div class="modal__body__calc__balance__numbers__value">
                             <div class="modal__body__calc__balance__numbers__value__item">
-                                <p>100.890110</p>
-                                <p>ETH</p>
+                                <p>@tokenBalance</p>
+                                <p>@ethBalance</p>
 
                             </div>
                             <div class="modal__body__calc__balance__numbers__value__item">
@@ -51,64 +51,72 @@
                         </div>
                     </div>
                     @*<div class="modal__body__calc__balance__button">
-                        <button class="btn_orange btn_center">Пополнение</button>
-                        <button class="btn_orange btn_center">Вывод</button>
-                    </div>*@
+                            <button class="btn_orange btn_center">Пополнение</button>
+                            <button class="btn_orange btn_center">Вывод</button>
+                        </div>*@
                 </div>
                 @*<div class="modal__body__container__right">
-                    <p class="modal__body__calc__change__header">Обмен</p>
-                    <p class="modal__body__calc__change__desc">Trade tokens in an istant</p>
-                    <div class="modal__input__box" place="From" balanc='0.00000410' currency='ETH'>
-                        <input type="text" class="modal__input">
-                        <select type="select" class="modal__select">
-                            <option>ETH</option>
-                            <option>2DH</option>
-                        </select>
-                    </div>
-                    <div class="modal__input__box" place="To" balanc='0.00000410' currency='2DH'>
-                        <input type="text" class="modal__input">
-                        <select type="select" class="modal__select">
-                            <option>2DH</option>
-                            <option>ETH</option>
-                        </select>
-                    </div>
-                    <div class="modal__input__total">
-                        <p>Price</p>
-                        <div class="modal_input_total_value">
-                            <p>1.000000050</p>
-                            <p>2DH</p>
+                        <p class="modal__body__calc__change__header">Обмен</p>
+                        <p class="modal__body__calc__change__desc">Trade tokens in an istant</p>
+                        <div class="modal__input__box" place="From" balanc='0.00000410' currency='ETH'>
+                            <input type="text" class="modal__input">
+                            <select type="select" class="modal__select">
+                                <option>ETH</option>
+                                <option>2DH</option>
+                            </select>
                         </div>
-                    </div>
-                    <div class="modal__input__button">
-                        <button class="btn_orange btn_center">ОК</button>
-                    </div>
-                </div>*@
+                        <div class="modal__input__box" place="To" balanc='0.00000410' currency='2DH'>
+                            <input type="text" class="modal__input">
+                            <select type="select" class="modal__select">
+                                <option>2DH</option>
+                                <option>ETH</option>
+                            </select>
+                        </div>
+                        <div class="modal__input__total">
+                            <p>Price</p>
+                            <div class="modal_input_total_value">
+                                <p>1.000000050</p>
+                                <p>2DH</p>
+                            </div>
+                        </div>
+                        <div class="modal__input__button">
+                            <button class="btn_orange btn_center">ОК</button>
+                        </div>
+                    </div>*@
             </div>
         </div>
         <a class="modal_close" style="cursor:pointer" @onclick="@Close">&#10006;</a>
     </div>
 </div>
 
-@code {
-    [Inject]
-    public IJSRuntime JsRuntime { get; set; }
-
-    [Parameter]
-    public RenderFragment Title { get; set; }
-
-    string elementid = "modal_assets";
-
+@code {[Inject]
+    public IJSRuntime JsRuntime { get; set; }
+
+    [Parameter]
+    public RenderFragment Title { get; set; }
+    string ethBalance;
+    string tokenBalance;
+
+    string elementid = "modal_assets";
+
     Models.AccountModel _account;
 
+        @using Models;Blockchain bcMain;
+
+        public async Task Balances()
+        {
+            ethBalance = await _account.GetBalance();
+            tokenBalance = await bcMain.BalanceOf("0xe5D682717955d6C35d465A3485625C64655a04f4", _account.GetActualAddress(bcMain));
+        }
 
-    public void Open(Models.AccountModel account)
-    {
-        _account = account;
-        JsRuntime.InvokeVoidAsync("OpenModal", elementid);
-    }
+        public void Open(Models.AccountModel account)
+        {
+            _account = account;
+            JsRuntime.InvokeVoidAsync("OpenModal", elementid);
+        }
 
-    public void Close()
-    {
-        JsRuntime.InvokeVoidAsync("CloseModal", elementid);
-    }
+        public void Close()
+        {
+            JsRuntime.InvokeVoidAsync("CloseModal", elementid);
+        }
 }