@using Microsoft.AspNetCore.Components.Web
@code {[Inject] public IJSRuntime JsRuntime { get; set; } [Parameter] public RenderFragment Title { get; set; } string ethBalance; string tokenBalance; string chosenBalanceFrom; string chosenBalanceTo; string bc_selected; string fi; string ti; long lastInput = 0; string systemEth; string systemToken; string fromInput { get { return fi; } set { fi = value; System.Threading.Thread.Sleep(1); var now = DateTimeOffset.Now.ToUnixTimeSeconds(); if (now - lastInput > 0) { try { var val = float.Parse(fi, System.Globalization.CultureInfo.InvariantCulture); //var val = System.Convert.ToSingle(fi); if (to_token_selected == "qnm") val *= 1000f; else val /= 1000f; ti = val.ToString(); } catch (Exception e) { toInput = "0"; Console.WriteLine(e.Message); } } lastInput = DateTimeOffset.Now.ToUnixTimeSeconds(); } } string toInput { get { return ti; } set { ti = value; lastInput = DateTimeOffset.Now.ToUnixTimeSeconds(); System.Threading.Thread.Sleep(1); var now = DateTimeOffset.Now.ToUnixTimeSeconds(); if (now - lastInput > 0) { try { var val = float.Parse(ti, System.Globalization.CultureInfo.InvariantCulture); if (to_token_selected == "eth") val *= 1000f; else val /= 1000f; fi = val.ToString(); } catch (Exception e) { fromInput = "0"; Console.WriteLine(e.Message); } } } } string ft; string from_token_selected { get { return ft; } set { if (value == "eth") { to_token_selected = "qnm"; chosenBalanceFrom = ethBalance; chosenBalanceTo = tokenBalance; } else { to_token_selected = "eth"; chosenBalanceFrom = tokenBalance; chosenBalanceTo = ethBalance; } ft = value; } } string to_token_selected = "qnm"; string elementid = "modal_assets"; Models.AccountModel _account = new(); @using Models;Blockchain bcMain; public async Task Balances() { ethBalance = await _account.GetBalance(); var bc = await _account.GetSelectedBlockChain(); bc_selected = bc.name; if (bc.port == 8666) { tokenBalance = await bc.BalanceOf(Blockchain.QNMAddress, _account.GetActualAddress(bc)); systemEth = await bc.GetBalance(Blockchain.MultiOwnerContractRinkeby); systemToken = await bc.GetBalanceToken(Blockchain.QNMAddress, Blockchain.MultiOwnerContractRinkeby); Console.WriteLine($"systemToken {systemToken}"); } else tokenBalance = "0"; } public async Task Open(Models.AccountModel account) { _account = account; await Balances(); await JsRuntime.InvokeVoidAsync("OpenModal", elementid); } public async Task Ok() { bool confirmed = await JsRuntime.InvokeAsync