@@ -4,9 +4,9 @@ pragma solidity 0.8.27;
4
4
5
5
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol " ;
6
6
import { GraphUpgradeable } from "@graphprotocol/contracts/contracts/upgrades/GraphUpgradeable.sol " ;
7
- import " ../staking/utilities/Managed .sol " ;
8
- import { IGraphToken } from "@graphprotocol/contracts/contracts/token/IGraphToken .sol " ;
9
- import "./DirectAllocationStorage.sol " ;
7
+ import { Governed } from " @graphprotocol/contracts/contracts/governance/Governed .sol " ;
8
+ import { GraphDirectory } from "../utilities/GraphDirectory .sol " ;
9
+ import { DirectAllocationStorage } from "./DirectAllocationStorage.sol " ;
10
10
11
11
/**
12
12
* @title DirectAllocation
@@ -16,46 +16,43 @@ import "./DirectAllocationStorage.sol";
16
16
*
17
17
* @dev This contract is designed to be a non-self-minting target in the IssuanceAllocator.
18
18
* The IssuanceAllocator will mint tokens directly to this contract, and the authorized
19
- * manager can withdraw them as needed.
19
+ * manager can send them to individual addresses as needed.
20
20
*/
21
- contract DirectAllocation is Initializable , GraphUpgradeable , DirectAllocationStorage {
21
+ contract DirectAllocation is Initializable , GraphUpgradeable , Governed , GraphDirectory , DirectAllocationStorage {
22
22
// -- Custom Errors --
23
23
24
+ error OnlyImplementationCanInitialize ();
25
+ error ControllerCannotBeZeroAddress ();
24
26
error OnlyManagerCanSendTokens ();
25
27
error SendToZeroAddressNotAllowed ();
26
- error OnlyImplementationCanInitialize ();
27
- error ControllerMismatch ();
28
+
29
+ // -- Events --
30
+
31
+ event ManagerSet (address indexed oldManager , address indexed newManager );
32
+ event TokensSent (address indexed to , uint256 amount );
28
33
29
34
/**
30
35
* @notice Constructor for the DirectAllocation contract
31
36
* @dev This contract is upgradeable, but we use the constructor to disable initializers
32
37
* to prevent the implementation contract from being initialized.
33
- * @dev We need to pass a valid controller address to the Managed constructor because
34
- * GraphDirectory requires a non-zero controller address. This controller will only be
35
- * used for the implementation contract, not for the proxy.
36
38
* @param _controller Controller contract that manages this contract
37
39
*/
38
- constructor (address _controller ) Managed (_controller) {
40
+ constructor (address _controller ) GraphDirectory (_controller) {
39
41
_disableInitializers ();
40
42
}
41
43
42
- // -- Events --
43
-
44
- event ManagerSet (address indexed oldManager , address indexed newManager );
45
- event TokensSent (address indexed to , uint256 amount );
46
-
47
44
// -- Initialization --
48
45
49
46
/**
50
47
* @notice Initialize the DirectAllocation contract
51
48
* @param _controller Controller contract that manages this contract
52
- * @param _name Name of this allocation for identification
53
49
* @param _manager Address that can withdraw funds
54
50
*/
55
- function initialize (address _controller , string calldata _name , address _manager ) external onlyImpl initializer {
56
- if (_controller != address (_graphController ())) revert ControllerMismatch ();
51
+ function initialize (address _controller , address _manager ) external initializer {
52
+ if (msg .sender != _implementation ()) revert OnlyImplementationCanInitialize ();
53
+ if (_controller == address (0 )) revert ControllerCannotBeZeroAddress ();
57
54
58
- name = _name ;
55
+ Governed. _initialize ( _graphController (). getGovernor ()) ;
59
56
manager = _manager;
60
57
}
61
58
0 commit comments