-
Notifications
You must be signed in to change notification settings - Fork 99
/
LicenseBase.sol
108 lines (95 loc) · 2.62 KB
/
LicenseBase.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
pragma solidity ^0.4.19;
import "./LicenseAccessControl.sol";
/**
* @title LicenseBase
* @notice This contract defines the License data structure and how to read from it
*/
contract LicenseBase is LicenseAccessControl {
/**
* @notice Issued is emitted when a new license is issued
*/
event LicenseIssued(
address indexed owner,
address indexed purchaser,
uint256 licenseId,
uint256 productId,
uint256 attributes,
uint256 issuedTime,
uint256 expirationTime,
address affiliate
);
event LicenseRenewal(
address indexed owner,
address indexed purchaser,
uint256 licenseId,
uint256 productId,
uint256 expirationTime
);
struct License {
uint256 productId;
uint256 attributes;
uint256 issuedTime;
uint256 expirationTime;
address affiliate;
}
/**
* @notice All licenses in existence.
* @dev The ID of each license is an index in this array.
*/
License[] licenses;
/** internal **/
function _isValidLicense(uint256 _licenseId) internal view returns (bool) {
return licenseProductId(_licenseId) != 0;
}
/** anyone **/
/**
* @notice Get a license's productId
* @param _licenseId the license id
*/
function licenseProductId(uint256 _licenseId) public view returns (uint256) {
return licenses[_licenseId].productId;
}
/**
* @notice Get a license's attributes
* @param _licenseId the license id
*/
function licenseAttributes(uint256 _licenseId) public view returns (uint256) {
return licenses[_licenseId].attributes;
}
/**
* @notice Get a license's issueTime
* @param _licenseId the license id
*/
function licenseIssuedTime(uint256 _licenseId) public view returns (uint256) {
return licenses[_licenseId].issuedTime;
}
/**
* @notice Get a license's issueTime
* @param _licenseId the license id
*/
function licenseExpirationTime(uint256 _licenseId) public view returns (uint256) {
return licenses[_licenseId].expirationTime;
}
/**
* @notice Get a the affiliate credited for the sale of this license
* @param _licenseId the license id
*/
function licenseAffiliate(uint256 _licenseId) public view returns (address) {
return licenses[_licenseId].affiliate;
}
/**
* @notice Get a license's info
* @param _licenseId the license id
*/
function licenseInfo(uint256 _licenseId)
public view returns (uint256, uint256, uint256, uint256, address)
{
return (
licenseProductId(_licenseId),
licenseAttributes(_licenseId),
licenseIssuedTime(_licenseId),
licenseExpirationTime(_licenseId),
licenseAffiliate(_licenseId)
);
}
}