// Copyright 2015-2018 Parity Technologies (UK) Ltd. // This file is part of Parity. // // SPDX-License-Identifier: BSD-3-Clause import React, { Component } from "react"; import { AccountCard, Card, Form as FetherForm } from "fether-ui"; import { inject, observer } from "mobx-react"; @inject("createAccountStore") @observer class AccountRewritePhrase extends Component { state = { isLoading: false, isFileValid: false, json: null, value: "" }; handleChange = ({ target: { value } }) => { this.setState({ value }); }; handleChangeFile = ({ target: { result } }) => { try { const json = JSON.parse(result); const isFileValid = json.address.length === 32 && typeof json.meta === "object" && json.encoding.content === "pkcs8"; this.setState({ isFileValid, json }); } catch (error) { this.setState({ isFileValid: false, json: null }); console.error(error); } }; handleNextStep = async () => { const { history, location: { pathname }, createAccountStore: { isImport, isJSON, setJSON, setPhrase } } = this.props; const currentStep = pathname.slice(-1); const { json, value } = this.state; if (isJSON) { this.setState({ isLoading: true }); console.log("setting address ", json.address); await setJSON(json); // await setAddress(json.address); } // If we're importing, derive address from recovery phrase when we submit else if (isImport) { this.setState({ isLoading: true }); await setPhrase(value); } history.push(`/accounts/new/${+currentStep + 1}`); }; toggleImportMethod = () => { const { createAccountStore } = this.props; createAccountStore.setIsJSON(!createAccountStore.isJSON); }; render() { const { createAccountStore: { address, isImport, isJSON, name }, history, location: { pathname } } = this.props; const { value } = this.state; const currentStep = pathname.slice(-1); const body = [
Drop your JSON keyfile below
Type your Recovery phrase
Type your secret phrase to confirm that you wrote it down correctly:
)}