调用wave-crypto模块创建种子和地址时出错 [英] Error with wave-crypto module when calling it to create a seed and address
本文介绍了调用wave-crypto模块创建种子和地址时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在模块中以及尝试创建onclick和种子以及公共和私有密钥的用户钱包时,我找不到crypto-js.
I can not find crypto-js within the moduleand while trying to create a user wallet onclick and seed and public and private key.
我收到此错误消息:
错误calllin模块功能找不到模块错误 "crypto-js",与app/tns_modules/
Error calllin module function Error can not find module "crypto-js", relatve to app/tns_modules/
这是我的代码:
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 { 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 = publicKey(seed);
const bytes = Uint8Array.from([1, 2, 3, 4]);
const sig = signBytes(bytes, seed);
const isValid = verifySignature(pubKey, bytes, sig)
}
wallet() {
let walletAddress = address('seed', 'T');
keyPair('seed');
publicKey('seed');
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
});
}
}
推荐答案
似乎您已手动复制了库.通过npm重新安装@waves/waves-crypto
,并从 node_modules 导入,如下所示:
It seems like you have manually copied the library. Reinstall @waves/waves-crypto
via npm, and import it from node_modules like this:
import * as wavesCrypto from '@waves/waves-crypto'
这篇关于调用wave-crypto模块创建种子和地址时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文