1
1
pragma solidity 0.4.19 ;
2
2
3
- contract Attestation {
3
+ contract Ownable {
4
+ address public owner;
5
+
6
+
7
+ event OwnershipTransferred (address indexed previousOwner , address indexed newOwner );
8
+
9
+ /**
10
+ * @dev The Ownable constructor sets the original `owner` of the contract to the sender
11
+ * account.
12
+ */
13
+ function Ownable () {
14
+ owner = msg .sender ;
15
+ }
16
+
17
+
18
+ /**
19
+ * @dev Throws if called by any account other than the owner.
20
+ */
21
+ modifier onlyOwner () {
22
+ require (msg .sender == owner);
23
+ _;
24
+ }
25
+
26
+
27
+ /**
28
+ * @dev Allows the current owner to transfer control of the contract to a newOwner.
29
+ * @param newOwner The address to transfer ownership to.
30
+ */
31
+ function transferOwnership (address newOwner ) onlyOwner public {
32
+ require (newOwner != address (0 ));
33
+ OwnershipTransferred (owner, newOwner);
34
+ owner = newOwner;
35
+ }
36
+
37
+ }
38
+
39
+ contract Attestation is Ownable {
4
40
5
41
enum Direction {Forwards, Backwards}
6
42
@@ -29,13 +65,13 @@ contract Attestation {
29
65
30
66
mapping (address => mapping (address => uint )) CompanyUsers;
31
67
32
- modifier onlyCompanyOwner (address _company_address ) {
33
- require (CompanyUsers[_company_address][msg . sender ] == 1 );
68
+ modifier onlyCompanyOwner (address _company_address , address _company_owner ) {
69
+ require (CompanyUsers[_company_address][_company_owner ] == 1 );
34
70
_;
35
71
}
36
72
37
- modifier onlyCompanyUser (address _company_address ) {
38
- require (CompanyUsers[_company_address][msg . sender ] != 0 );
73
+ modifier onlyCompanyUser (address _company_address , address _company_user ) {
74
+ require (CompanyUsers[_company_address][_company_user ] != 0 );
39
75
_;
40
76
}
41
77
@@ -44,43 +80,43 @@ contract Attestation {
44
80
_;
45
81
}
46
82
47
- function createUser (address _user_address ,bytes32 _data ) {
83
+ function createUserByOwner (address _user_address ,bytes32 _data ) onlyOwner {
48
84
require (! Users[_user_address].active);
49
85
UserDetails storage userDetails = Users[_user_address];
50
86
userDetails.active = true ;
51
87
userDetails.data = _data;
52
88
}
53
89
54
- function createCompany (bytes32 _data ,address _company_address ) {
90
+ function createCompanyByOwner (bytes32 _data ,address _company_address , address _company_owner ) onlyOwner {
55
91
require (! Company[_company_address].active);
56
92
/* create company */
57
93
CompanyDetails storage companyDetails = Company[_company_address];
58
94
companyDetails.active = true ;
59
- companyDetails.owner = msg . sender ;
95
+ companyDetails.owner = _company_owner ;
60
96
companyDetails.data = _data;
61
97
/* setting owner */
62
- CompanyUsers[_company_address][msg . sender ] = 1 ;
98
+ CompanyUsers[_company_address][_company_owner ] = 1 ;
63
99
}
64
100
65
- function editCompany (bytes32 _data ,address _company_address ) companyExist (_company_address) onlyCompanyOwner (_company_address) {
101
+ function editCompany (bytes32 _data ,address _company_address , address _company_owner ) companyExist (_company_address) onlyCompanyOwner (_company_address,_company_owner ) {
66
102
CompanyDetails storage companyDetails = Company[_company_address];
67
103
companyDetails.active = true ;
68
104
companyDetails.owner = msg .sender ;
69
105
companyDetails.data = _data;
70
106
}
71
107
72
- function attestByUser (address _company_address , bytes32 _connection_type , Direction _direction , uint256 _start , uint256 _end ) companyExist (_company_address){
108
+ function attestByUserByOwner (address _user_address , address _company_address , bytes32 _connection_type , Direction _direction , uint256 _start , uint256 _end ) onlyOwner companyExist (_company_address){
73
109
if (! Users[msg .sender ].active)
74
110
{
75
- createUser ( msg . sender ,bytes32 (0 ));
111
+ createUserByOwner (_user_address ,bytes32 (0 ));
76
112
}
77
113
upsertConnection (msg .sender ,_company_address,_connection_type,_direction,_start,_end);
78
114
}
79
115
80
- function attestByCompany (address _user_address ,address _company_address , bytes32 _connection_type , Direction _direction , uint256 _start , uint256 _end ) companyExist (_company_address) onlyCompanyUser (_company_address) {
116
+ function attestByCompanyByOwner (address _user_address ,address _company_address ,address _company_user , bytes32 _connection_type , Direction _direction , uint256 _start , uint256 _end ) onlyOwner companyExist (_company_address) onlyCompanyUser (_company_address,_company_user ) {
81
117
if (! Users[_user_address].active)
82
118
{
83
- createUser (_user_address,bytes32 (0 ));
119
+ createUserByOwner (_user_address,bytes32 (0 ));
84
120
}
85
121
upsertConnection (_user_address,_company_address,_connection_type,_direction,_start,_end);
86
122
}
@@ -94,13 +130,13 @@ contract Attestation {
94
130
connection.direction = _direction;
95
131
}
96
132
97
- function changeCompanyOwner (address _company_address ,address _new_owner_address ) companyExist (_company_address) onlyCompanyOwner (_company_address) {
133
+ function changeCompanyOwnerByOwner (address _company_address ,address _company_owner , address _new_owner_address ) onlyOwner companyExist (_company_address) onlyCompanyOwner (_company_address,_company_owner ) {
98
134
Company[_company_address].owner = _new_owner_address;
99
135
delete CompanyUsers[_company_address][msg .sender ];
100
136
CompanyUsers[_company_address][_new_owner_address] = 1 ;
101
137
}
102
138
103
- function addCompanyUser (address _company_address ,address _address ) companyExist (_company_address) onlyCompanyOwner (_company_address) {
139
+ function addCompanyUserByOwner (address _company_address ,address _company_owner , address _address ) onlyOwner companyExist (_company_address) onlyCompanyOwner (_company_address,_company_owner ) {
104
140
CompanyUsers[_company_address][_address] = 2 ;
105
141
}
106
142
0 commit comments