-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMockInitializable.sol
90 lines (68 loc) · 2.25 KB
/
MockInitializable.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
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.13;
import "../attribute/Initializable.sol";
contract MockInitializable is Initializable {
Uint256Storage private constant _version = Uint256Storage.wrap(keccak256("equilibria.root.UInitializable.version"));
event NoOp();
event NoOpChild();
function __version() external view returns (uint256) {
return _version.read();
}
function initialize() public initializer(1) {
emit NoOp();
}
function doubleInitialize() public initializer(1) {
initialize();
}
function initializeWithChildren() public initializer(1) {
childInitializer();
emit NoOp();
}
function childInitializer() public onlyInitializer {
emit NoOpChild();
}
function customInitializer(uint256 version) public initializer(version) {
emit NoOp();
}
}
contract MockUInitializableConstructor1 is MockInitializable {
constructor() {
childInitializer();
}
}
contract MockUInitializableConstructor3 is MockInitializable {
constructor() initializer(1) {
childInitializer();
}
}
contract MockUInitializableConstructor5 is MockUInitializableConstructor1 {
constructor() MockUInitializableConstructor1() { }
}
contract MockUInitializableConstructor6 is MockUInitializableConstructor1 {
constructor() MockUInitializableConstructor1() {
childInitializer6();
}
function childInitializer6() public onlyInitializer { }
}
contract MockUInitializableConstructor8 is MockUInitializableConstructor3 {
constructor() MockUInitializableConstructor3() { }
}
contract MockUInitializableMulti is Initializable {
Uint256Storage private constant _version = Uint256Storage.wrap(keccak256("equilibria.root.UInitializable.version"));
event NoOp(uint256 version);
function __version() external view returns (uint256) {
return _version.read();
}
function initialize1() public initializer(1) {
emit NoOp(1);
}
function initialize2() public initializer(2) {
emit NoOp(2);
}
function initialize17() public initializer(17) {
emit NoOp(17);
}
function initializeMax() public initializer(type(uint256).max) {
emit NoOp(type(uint256).max);
}
}