尝试创建新的钱包地址,但没有任何反应

时间:2019-05-12 17:22:47

标签: html typescript wavesplatform

我正在尝试为我的新的以原生脚本编写的android和ios加密货币应用程序创建一个钱包地址和一个种子短语。

我尝试使用console.log和警报功能在我的应用上创建帐户后向用户显示新的种子短语和钱包地址。但是当他们按下按钮并执行“ wallet()”函数时,没有弹出任何提示,但我没有收到错误,或者只是一个按钮无法正常工作。

import { Component, ElementRef, ViewChild } from "@angular/core";
import { Router } from "@angular/router";
import { alert, prompt } from "tns-core-modules/ui/dialogs";
import { Page } from "tns-core-modules/ui/page";
import { Routes } from "@angular/router";
//import { publicKey, verifySignature, signBytes, address, keyPair, privateKey } from "../@waves/waves-crypto";
import * as wavesCrypto from '../waves-crypto';
import * as CryptoJS from '../crypto-js';

import { User } from "../shared/user.model";
import { UserService } from "../shared/user.service";

@Component({
    selector: "app-login",
    moduleId: module.id,
    templateUrl: "./login.component.html",
    styleUrls: ['./login.component.css']
})
export class LoginComponent {
    isLoggingIn = true;
    user: User;
    @ViewChild("password") password: ElementRef;
    @ViewChild("confirmPassword") confirmPassword: ElementRef;
    @ViewChild("waves") waves: ElementRef;

    constructor(private page: Page, private userService: UserService, private router: Router) {
        this.page.actionBarHidden = true;
        this.user = new User();
        // this.user.email = "foo2@foo.com";
        // this.user.password = "foo";
        const seed = 'magicseed';
        const pubKey = wavesCrypto.publicKey(seed);
        const bytes = Uint8Array.from([1, 2, 3, 4]);
        const sig = wavesCrypto.signBytes(bytes, seed);
        const isValid = wavesCrypto.verifySignature(pubKey, bytes, sig)
    }

    wallet() {
        let walletAddress = wavesCrypto.address('seed', 'T');
        let keyPair = wavesCrypto.keyPair('seed');
        wavesCrypto.publicKey('seed');
        wavesCrypto.privateKey('seed');
        wavesCrypto.privateKey('seed');
        alert(walletAddress);
        console.log(walletAddress);
        console.log(keyPair);
    }

    toggleForm() {
        this.isLoggingIn = !this.isLoggingIn;
    }

    submit() {
        if (!this.user.email || !this.user.password) {
            this.alert("Please provide both an email address and password.");
            return;
        }

        if (this.isLoggingIn) {
            this.login();
        } else {
            this.register();
        }
    }

    login() {
        this.userService.login(this.user)
            .then(() => {
                this.router.navigate(["/home"]);
            })
            .catch(() => {
                this.alert("Unfortunately we could not find your account.");
            });
    }

    register() {
        if (this.user.password != this.user.confirmPassword) {
            this.alert("Your passwords do not match.");
            return;
        }
        this.userService.register(this.user)
            .then(() => {
                this.alert("Your account was successfully created.");
                this.isLoggingIn = true;
            })
            .catch(() => {
                this.alert("Unfortunately we were unable to create your account.");
            });
    }

    forgotPassword() {
        prompt({
            title: "Forgot Password",
            message: "Enter the email address you used to register for APP NAME to reset your password.",
            inputType: "email",
            defaultText: "",
            okButtonText: "Ok",
            cancelButtonText: "Cancel"
        }).then((data) => {
            if (data.result) {
                this.userService.resetPassword(data.text.trim())
                    .then(() => {
                        this.alert("Your password was successfully reset. Please check your email for instructions on choosing a new password.");
                    }).catch(() => {
                        this.alert("Unfortunately, an error occurred resetting your password.");
                    });
            }
        });
    }

    focusPassword() {
        this.password.nativeElement.focus();
    }
    focusConfirmPassword() {
        if (!this.isLoggingIn) {
            this.confirmPassword.nativeElement.focus();
        }
    }

    alert(message: string) {
        return alert({
            title: "APP NAME",
            okButtonText: "OK",
            message: message
        });
    }
}

所以我希望在按下按钮时出现一个弹出窗口,或者它可以在按钮上方用户测试网上新的钱包地址和种子短语的同一页面上显示该页面

0 个答案:

没有答案