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