-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAccountList.js
105 lines (97 loc) · 3.07 KB
/
AccountList.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import React, { Component } from "react";
import KeyModal from "./KeyModal";
import ChecksumAddress from "../../components/checksum-addresses/ChecksumAddress";
import OnlyIf from "../../components/only-if/OnlyIf";
import FormattedEtherValue from "../../components/formatted-ether-value/FormattedEtherValue";
import KeyIcon from "../../icons/key.svg";
class AccountList extends Component {
constructor(props) {
super(props);
this.state = {
showKeys: false,
privateKey: "",
accountAddress: "",
};
}
showKeys = (accountAddress, privateKey) => {
this.setState({
showKeys: true,
privateKey,
accountAddress,
});
};
onCloseModal = () => {
this.setState({
showKeys: false,
});
};
_renderAccounts = () => {
const self = this;
return this.props.accounts.map((account, index) => {
return (
<div className="AccountCard" key={`account-card-${index}`}>
<div className="AddressAndBalance">
<div className="AccountAddress">
<div className="Label">ADDRESS</div>
<div className="Value">
<ChecksumAddress address={account} />
</div>
</div>
<div className="AccountBalance">
<div className="Label">BALANCE</div>
<div className="Value">
<FormattedEtherValue
value={this.props.balances[account].toString()}
/>
</div>
</div>
</div>
<div className="SecondaryInfo">
<div className="TransactionCount">
<div className="Label">TX COUNT</div>
<div className="Value">{this.props.nonces[account]}</div>
</div>
<div className="AccountIndex">
<div className="Label">INDEX</div>
<div className="Value">{index}</div>
</div>
<span
className="ShowKeys popover-container"
onClick={() => {
self.showKeys(
account,
// need to pass lower case account here because account is
// checksummed address
self.props.privateKeys[account.toLowerCase()],
);
}}
>
<KeyIcon />
<span className="popover">Show Keys</span>
</span>
{/* <div className={Styles.AccountState}>
{account.isUnlocked
? <Icon glyph={UnlockedIcon} size={24} className="isolate" />
: <Icon glyph={LockedIcon} size={24} className="isolate" />}
</div> */}
</div>
</div>
);
});
};
render() {
return (
<div className="AccountList">
{this._renderAccounts()}
<OnlyIf test={this.state.showKeys}>
<KeyModal
accountAddress={this.state.accountAddress}
privateKey={this.state.privateKey}
onCloseModal={this.onCloseModal}
/>
</OnlyIf>
</div>
);
}
}
export default AccountList;