-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDrillbitChain.sol
More file actions
73 lines (57 loc) · 2.05 KB
/
DrillbitChain.sol
File metadata and controls
73 lines (57 loc) · 2.05 KB
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
pragma solidity ^0.4.20;
contract WorkbenchBase {
event WorkbenchContractCreated(string applicationName, string workflowName, address originatingAddress);
event WorkbenchContractUpdated(string applicationName, string workflowName, string action, address originatingAddress);
string internal ApplicationName;
string internal WorkflowName;
function WorkbenchBase(string applicationName, string workflowName) internal {
ApplicationName = applicationName;
WorkflowName = workflowName;
}
function ContractCreated() internal {
WorkbenchContractCreated(ApplicationName, WorkflowName, msg.sender);
}
function ContractUpdated(string action) internal {
WorkbenchContractUpdated(ApplicationName, WorkflowName, action, msg.sender);
}
}
contract DrillbitChain is WorkbenchBase('DrillbitChain', 'DrillbitChain') {
//Set of States
enum StateType { Request, Respond, Initiated}
//List of properties
StateType public State;
address public PIC;
address public Engineer;
string public RequestMessage;
string public ResponseMessage;
// constructor function
function DrillbitChain(string message) public
{
PIC = msg.sender;
RequestMessage = message;
State = StateType.Request;
// call ContractCreated() to create an instance of this workflow
ContractCreated();
}
// call this function to send a request
function SendRequest(string requestMessage) public
{
if (PIC != msg.sender)
{
revert();
}
RequestMessage = requestMessage;
State = StateType.Request;
// call ContractUpdated() to record this action
ContractUpdated('SendRequest');
}
// call this function to send a response
function SendResponse(string responseMessage) public
{
Engineer = msg.sender;
// call ContractUpdated() to record this action
ResponseMessage = responseMessage;
State = StateType.Respond;
ContractUpdated('SendResponse');
}
}