/
labs_storage.sol
178 lines (135 loc) · 5.5 KB
/
labs_storage.sol
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
pragma solidity ^0.4.18;
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Grower is Ownable {
mapping(address => string) public data;
function Grower() public {
}
event Log(address indexed _address, string _data);
function storeValue(address _address, string _data) public onlyOwner returns (bool) {
require(_address != 0x0);
data[_address] = _data;
Log(_address, _data);
return true;
}
}
contract Lab is Ownable {
mapping(address => string) public data;
function Lab() public {
}
event Log(address indexed _address, string _data);
function storeValue(address _address, string _data) public onlyOwner returns (bool) {
require(_address != 0x0);
data[_address] = _data;
Log(_address, _data);
return true;
}
}
contract RawMaterial is Ownable {
mapping(bytes32 => string) public data;
function RawMaterial() public {
}
event Log(bytes32 indexed _uid, address indexed _address, string _data);
function storeValue(bytes32 _uid, address _growerAddress, string _data) public onlyOwner returns (bool) {
data[_uid] = _data;
Log(_uid, _growerAddress, _data);
return true;
}
}
contract Expertise is Ownable {
mapping(bytes32 => string) public data;
function Expertise() public {
}
event Log(bytes32 indexed _uid, bytes32 indexed _growerUid, address indexed _labAddress, string _data);
function storeValue(bytes32 _uid, bytes32 _growerUid, address _labAddress, string _data) public onlyOwner returns (bool) {
data[_uid] = _data;
Log(_uid, _growerUid, _labAddress, _data);
return true;
}
}
contract SupplyTracking is Ownable {
address public growerContract;
address public rawMaterialContract;
address public labContract;
address public expertiseContract;
bytes32 public growerContractVersion;
bytes32 public rawMaterialContractVersion;
bytes32 public labContractVersion;
bytes32 public expertiseContractVersion;
mapping(bytes32 => string) public expertises;
function SupplyTracking() public {
}
event ChangeGrowerContract(address indexed _address, bytes32 indexed _version);
event ChangeRawMaterialContract(address indexed _address, bytes32 indexed _version);
event ChangeLabContract(address indexed _address, bytes32 indexed _version);
event ChangeExpertiseContract(address indexed _address, bytes32 indexed _version);
//-------------------------------------------------------------------------------------------
function setGrowerConract(address _newAddress, bytes32 _version) public onlyOwner returns (bool) {
growerContract = _newAddress;
growerContractVersion = _version;
ChangeGrowerContract(_newAddress, _version);
return true;
}
function setGrower(address _address, string _data) public onlyOwner returns (bool) {
Grower c = Grower(growerContract);
return c.storeValue(_address, _data);
}
//-------------------------------------------------------------------------------------------
function setRawMaterialConract(address _newAddress, bytes32 _version) public onlyOwner returns (bool) {
rawMaterialContract = _newAddress;
rawMaterialContractVersion = _version;
ChangeRawMaterialContract(_newAddress, _version);
return true;
}
function setRawMaterial(bytes32 _uid, address _growerAddress, string _data) public onlyOwner returns (bool) {
RawMaterial c = RawMaterial(rawMaterialContract);
return c.storeValue(_uid, _growerAddress, _data);
}
//-------------------------------------------------------------------------------------------
function setLabConract(address _newAddress, bytes32 _version) public onlyOwner returns (bool) {
labContract = _newAddress;
labContractVersion = _version;
ChangeLabContract(_newAddress, _version);
return true;
}
function setLab(address _address, string _data) public onlyOwner returns (bool) {
Lab c = Lab(labContract);
return c.storeValue(_address, _data);
}
//-------------------------------------------------------------------------------------------
function setExpertisConract(address _newAddress, bytes32 _version) public onlyOwner returns (bool) {
expertiseContract = _newAddress;
expertiseContractVersion = _version;
ChangeExpertiseContract(_newAddress, _version);
return true;
}
function setExpertise(bytes32 _uid, bytes32 _growerUid, address _labAddress, string _data) public onlyOwner returns (bool) {
Expertise c = Expertise(expertiseContract);
return c.storeValue(_uid, _growerUid, _labAddress, _data);
}
}