2018-10-17 01:56:56 -07:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import Tooltip from 'rc-tooltip'
|
|
|
|
import 'rc-tooltip/assets/bootstrap.css'
|
2017-12-11 16:54:27 -08:00
|
|
|
|
2018-10-15 07:52:03 -07:00
|
|
|
const encodeJson = json => {
|
2018-10-17 01:56:56 -07:00
|
|
|
const encoded = window.encodeURIComponent(JSON.stringify(json))
|
|
|
|
return `data:application/json;charset=utf-8,${encoded}`
|
|
|
|
}
|
2017-12-06 23:02:38 -08:00
|
|
|
|
2018-10-15 07:52:03 -07:00
|
|
|
export default class Keys extends Component {
|
2017-12-11 16:54:27 -08:00
|
|
|
constructor(props) {
|
2018-10-17 01:56:56 -07:00
|
|
|
super(props)
|
|
|
|
this.onVisibleChange = this.onVisibleChange.bind(this)
|
|
|
|
this.onCopyBtnClick = this.onCopyBtnClick.bind(this)
|
2017-12-11 16:54:27 -08:00
|
|
|
this.state = {
|
|
|
|
copyBtns: {
|
|
|
|
copyMiningPass: {
|
|
|
|
visible: false,
|
2018-10-17 01:56:56 -07:00
|
|
|
text: 'Copy'
|
2017-12-11 16:54:27 -08:00
|
|
|
},
|
|
|
|
copyVotingPass: {
|
|
|
|
visible: false,
|
2018-10-17 01:56:56 -07:00
|
|
|
text: 'Copy'
|
2017-12-11 16:54:27 -08:00
|
|
|
},
|
|
|
|
copyPayoutPass: {
|
|
|
|
visible: false,
|
2018-10-17 01:56:56 -07:00
|
|
|
text: 'Copy'
|
2017-12-11 16:54:27 -08:00
|
|
|
},
|
|
|
|
copyMiningKey: {
|
|
|
|
visible: false,
|
2018-10-17 01:56:56 -07:00
|
|
|
text: 'Copy'
|
2017-12-11 16:54:27 -08:00
|
|
|
},
|
|
|
|
copyVotingKey: {
|
|
|
|
visible: false,
|
2018-10-17 01:56:56 -07:00
|
|
|
text: 'Copy'
|
2017-12-11 16:54:27 -08:00
|
|
|
},
|
|
|
|
copyPayoutKey: {
|
|
|
|
visible: false,
|
2018-10-17 01:56:56 -07:00
|
|
|
text: 'Copy'
|
2018-10-15 07:52:03 -07:00
|
|
|
}
|
2017-12-11 16:54:27 -08:00
|
|
|
}
|
2018-10-17 01:56:56 -07:00
|
|
|
}
|
2017-12-11 16:54:27 -08:00
|
|
|
}
|
2017-12-06 23:02:38 -08:00
|
|
|
componentWillUpdate(nextProps, nextState) {
|
|
|
|
if (this.refs.miningKeyAddress) {
|
2018-10-17 01:56:56 -07:00
|
|
|
const Clipboard = require('clipboard')
|
2017-12-06 23:02:38 -08:00
|
|
|
// this.clipboard = new Clipboard(this.refs.copyBtn);
|
2018-10-17 01:56:56 -07:00
|
|
|
new Clipboard(this.refs.miningKeyAddress)
|
|
|
|
new Clipboard(this.refs.miningKeyPass)
|
|
|
|
new Clipboard(this.refs.payoutKeyAddress)
|
|
|
|
new Clipboard(this.refs.payoutKeyPass)
|
|
|
|
new Clipboard(this.refs.votingKeyAddress)
|
|
|
|
new Clipboard(this.refs.votingKeyPass)
|
2017-12-06 23:02:38 -08:00
|
|
|
}
|
|
|
|
}
|
2017-12-11 16:54:27 -08:00
|
|
|
onVisibleChange(id) {
|
2018-10-17 01:56:56 -07:00
|
|
|
console.log(id)
|
|
|
|
let copyBtns = this.state.copyBtns
|
|
|
|
copyBtns[id].visible = !copyBtns[id].visible
|
|
|
|
copyBtns[id].text = 'Copy'
|
2017-12-11 16:54:27 -08:00
|
|
|
this.setState({
|
|
|
|
copyBtns
|
2018-10-17 01:56:56 -07:00
|
|
|
})
|
2018-10-15 07:52:03 -07:00
|
|
|
|
2017-12-11 16:54:27 -08:00
|
|
|
// const id = e.target.id;
|
|
|
|
}
|
2018-10-15 07:52:03 -07:00
|
|
|
onCopyBtnClick(e) {
|
2018-10-17 01:56:56 -07:00
|
|
|
const id = e.target.id
|
|
|
|
let copyBtns = this.state.copyBtns
|
|
|
|
copyBtns[id].text = 'Copied!'
|
2017-12-11 16:54:27 -08:00
|
|
|
this.setState({
|
|
|
|
copyBtns
|
2018-10-17 01:56:56 -07:00
|
|
|
})
|
2017-12-11 16:54:27 -08:00
|
|
|
}
|
2018-10-15 07:52:03 -07:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className="container">
|
|
|
|
<div className="keys">
|
|
|
|
<div className="keys-i">
|
|
|
|
<p className="keys-title">Mining key</p>
|
|
|
|
<div className="keys-hash-container">
|
|
|
|
<p className="keys-hash" id="miningKey">
|
|
|
|
0x
|
|
|
|
{this.props.mining.jsonStore.address}
|
|
|
|
</p>
|
|
|
|
<Tooltip
|
|
|
|
visible={this.state.copyBtns.copyMiningKey.visible}
|
|
|
|
animation="zoom"
|
|
|
|
trigger="hover"
|
|
|
|
onVisibleChange={() => {
|
2018-10-17 01:56:56 -07:00
|
|
|
this.onVisibleChange('copyMiningKey')
|
2018-10-15 07:52:03 -07:00
|
|
|
}}
|
|
|
|
placement="right"
|
|
|
|
overlay={this.state.copyBtns.copyMiningKey.text}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
id="copyMiningKey"
|
|
|
|
onClick={this.onCopyBtnClick}
|
|
|
|
className="copy"
|
|
|
|
ref="miningKeyAddress"
|
2018-10-17 01:56:56 -07:00
|
|
|
data-clipboard-text={'0x' + this.props.mining.jsonStore.address}
|
2018-10-15 07:52:03 -07:00
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
<p className="keys-hash">
|
|
|
|
<label className="password-label">Password:</label>
|
|
|
|
<input
|
|
|
|
disabled={true}
|
|
|
|
defaultValue={this.props.mining.password}
|
|
|
|
type="password"
|
|
|
|
id="miningKeyPass"
|
|
|
|
className="pass"
|
|
|
|
/>
|
|
|
|
<Tooltip
|
|
|
|
visible={this.state.copyBtns.copyMiningPass.visible}
|
|
|
|
animation="zoom"
|
|
|
|
trigger="hover"
|
|
|
|
onVisibleChange={() => {
|
2018-10-17 01:56:56 -07:00
|
|
|
this.onVisibleChange('copyMiningPass')
|
2018-10-15 07:52:03 -07:00
|
|
|
}}
|
|
|
|
placement="right"
|
|
|
|
overlay={this.state.copyBtns.copyMiningPass.text}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
id="copyMiningPass"
|
|
|
|
onClick={this.onCopyBtnClick}
|
|
|
|
className="copy"
|
|
|
|
ref="miningKeyPass"
|
|
|
|
data-clipboard-text={this.props.mining.password}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</p>
|
|
|
|
<p className="keys-description">
|
2018-10-17 01:56:56 -07:00
|
|
|
Download this key and use it in your mining node to validate blocks in the network. Mined coins will be
|
|
|
|
deposited to your payout account.
|
2018-10-15 07:52:03 -07:00
|
|
|
</p>
|
|
|
|
<div className="keys-footer">
|
|
|
|
<a
|
|
|
|
className="keys-download"
|
|
|
|
id="miningKeyDownload"
|
|
|
|
href={encodeJson(this.props.mining.jsonStore)}
|
|
|
|
download={`mining_${this.props.mining.jsonStore.address}.json`}
|
|
|
|
>
|
|
|
|
Download Mining Key
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="keys-i">
|
|
|
|
<p className="keys-title">Payout key</p>
|
|
|
|
<div className="keys-hash-container">
|
|
|
|
<p className="keys-hash" id="payoutKey">
|
|
|
|
0x
|
|
|
|
{this.props.payout.jsonStore.address}
|
|
|
|
</p>
|
|
|
|
<Tooltip
|
|
|
|
visible={this.state.copyBtns.copyPayoutKey.visible}
|
|
|
|
animation="zoom"
|
|
|
|
trigger="hover"
|
|
|
|
onVisibleChange={() => {
|
2018-10-17 01:56:56 -07:00
|
|
|
this.onVisibleChange('copyPayoutKey')
|
2018-10-15 07:52:03 -07:00
|
|
|
}}
|
|
|
|
placement="right"
|
|
|
|
overlay={this.state.copyBtns.copyPayoutKey.text}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
id="copyPayoutKey"
|
|
|
|
onClick={this.onCopyBtnClick}
|
|
|
|
className="copy"
|
|
|
|
ref="payoutKeyAddress"
|
2018-10-17 01:56:56 -07:00
|
|
|
data-clipboard-text={'0x' + this.props.payout.jsonStore.address}
|
2018-10-15 07:52:03 -07:00
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
<p className="keys-hash">
|
|
|
|
<label className="password-label">Password:</label>
|
|
|
|
<input
|
|
|
|
type="password"
|
|
|
|
disabled={true}
|
|
|
|
id="payoutKeyPass"
|
|
|
|
className="pass"
|
|
|
|
defaultValue={this.props.payout.password}
|
|
|
|
/>
|
|
|
|
<Tooltip
|
|
|
|
visible={this.state.copyBtns.copyPayoutPass.visible}
|
|
|
|
animation="zoom"
|
|
|
|
trigger="hover"
|
|
|
|
onVisibleChange={() => {
|
2018-10-17 01:56:56 -07:00
|
|
|
this.onVisibleChange('copyPayoutPass')
|
2018-10-15 07:52:03 -07:00
|
|
|
}}
|
|
|
|
placement="right"
|
|
|
|
overlay={this.state.copyBtns.copyPayoutPass.text}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
id="copyPayoutPass"
|
|
|
|
onClick={this.onCopyBtnClick}
|
|
|
|
className="copy"
|
|
|
|
ref="payoutKeyPass"
|
|
|
|
data-clipboard-text={this.props.payout.password}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</p>
|
|
|
|
<p className="keys-description">
|
2018-10-17 01:56:56 -07:00
|
|
|
Download this key and use it on your client node/wallet to spend earned coins.
|
2018-10-15 07:52:03 -07:00
|
|
|
</p>
|
|
|
|
<div className="keys-footer">
|
|
|
|
<a
|
|
|
|
className="keys-download"
|
|
|
|
id="payoutKeyDownload"
|
|
|
|
href={encodeJson(this.props.payout.jsonStore)}
|
|
|
|
download={`payout_${this.props.payout.jsonStore.address}.json`}
|
|
|
|
>
|
|
|
|
Download Payout Key
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="keys-i">
|
|
|
|
<p className="keys-title">Voting key</p>
|
|
|
|
<div className="keys-hash-container">
|
|
|
|
<p className="keys-hash" id="votingKey">
|
|
|
|
0x
|
|
|
|
{this.props.voting.jsonStore.address}
|
|
|
|
</p>
|
|
|
|
<Tooltip
|
|
|
|
visible={this.state.copyBtns.copyVotingKey.visible}
|
|
|
|
animation="zoom"
|
|
|
|
trigger="hover"
|
|
|
|
onVisibleChange={() => {
|
2018-10-17 01:56:56 -07:00
|
|
|
this.onVisibleChange('copyVotingKey')
|
2018-10-15 07:52:03 -07:00
|
|
|
}}
|
|
|
|
placement="right"
|
|
|
|
overlay={this.state.copyBtns.copyVotingKey.text}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
id="copyVotingKey"
|
|
|
|
onClick={this.onCopyBtnClick}
|
|
|
|
className="copy"
|
|
|
|
ref="votingKeyAddress"
|
2018-10-17 01:56:56 -07:00
|
|
|
data-clipboard-text={'0x' + this.props.voting.jsonStore.address}
|
2018-10-15 07:52:03 -07:00
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
<p className="keys-hash">
|
|
|
|
<label className="password-label">Password:</label>
|
|
|
|
<input
|
|
|
|
type="password"
|
|
|
|
disabled={true}
|
|
|
|
id="votingKeyPass"
|
|
|
|
className="pass"
|
|
|
|
defaultValue={this.props.voting.password}
|
|
|
|
/>
|
|
|
|
<Tooltip
|
|
|
|
visible={this.state.copyBtns.copyVotingPass.visible}
|
|
|
|
animation="zoom"
|
|
|
|
trigger="hover"
|
|
|
|
onVisibleChange={() => {
|
2018-10-17 01:56:56 -07:00
|
|
|
this.onVisibleChange('copyVotingPass')
|
2018-10-15 07:52:03 -07:00
|
|
|
}}
|
|
|
|
placement="right"
|
|
|
|
overlay={this.state.copyBtns.copyVotingPass.text}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
id="copyVotingPass"
|
|
|
|
onClick={this.onCopyBtnClick}
|
|
|
|
className="copy"
|
|
|
|
ref="votingKeyPass"
|
|
|
|
data-clipboard-text={this.props.voting.password}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</p>
|
|
|
|
<p className="keys-description">
|
2018-10-17 01:56:56 -07:00
|
|
|
Download this key and use it on your client node to vote for necessary ballots, such as adding or removing
|
|
|
|
miners from the network.
|
2018-10-15 07:52:03 -07:00
|
|
|
</p>
|
|
|
|
<div className="keys-footer">
|
|
|
|
<a
|
|
|
|
className="keys-download"
|
|
|
|
id="votingKeyDownload"
|
|
|
|
href={encodeJson(this.props.voting.jsonStore)}
|
|
|
|
download={`voting_${this.props.voting.jsonStore.address}.json`}
|
|
|
|
>
|
|
|
|
Download Voting Key
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-12-06 23:02:38 -08:00
|
|
|
</div>
|
2018-10-15 07:52:03 -07:00
|
|
|
<div className="keys-note">
|
|
|
|
<p className="keys-note-title">Important</p>
|
|
|
|
<p className="keys-note-description">
|
2018-10-17 01:56:56 -07:00
|
|
|
Do not close this tab until you download all keys and save passwords. Keep keys secure and protected. If you
|
|
|
|
lose your keys, you will need to get a new initial key using Voting DAPP.
|
2018-10-15 07:52:03 -07:00
|
|
|
</p>
|
2017-12-06 23:02:38 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-10-17 01:56:56 -07:00
|
|
|
)
|
2017-12-06 23:02:38 -08:00
|
|
|
}
|
|
|
|
}
|