@@ -3,6 +3,8 @@ pragma solidity ^0.8.24;
3
3
4
4
import "forge-std/Test.sol " ;
5
5
6
+ import { GraphProxyAdmin } from "@graphprotocol/contracts/contracts/upgrades/GraphProxyAdmin.sol " ;
7
+ import { GraphProxy } from "@graphprotocol/contracts/contracts/upgrades/GraphProxy.sol " ;
6
8
import { Controller } from "@graphprotocol/contracts/contracts/governance/Controller.sol " ;
7
9
8
10
import { PaymentsEscrow } from "contracts/payments/PaymentsEscrow.sol " ;
@@ -18,6 +20,7 @@ abstract contract GraphBaseTest is Test, Constants {
18
20
19
21
/* Contracts */
20
22
23
+ GraphProxyAdmin public proxyAdmin;
21
24
Controller public controller;
22
25
MockGRTToken public token;
23
26
GraphPayments public payments;
@@ -41,6 +44,7 @@ abstract contract GraphBaseTest is Test, Constants {
41
44
42
45
function setUp () public virtual {
43
46
// Deploy ERC20 token
47
+ vm.prank (users.deployer);
44
48
token = new MockGRTToken ();
45
49
46
50
// Setup Users
@@ -68,10 +72,13 @@ abstract contract GraphBaseTest is Test, Constants {
68
72
69
73
function deployProtocolContracts () private {
70
74
vm.startPrank (users.governor);
75
+ proxyAdmin = new GraphProxyAdmin ();
71
76
controller = new Controller ();
72
- controller.setContractProxy (keccak256 ("GraphToken " ), address (token));
73
77
vm.stopPrank ();
74
78
79
+ // Staking Proxy
80
+ vm.prank (users.deployer);
81
+ GraphProxy stakingProxy = new GraphProxy (address (0 ), address (proxyAdmin));
75
82
76
83
// GraphPayments predict address
77
84
bytes32 saltPayments = keccak256 ("GraphPaymentsSalt " );
@@ -101,39 +108,16 @@ abstract contract GraphBaseTest is Test, Constants {
101
108
users.deployer
102
109
);
103
110
104
- // HorizonStakingExtension predict address
105
- bytes32 saltHorizonStakingExtension = keccak256 ("HorizonStakingExtensionSalt " );
106
- bytes32 horizonStakingExtensionHash = keccak256 (bytes .concat (
107
- vm.getCode ("HorizonStakingExtension.sol:HorizonStakingExtension " ),
108
- abi.encode (address (controller), subgraphDataServiceAddress)
109
- ));
110
- address predictedAddressHorizonStakingExtension = vm.computeCreate2Address (
111
- saltHorizonStakingExtension,
112
- horizonStakingExtensionHash,
113
- users.deployer
114
- );
115
-
116
- // HorizonStaking predict address
117
- bytes32 saltHorizonStaking = keccak256 ("saltHorizonStaking " );
118
- bytes32 horizonStakingHash = keccak256 (bytes .concat (
119
- vm.getCode ("HorizonStaking.sol:HorizonStaking " ),
120
- abi.encode (
121
- address (controller),
122
- predictedAddressHorizonStakingExtension,
123
- subgraphDataServiceAddress
124
- )
125
- ));
126
- address predictedAddressHorizonStaking = vm.computeCreate2Address (
127
- saltHorizonStaking,
128
- horizonStakingHash,
129
- users.deployer
130
- );
131
-
132
111
// Setup controller
133
112
vm.startPrank (users.governor);
134
- controller.setContractProxy (keccak256 ("GraphEscrow " ), predictedAddressEscrow);
113
+ controller.setContractProxy (keccak256 ("GraphToken " ), address (token));
114
+ controller.setContractProxy (keccak256 ("PaymentsEscrow " ), predictedAddressEscrow);
135
115
controller.setContractProxy (keccak256 ("GraphPayments " ), predictedPaymentsAddress);
136
- controller.setContractProxy (keccak256 ("Staking " ), address (predictedAddressHorizonStaking));
116
+ controller.setContractProxy (keccak256 ("Staking " ), address (stakingProxy));
117
+ controller.setContractProxy (keccak256 ("EpochManager " ), makeAddr ("EpochManager " ));
118
+ controller.setContractProxy (keccak256 ("RewardsManager " ), makeAddr ("RewardsManager " ));
119
+ controller.setContractProxy (keccak256 ("Curation " ), makeAddr ("Curation " ));
120
+ controller.setContractProxy (keccak256 ("GraphTokenGateway " ), makeAddr ("GraphTokenGateway " ));
137
121
vm.stopPrank ();
138
122
139
123
vm.startPrank (users.deployer);
@@ -146,16 +130,21 @@ abstract contract GraphBaseTest is Test, Constants {
146
130
revokeCollectorThawingPeriod,
147
131
withdrawEscrowThawingPeriod
148
132
);
149
- stakingExtension = new HorizonStakingExtension {salt: saltHorizonStakingExtension} (
133
+ stakingExtension = new HorizonStakingExtension (
150
134
address (controller),
151
135
subgraphDataServiceAddress
152
136
);
153
- stakingBase = new HorizonStaking {salt: saltHorizonStaking} (
137
+ stakingBase = new HorizonStaking (
154
138
address (controller),
155
139
address (stakingExtension),
156
140
subgraphDataServiceAddress
157
141
);
158
- staking = IHorizonStaking (address (stakingBase));
142
+ vm.stopPrank ();
143
+
144
+ vm.startPrank (users.governor);
145
+ proxyAdmin.upgrade (stakingProxy, address (stakingBase));
146
+ proxyAdmin.acceptProxy (stakingBase, stakingProxy);
147
+ staking = IHorizonStaking (address (stakingProxy));
159
148
vm.stopPrank ();
160
149
}
161
150
0 commit comments