forked from CMTA/CMTAT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseModule.sol
110 lines (95 loc) · 3.09 KB
/
BaseModule.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
//SPDX-License-Identifier: MPL-2.0
pragma solidity 0.8.17;
// required OZ imports here
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import "../../security/AuthorizationModule.sol";
import "../../../libraries/Errors.sol";
abstract contract BaseModule is AuthorizationModule {
/* Events */
event Term(string indexed newTermIndexed, string newTerm);
event TokenId(string indexed newTokenIdIndexed, string newTokenId);
event Information(
string indexed newInformationIndexed,
string newInformation
);
event Flag(uint256 indexed newFlag);
/* Variables */
string public tokenId;
string public terms;
string public information;
uint256 public flag;
/* Initializers */
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __Base_init(
string memory tokenId_,
string memory terms_,
string memory information_,
uint256 flag_,
address admin
) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
// AuthorizationModule inherits from AccessControlUpgradeable
__AccessControl_init_unchained();
/* CMTAT modules */
// Security
__AuthorizationModule_init_unchained(admin);
// own function
__Base_init_unchained(tokenId_, terms_, information_, flag_);
}
function __Base_init_unchained(
string memory tokenId_,
string memory terms_,
string memory information_,
uint256 flag_
) internal onlyInitializing {
tokenId = tokenId_;
terms = terms_;
information = information_;
flag = flag_;
}
/* Methods */
/*
@notice the tokenId will be changed even if the new value is the same as the current one
*/
function setTokenId(
string memory tokenId_
) public onlyRole(DEFAULT_ADMIN_ROLE) {
tokenId = tokenId_;
emit TokenId(tokenId_, tokenId_);
}
/*
@notice The terms will be changed even if the new value is the same as the current one
*/
function setTerms(
string memory terms_
) public onlyRole(DEFAULT_ADMIN_ROLE) {
terms = terms_;
emit Term(terms_, terms_);
}
/*
@notice The information will be changed even if the new value is the same as the current one
*/
function setInformation(
string memory information_
) public onlyRole(DEFAULT_ADMIN_ROLE) {
information = information_;
emit Information(information_, information_);
}
/*
@notice The call will be reverted if the new value of flag is the same as the current one
*/
function setFlag(uint256 flag_) public onlyRole(DEFAULT_ADMIN_ROLE) {
if (flag == flag_) revert Errors.SameValue();
flag = flag_;
emit Flag(flag_);
}
uint256[50] private __gap;
}