-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransferRequest.sol
More file actions
61 lines (43 loc) · 1.48 KB
/
TransferRequest.sol
File metadata and controls
61 lines (43 loc) · 1.48 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
pragma solidity ^0.4.23;
import './Request.sol';
contract TransferRequest is Request{
string public productId;
address public approver;
address public sender;
event TransferRequestCreated(string productId, address sender, address approver);
event Approved();
event NewApprover(address newApprover);
modifier notApproved{
require(!approved, "This has already been approved");
_;
}
modifier onlyApprover{
require(msg.sender == approver, "he is not the approver");
_;
}
constructor(uint _id, address _approver, string _productId, address _sender)public{
productId = _productId;
id = _id;
approver = _approver;
sender = _sender;
approved = false;
emit TransferRequestCreated( _productId, _sender, _approver);
}
function getProductId()public view returns(string){
return productId;
}
function getApprover()public view returns(address){
return approver;
}
function approve() onlyApprover notApproved public returns(bool){
require(!voted[msg.sender], "has already approved");
approved = true;
voted[msg.sender] = true;
emit Approved();
return approved;
}
function updateApprovers(address newApprover)public {
approver = newApprover;
emit NewApprover(newApprover);
}
}