@@ -5,6 +5,7 @@ import "../upgradeability/AdminUpgradeabilityProxy.sol";
5
5
import "../upgradeability/UpgradeabilityProxyFactory.sol " ;
6
6
import "openzeppelin-solidity/contracts/ownership/Ownable.sol " ;
7
7
8
+
8
9
/**
9
10
* @title BaseApp
10
11
* @dev Abstract base contract for upgradeable applications.
@@ -23,18 +24,14 @@ contract BaseApp is Ownable {
23
24
factory = _factory;
24
25
}
25
26
26
- /**
27
- * @dev Abstract function to return the implementation provider.
28
- * @return The implementation provider.
29
- */
30
- function getProvider () internal view returns (ImplementationProvider);
31
-
32
27
/**
33
28
* @dev Returns the implementation address for a given contract name, provided by the `ImplementationProvider`.
34
29
* @param contractName Name of the contract.
35
30
* @return Address where the contract is implemented.
36
31
*/
37
- function getImplementation (string contractName ) public view returns (address ) {
32
+ function getImplementation (string contractName )
33
+ public view returns (address )
34
+ {
38
35
return getProvider ().getImplementation (contractName);
39
36
}
40
37
@@ -43,7 +40,10 @@ contract BaseApp is Ownable {
43
40
* @param contractName Name of the contract.
44
41
* @return Address of the new proxy.
45
42
*/
46
- function create (string contractName ) public returns (AdminUpgradeabilityProxy) {
43
+ function create (string contractName )
44
+ public
45
+ returns (AdminUpgradeabilityProxy)
46
+ {
47
47
address implementation = getImplementation (contractName);
48
48
return factory.createProxy (this , implementation);
49
49
}
@@ -58,17 +58,31 @@ contract BaseApp is Ownable {
58
58
* https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding.
59
59
* @return Address of the new proxy.
60
60
*/
61
- function createAndCall (string contractName , bytes data ) payable public returns (AdminUpgradeabilityProxy) {
61
+ function createAndCall (
62
+ string contractName ,
63
+ bytes data
64
+ )
65
+ payable
66
+ public
67
+ returns (AdminUpgradeabilityProxy)
68
+ {
62
69
address implementation = getImplementation (contractName);
63
- return factory.createProxyAndCall.value (msg .value )(this , implementation, data);
70
+ return factory.createProxyAndCall.value (
71
+ msg .value )(this , implementation, data);
64
72
}
65
73
66
74
/**
67
75
* @dev Upgrades a proxy to the newest implementation of a contract.
68
76
* @param proxy Proxy to be upgraded.
69
77
* @param contractName Name of the contract.
70
78
*/
71
- function upgrade (AdminUpgradeabilityProxy proxy , string contractName ) public onlyOwner {
79
+ function upgrade (
80
+ AdminUpgradeabilityProxy proxy ,
81
+ string contractName
82
+ )
83
+ public
84
+ onlyOwner
85
+ {
72
86
address implementation = getImplementation (contractName);
73
87
proxy.upgradeTo (implementation);
74
88
}
@@ -83,7 +97,15 @@ contract BaseApp is Ownable {
83
97
* called, as described in
84
98
* https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding.
85
99
*/
86
- function upgradeAndCall (AdminUpgradeabilityProxy proxy , string contractName , bytes data ) payable public onlyOwner {
100
+ function upgradeAndCall (
101
+ AdminUpgradeabilityProxy proxy ,
102
+ string contractName ,
103
+ bytes data
104
+ )
105
+ payable
106
+ public
107
+ onlyOwner
108
+ {
87
109
address implementation = getImplementation (contractName);
88
110
proxy.upgradeToAndCall.value (msg .value )(implementation, data);
89
111
}
@@ -93,7 +115,9 @@ contract BaseApp is Ownable {
93
115
* This is needed because only the proxy admin can query it.
94
116
* @return The address of the current implementation of the proxy.
95
117
*/
96
- function getProxyImplementation (AdminUpgradeabilityProxy proxy ) public view returns (address ) {
118
+ function getProxyImplementation (AdminUpgradeabilityProxy proxy )
119
+ public view returns (address )
120
+ {
97
121
return proxy.implementation ();
98
122
}
99
123
@@ -102,7 +126,16 @@ contract BaseApp is Ownable {
102
126
* Only the admin can query it.
103
127
* @return The address of the current admin of the proxy.
104
128
*/
105
- function getProxyAdmin (AdminUpgradeabilityProxy proxy ) public view returns (address ) {
129
+ function getProxyAdmin (AdminUpgradeabilityProxy proxy )
130
+ public view returns (address )
131
+ {
106
132
return proxy.admin ();
107
133
}
134
+
135
+ /**
136
+ * @dev Abstract function to return the implementation provider.
137
+ * @return The implementation provider.
138
+ */
139
+ function getProvider () internal view returns (ImplementationProvider);
140
+
108
141
}
0 commit comments