@@ -41,7 +41,7 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants {
41
41
RewardsManagerMock public rewardsManager;
42
42
CurationMock public curation;
43
43
TAPCollector tapCollector;
44
-
44
+
45
45
HorizonStaking private stakingBase;
46
46
HorizonStakingExtension private stakingExtension;
47
47
@@ -103,22 +103,34 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants {
103
103
GraphProxy stakingProxy = new GraphProxy (address (0 ), address (proxyAdmin));
104
104
105
105
// GraphPayments predict address
106
- bytes memory paymentsParameters = abi.encode (address (controller), protocolPaymentCut);
107
- bytes memory paymentsBytecode = abi.encodePacked (
106
+ bytes memory paymentsImplementationParameters = abi.encode (address (controller), protocolPaymentCut);
107
+ bytes memory paymentsImplementationBytecode = abi.encodePacked (
108
108
type (GraphPayments).creationCode,
109
- paymentsParameters
109
+ paymentsImplementationParameters
110
110
);
111
- address predictedPaymentsAddress = _computeAddress (
111
+ address predictedPaymentsImplementationAddress = _computeAddress (
112
112
"GraphPayments " ,
113
- paymentsBytecode ,
113
+ paymentsImplementationBytecode ,
114
114
users.deployer
115
115
);
116
-
117
- // PaymentsEscrow
118
- bytes memory escrowImplementationParameters = abi.encode (
119
- address (controller),
120
- withdrawEscrowThawingPeriod
116
+
117
+ bytes memory paymentsProxyParameters = abi.encode (
118
+ predictedPaymentsImplementationAddress,
119
+ users.governor,
120
+ abi.encodeCall (GraphPayments.initialize, ())
121
+ );
122
+ bytes memory paymentsProxyBytecode = abi.encodePacked (
123
+ type (TransparentUpgradeableProxy).creationCode,
124
+ paymentsProxyParameters
125
+ );
126
+ address predictedPaymentsProxyAddress = _computeAddress (
127
+ "TransparentUpgradeableProxy " ,
128
+ paymentsProxyBytecode,
129
+ users.deployer
121
130
);
131
+
132
+ // PaymentsEscrow
133
+ bytes memory escrowImplementationParameters = abi.encode (address (controller), withdrawEscrowThawingPeriod);
122
134
bytes memory escrowImplementationBytecode = abi.encodePacked (
123
135
type (PaymentsEscrow).creationCode,
124
136
escrowImplementationParameters
@@ -157,29 +169,32 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants {
157
169
resetPrank (users.governor);
158
170
controller.setContractProxy (keccak256 ("GraphToken " ), address (token));
159
171
controller.setContractProxy (keccak256 ("PaymentsEscrow " ), predictedEscrowProxyAddress);
160
- controller.setContractProxy (keccak256 ("GraphPayments " ), predictedPaymentsAddress );
172
+ controller.setContractProxy (keccak256 ("GraphPayments " ), predictedPaymentsProxyAddress );
161
173
controller.setContractProxy (keccak256 ("Staking " ), address (stakingProxy));
162
174
controller.setContractProxy (keccak256 ("EpochManager " ), address (epochManager));
163
175
controller.setContractProxy (keccak256 ("RewardsManager " ), address (rewardsManager));
164
176
controller.setContractProxy (keccak256 ("Curation " ), address (curation));
165
177
controller.setContractProxy (keccak256 ("GraphTokenGateway " ), graphTokenGatewayAddress);
166
178
controller.setContractProxy (keccak256 ("GraphProxyAdmin " ), address (proxyAdmin));
167
-
168
- resetPrank (users.deployer);
169
- address paymentsAddress = _deployContract ("GraphPayments " , paymentsBytecode);
170
- assertEq (paymentsAddress, predictedPaymentsAddress);
171
- payments = GraphPayments (paymentsAddress);
172
-
173
- address escrowImplementationAddress = _deployContract ("PaymentsEscrow " , escrowImplementationBytecode);
174
- address escrowProxyAddress = _deployContract ("TransparentUpgradeableProxy " , escrowProxyBytecode);
175
- assertEq (escrowImplementationAddress, predictedEscrowImplementationAddress);
176
- assertEq (escrowProxyAddress, predictedEscrowProxyAddress);
177
- escrow = PaymentsEscrow (escrowProxyAddress);
178
179
179
- stakingExtension = new HorizonStakingExtension (
180
- address (controller),
181
- subgraphDataServiceLegacyAddress
182
- );
180
+ resetPrank (users.deployer);
181
+ {
182
+ address paymentsImplementationAddress = _deployContract ("GraphPayments " , paymentsImplementationBytecode);
183
+ address paymentsProxyAddress = _deployContract ("TransparentUpgradeableProxy " , paymentsProxyBytecode);
184
+ assertEq (paymentsImplementationAddress, predictedPaymentsImplementationAddress);
185
+ assertEq (paymentsProxyAddress, predictedPaymentsProxyAddress);
186
+ payments = GraphPayments (paymentsProxyAddress);
187
+ }
188
+
189
+ {
190
+ address escrowImplementationAddress = _deployContract ("PaymentsEscrow " , escrowImplementationBytecode);
191
+ address escrowProxyAddress = _deployContract ("TransparentUpgradeableProxy " , escrowProxyBytecode);
192
+ assertEq (escrowImplementationAddress, predictedEscrowImplementationAddress);
193
+ assertEq (escrowProxyAddress, predictedEscrowProxyAddress);
194
+ escrow = PaymentsEscrow (escrowProxyAddress);
195
+ }
196
+
197
+ stakingExtension = new HorizonStakingExtension (address (controller), subgraphDataServiceLegacyAddress);
183
198
stakingBase = new HorizonStaking (
184
199
address (controller),
185
200
address (stakingExtension),
@@ -229,7 +244,11 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants {
229
244
* PRIVATE
230
245
*/
231
246
232
- function _computeAddress (string memory contractName , bytes memory bytecode , address deployer ) private pure returns (address ) {
247
+ function _computeAddress (
248
+ string memory contractName ,
249
+ bytes memory bytecode ,
250
+ address deployer
251
+ ) private pure returns (address ) {
233
252
bytes32 salt = keccak256 (abi.encodePacked (contractName, "Salt " ));
234
253
return Create2.computeAddress (salt, keccak256 (bytecode), deployer);
235
254
}
@@ -238,4 +257,4 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants {
238
257
bytes32 salt = keccak256 (abi.encodePacked (contractName, "Salt " ));
239
258
return Create2.deploy (0 , salt, bytecode);
240
259
}
241
- }
260
+ }
0 commit comments