Skip to content

Commit 4f654c0

Browse files
committed
chore: cleaning up implementation
1 parent b2f2392 commit 4f654c0

File tree

7 files changed

+187
-167
lines changed

7 files changed

+187
-167
lines changed

packages/contracts/contracts/issuance/IIssuanceAllocator.sol

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ interface IIssuanceAllocator {
2828
/**
2929
* @notice Add a new allocation target with zero proportion.
3030
* @param _target Address of the target contract
31-
* @param _name Name of the target
3231
* @param _isSelfMinter Whether the target is a self-minting contract
3332
*
3433
* @dev The _isSelfMinter parameter should typically be set to false for new targets.
3534
* It should only be set to true for backwards compatibility with existing contracts
3635
* like the RewardsManager that already have minting capabilities.
3736
*/
38-
function addAllocationTarget(address _target, string calldata _name, bool _isSelfMinter) external;
37+
function addAllocationTarget(address _target, bool _isSelfMinter) external;
3938

4039
/**
4140
* @notice Remove an allocation target.

packages/horizon/contracts/issuance/DirectAllocation.sol

+17-20
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ pragma solidity 0.8.27;
44

55
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
66
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";
1010

1111
/**
1212
* @title DirectAllocation
@@ -16,46 +16,43 @@ import "./DirectAllocationStorage.sol";
1616
*
1717
* @dev This contract is designed to be a non-self-minting target in the IssuanceAllocator.
1818
* 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.
2020
*/
21-
contract DirectAllocation is Initializable, GraphUpgradeable, DirectAllocationStorage {
21+
contract DirectAllocation is Initializable, GraphUpgradeable, Governed, GraphDirectory, DirectAllocationStorage {
2222
// -- Custom Errors --
2323

24+
error OnlyImplementationCanInitialize();
25+
error ControllerCannotBeZeroAddress();
2426
error OnlyManagerCanSendTokens();
2527
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);
2833

2934
/**
3035
* @notice Constructor for the DirectAllocation contract
3136
* @dev This contract is upgradeable, but we use the constructor to disable initializers
3237
* 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.
3638
* @param _controller Controller contract that manages this contract
3739
*/
38-
constructor(address _controller) Managed(_controller) {
40+
constructor(address _controller) GraphDirectory(_controller) {
3941
_disableInitializers();
4042
}
4143

42-
// -- Events --
43-
44-
event ManagerSet(address indexed oldManager, address indexed newManager);
45-
event TokensSent(address indexed to, uint256 amount);
46-
4744
// -- Initialization --
4845

4946
/**
5047
* @notice Initialize the DirectAllocation contract
5148
* @param _controller Controller contract that manages this contract
52-
* @param _name Name of this allocation for identification
5349
* @param _manager Address that can withdraw funds
5450
*/
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();
5754

58-
name = _name;
55+
Governed._initialize(_graphController().getGovernor());
5956
manager = _manager;
6057
}
6158

packages/horizon/contracts/issuance/DirectAllocationStorage.sol

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
pragma solidity 0.8.27;
44

5-
import "../staking/utilities/Managed.sol";
6-
75
/**
86
* @title DirectAllocationStorage
97
* @notice Storage contract for DirectAllocation
108
* @dev This contract defines the storage layout for the DirectAllocation contract
119
*/
12-
abstract contract DirectAllocationStorage is Managed {
10+
abstract contract DirectAllocationStorage {
1311
// -- State --
1412

15-
// Name of this allocation for identification
16-
string public name;
17-
18-
// Address that can withdraw funds
13+
// Address that can send tokens
1914
address public manager;
15+
16+
// -- Storage Gap --
17+
18+
// Gap for future storage variables in upgrades
19+
uint256[50] private __gap;
2020
}

0 commit comments

Comments
 (0)