@@ -10,20 +10,17 @@ import "../common/Signatures.sol";
10
10
import "../common/UsingRegistry.sol " ;
11
11
12
12
contract Accounts is IAccounts , ReentrancyGuard , Initializable , UsingRegistry {
13
-
14
13
using SafeMath for uint256 ;
15
14
16
15
struct Signers {
17
16
//The address that is authorized to vote in governance and validator elections on behalf of the
18
17
// account. The account can vote as well, whether or not an vote signing key has been specified.
19
18
address voting;
20
-
21
19
// The address that is authorized to manage a validator or validator group and sign consensus
22
20
// messages on behalf of the account. The account can manage the validator, whether or not an
23
21
// validation signing key has been specified. However if an validation signing key has been
24
22
// specified, only that key may actually participate in consensus.
25
23
address validating;
26
-
27
24
// The address of the key with which this account wants to sign attestations on the Attestations
28
25
// contract
29
26
address attesting;
@@ -35,17 +32,13 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
35
32
// These keys may not be keys of other accounts, and may not be authorized by any other
36
33
// account for any purpose.
37
34
Signers signers;
38
-
39
35
// The address at which the account expects to receive transfers. If it's empty/0x0, the
40
36
// account indicates that an address exchange should be initiated with the dataEncryptionKey
41
37
address walletAddress;
42
-
43
38
// An optional human readable identifier for the account
44
39
string name;
45
-
46
40
// The ECDSA public key used to encrypt and decrypt data for this account
47
41
bytes dataEncryptionKey;
48
-
49
42
// The URL under which an account adds metadata and claims
50
43
string metadataURL;
51
44
}
@@ -54,7 +47,6 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
54
47
// Maps voting and validating keys to the account that provided the authorization.
55
48
mapping (address => address ) public authorizedBy;
56
49
57
-
58
50
event AttestationSignerAuthorized (address indexed account , address signer );
59
51
event VoteSignerAuthorized (address indexed account , address signer );
60
52
event ValidationSignerAuthorized (address indexed account , address signer );
@@ -70,14 +62,10 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
70
62
* @param dataEncryptionKey secp256k1 public key for data encryption. Preferably compressed.
71
63
* @param walletAddress The wallet address to set for the account
72
64
*/
73
- function setAccount (
74
- string calldata name ,
75
- bytes calldata dataEncryptionKey ,
76
- address walletAddress
77
- )
65
+ function setAccount (string calldata name , bytes calldata dataEncryptionKey , address walletAddress )
78
66
external
79
67
{
80
- if (! isAccount (msg .sender )) {
68
+ if (! isAccount (msg .sender )) {
81
69
createAccount ();
82
70
}
83
71
setName (name);
@@ -103,15 +91,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
103
91
* @param s Output value s of the ECDSA signature.
104
92
* @dev v, r, s constitute `voter`'s signature on `msg.sender`.
105
93
*/
106
- function authorizeVoteSigner (
107
- address voter ,
108
- uint8 v ,
109
- bytes32 r ,
110
- bytes32 s
111
- )
112
- external
113
- nonReentrant
114
- {
94
+ function authorizeVoteSigner (address voter , uint8 v , bytes32 r , bytes32 s ) external nonReentrant {
115
95
Account storage account = accounts[msg .sender ];
116
96
authorize (voter, account.signers.voting, v, r, s);
117
97
account.signers.voting = voter;
@@ -126,12 +106,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
126
106
* @param s Output value s of the ECDSA signature.
127
107
* @dev v, r, s constitute `validator`'s signature on `msg.sender`.
128
108
*/
129
- function authorizeValidationSigner (
130
- address validator ,
131
- uint8 v ,
132
- bytes32 r ,
133
- bytes32 s
134
- )
109
+ function authorizeValidationSigner (address validator , uint8 v , bytes32 r , bytes32 s )
135
110
external
136
111
nonReentrant
137
112
{
@@ -179,11 +154,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
179
154
* @dev Fails if the `accountOrVoteSigner` is not an account or active authorized vote signer.
180
155
* @return The associated account.
181
156
*/
182
- function activeVoteSignerToAccount (address accountOrVoteSigner )
183
- external
184
- view
185
- returns (address )
186
- {
157
+ function activeVoteSignerToAccount (address accountOrVoteSigner ) external view returns (address ) {
187
158
address authorizingAccount = authorizedBy[accountOrVoteSigner];
188
159
if (authorizingAccount != address (0 )) {
189
160
require (accounts[authorizingAccount].signers.voting == accountOrVoteSigner);
@@ -228,7 +199,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
228
199
return accounts[account].metadataURL;
229
200
}
230
201
231
- /**
202
+ /**
232
203
* @notice Getter for the data encryption key and version.
233
204
* @param account The address of the account to get the key for
234
205
* @return dataEncryptionKey secp256k1 public key for data encryption. Preferably compressed.
@@ -296,14 +267,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
296
267
* @param s Output value s of the ECDSA signature.
297
268
* @dev v, r, s constitute `attestor`'s signature on `msg.sender`.
298
269
*/
299
- function authorizeAttestationSigner (
300
- address attestor ,
301
- uint8 v ,
302
- bytes32 r ,
303
- bytes32 s
304
- )
305
- public
306
- {
270
+ function authorizeAttestationSigner (address attestor , uint8 v , bytes32 r , bytes32 s ) public {
307
271
Account storage account = accounts[msg .sender ];
308
272
authorize (attestor, account.signers.attesting, v, r, s);
309
273
account.signers.attesting = attestor;
@@ -444,15 +408,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
444
408
* @dev Fails if the address is already authorized or is an account.
445
409
* @dev v, r, s constitute `current`'s signature on `msg.sender`.
446
410
*/
447
- function authorize (
448
- address current ,
449
- address previous ,
450
- uint8 v ,
451
- bytes32 r ,
452
- bytes32 s
453
- )
454
- private
455
- {
411
+ function authorize (address current , address previous , uint8 v , bytes32 r , bytes32 s ) private {
456
412
require (isAccount (msg .sender ) && isNotAccount (current) && isNotAuthorized (current));
457
413
458
414
address signer = Signatures.getSignerOfAddress (msg .sender , v, r, s);
@@ -461,4 +417,4 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
461
417
authorizedBy[previous] = address (0 );
462
418
authorizedBy[current] = msg .sender ;
463
419
}
464
- }
420
+ }
0 commit comments