Esempio n. 1
0
        public WalletInfoPage()
        {
            InitializeComponent();
            var vm = new WalletInfoViewModel();

            BindingContext = vm;

            // Your label tap event
            var showPrivateKey = new TapGestureRecognizer();

            showPrivateKey.Tapped += (s, e) =>
            {
                if (txtPrivateKey.Text.StartsWith("*"))
                {
                    txtPrivateKey.Text = vm.PrivateKey;
                }
                else
                {
                    txtPrivateKey.Text = "********************************";
                }
            };
            lblViewKey.GestureRecognizers.Add(showPrivateKey);

            _cancel = new CancellationTokenSource();
            // redux
            App.Store.Select(state => state.wallet.VoteFor)
            .Subscribe(w =>
            {
                UserDialogs.Instance.HideLoading();
            }, _cancel.Token);
        }
Esempio n. 2
0
        public async Task InitializeAsync_working_correctly()
        {
            App.Settings.Endpoint = Endpoint.Mainnet;
            var web3Service = new Web3Service();
            await web3Service.TrySetAccountPrivateKey(privateKey);

            var model = new WalletInfoViewModel(web3Service, new NetworkService(), new Mock <INavigationService>().Object);

            await model.InitializeAsync(null);

            Assert.True(model.Tokens.Count == 0);
        }
Esempio n. 3
0
        public async Task <IViewComponentResult> InvokeAsync(User usr)
        {
            var eInfos     = GetInfosForUser(usr);
            var js         = JsonConvert.SerializeObject(eInfos);
            var walletInfo = new WalletInfoViewModel()
            {
                InfoJSON = js,
                InfoList = eInfos
            };

            return(View(walletInfo));
        }
Esempio n. 4
0
        public async Task RefreshPressed_executing_correctly()
        {
            App.Settings.Endpoint = Endpoint.Mainnet;
            var web3Service = new Web3Service();
            await web3Service.TrySetAccountPrivateKey(privateKey);

            var model = new WalletInfoViewModel(web3Service, new NetworkService(), new Mock <INavigationService>().Object);

            model.RefreshPressed.Execute(null);
            await Task.Delay(TimeSpan.FromSeconds(0.5));

            Assert.True(model.Tokens.Count == 0);
        }
Esempio n. 5
0
        public async Task TokenListItemPressed_executing_correctly()
        {
            var navigationPage = new NavigationPage();

            Application.Current.MainPage = navigationPage;
            var lazy  = new Lazy <INavigation>(navigationPage.Navigation);
            var model = new WalletInfoViewModel(new Mock <IWeb3Service>().Object, new Mock <INetworkService>().Object, new NavigationService(lazy));

            var oldCount = navigationPage.Navigation.NavigationStack.Count;

            model.TokenListItemPressed.Execute(null);
            await Task.Delay(TimeSpan.FromSeconds(0.5));

            var newCount = navigationPage.Navigation.NavigationStack.Count;

            Assert.True(newCount == oldCount + 1);
        }
Esempio n. 6
0
        public async Task <IActionResult> GetWalletInfo(string accountAddress)
        {
            WalletInfoViewModel  model      = new WalletInfoViewModel();
            Task <HexBigInteger> getBalance = _explorer.BalanceETH(accountAddress);

            var tasks = new List <Task <ERC20TokenViewModel> >();
            List <ERC20TokenViewModel> tokens = new List <ERC20TokenViewModel>();

            foreach (var token in _dbContext.Erc20Tokens)
            {
                if (token.Address != accountAddress)
                {
                    Task <ERC20TokenViewModel> task = _explorer.BalanceToken(token, accountAddress);
                    tasks.Add(task);
                }
                else
                {
                    break;
                }
            }

            try
            {
                model.Balance = Web3.Convert.FromWei(await getBalance, 18);

                await Task.WhenAll(tasks.ToArray());

                foreach (var listtask in tasks)
                {
                    tokens.Add(listtask.Result);
                }

                model.Tokens = tokens.Where(x => x.Balance != 0).ToList();
            }
            catch (Exception e)
            {
                return(BadRequest(HttpErrorHandler.AddError("Failure", e.Message, ModelState)));
            }

            return(new OkObjectResult(model));
        }
        public WalletInfoPage()
        {
            InitializeComponent();
            BindingContext = new WalletInfoViewModel(this);

            // Your label tap event
            var showPrivateKey = new TapGestureRecognizer();

            showPrivateKey.Tapped += (s, e) =>
            {
                if (txtPrivateKey.Text.StartsWith("*"))
                {
                    txtPrivateKey.Text = App.Container.PrivateKey;
                }
                else
                {
                    txtPrivateKey.Text = "********************************";
                }
            };
            lblViewKey.GestureRecognizers.Add(showPrivateKey);
        }
Esempio n. 8
0
 public WalletInfoPage(string address)
 {
     InitializeComponent();
     BindingContext = new WalletInfoViewModel(Navigation, App.Kernel.Get <ISmartNavigator>(), App.Kernel.Get <PageNavigator>(), address);
 }