private async Task <Page> BuildInputMnemonicPhrasePage(string commonText1, string commonText2, Func <string, bool> valid)
        {
            var inputMnemonic = new InputMnemonicPhrasePage(
                new CommonPageSettings
            {
                HasNavigation  = false,
                HeaderText     = "Mnemonic Phrase",
                Text           = commonText1,
                LeftButtonText = "Back"
            });


            inputMnemonic.ViewModel.Validators.Add(
                new KeyValuePair <string, Func <string, bool> >(
                    "The mnemonic phrase you entered is incorrect." + Environment.NewLine + "Typos can cause this."
                    + Environment.NewLine + "Please review your phrase and try again.",
                    valid));

            inputMnemonic.ViewModel.SuccessAction = async s =>
            {
                var result = await UpdateAddress(s);

                if (result)
                {
                    Settings.Set(Settings.Key.MnemonicPhrase, s);
                    Settings.Set(Settings.Key.IsLogged, true);

                    await _context.Navigation.PushSingleAsync(
                        new SuccessSignup(
                            new CommonPageSettings
                    {
                        HasNavigation = false,
                        HeaderText = commonText2
                    },
                            async() =>
                    {
                        var tokens = await _repository.Get();
                        foreach (var token in tokens)
                        {
                            await _repository.Delete(token);
                        }
                        App.SetMainPage(new BottomTabbedPage());
                    }));
                }
            };

            return(inputMnemonic);
        }
Beispiel #2
0
        private async Task RestoreWallet()
        {
            var inputMnemonic = new InputMnemonicPhrasePage(
                new CommonPageSettings
            {
                HasNavigation  = true,
                HasBack        = true,
                HeaderText     = "Restore Wallet",
                Title          = "Restore Wallet",
                Text           = "Enter your mnenonic phrase below to restore your wallet.",
                LeftButtonText = "Cancel"
            });

            inputMnemonic.ViewModel.Validators.Add(
                new KeyValuePair <string, Func <string, bool> >(
                    "The mnemonic phrase you entered is incorrect." + Environment.NewLine + "Typos can cause this."
                    + Environment.NewLine + "Please review your phrase and try again.",
                    EthereumService.MnenonicPhraseValidate));

            inputMnemonic.ViewModel.SuccessAction = async s =>
            {
                var result = await UpdateAddress(s);

                if (result)
                {
                    await _context.Navigation.PushSingleAsync(
                        new SuccessSignup(
                            new CommonPageSettings
                    {
                        HasNavigation = false,
                        HeaderText =
                            "The mnenonic phrase was an exatact match."
                            + Environment.NewLine + "Your wallet has been restored."
                            + Environment.NewLine + "Check out the dashboard."
                    },
                            () => this._context.Navigation.PopAsync()));

                    Settings.Set(Settings.Key.MnemonicPhrase, s);

                    _context.Navigation.RemovePage(
                        _context.Navigation.NavigationStack[_context.Navigation.NavigationStack.Count - 2]);
                }
            };

            await _context.Navigation.PushSingleAsync(inputMnemonic);
        }