Skip to content

Commit

Permalink
metadata rename
Browse files Browse the repository at this point in the history
  • Loading branch information
novaknole committed Oct 9, 2024
1 parent ba6dcf8 commit 4e5d291
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/contracts/src/MajorityVotingBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ abstract contract MajorityVotingBase is
_updateVotingSettings(_votingSettings);
_updateMinApprovals(_minApprovals);
_setTargetConfig(_targetConfig);
_updateMetadata(_pluginMetadata);
_setMetadata(_pluginMetadata);
}

/// @notice Checks if this or the parent contract supports an interface by its ID.
Expand Down
17 changes: 13 additions & 4 deletions packages/contracts/src/TokenVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ contract TokenVoting is IMembership, MajorityVotingBase {
uint256 _minApprovals,
bytes calldata _pluginMetadata
) external onlyCallAtInitialization reinitializer(2) {
__MajorityVotingBase_init(_dao, _votingSettings, _targetConfig, _minApprovals, _pluginMetadata);
__MajorityVotingBase_init(
_dao,
_votingSettings,
_targetConfig,
_minApprovals,
_pluginMetadata
);

votingToken = _token;

Expand All @@ -62,14 +68,17 @@ contract TokenVoting is IMembership, MajorityVotingBase {
/// @param _initData The initialization data to be passed to via `upgradeToAndCall` (see [ERC-1967](https://docs.openzeppelin.com/contracts/4.x/api/proxy#ERC1967Upgrade)).

Check failure on line 68 in packages/contracts/src/TokenVoting.sol

View workflow job for this annotation

GitHub Actions / checks

Line length must be no more than 120 but current length is 175

Check failure on line 68 in packages/contracts/src/TokenVoting.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 175

Check failure on line 68 in packages/contracts/src/TokenVoting.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 175
function initializeFrom(uint16 _fromBuild, bytes calldata _initData) external reinitializer(2) {
if (_fromBuild < 3) {
(uint256 minApprovals, TargetConfig memory targetConfig, bytes memory pluginMetadata) = abi
.decode(_initData, (uint256, TargetConfig, bytes));
(
uint256 minApprovals,
TargetConfig memory targetConfig,
bytes memory pluginMetadata
) = abi.decode(_initData, (uint256, TargetConfig, bytes));

_updateMinApprovals(minApprovals);

_setTargetConfig(targetConfig);

_updateMetadata(pluginMetadata);
_setMetadata(pluginMetadata);
}
}

Expand Down
16 changes: 8 additions & 8 deletions packages/contracts/src/TokenVotingSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {GovernanceWrappedERC20} from "./ERC20/governance/GovernanceWrappedERC20.

import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
import {PermissionLib} from "@aragon/osx-commons-contracts/src/permission/PermissionLib.sol";
import {PluginUUPSUpgradeable} from "@aragon/osx-commons-contracts/src/plugin/PluginUUPSUpgradeable.sol";
import {IPlugin} from "@aragon/osx-commons-contracts/src/plugin/IPlugin.sol";
import {IPluginSetup} from "@aragon/osx-commons-contracts/src/plugin/setup/IPluginSetup.sol";
import {PluginUpgradeableSetup} from "@aragon/osx-commons-contracts/src/plugin/setup/PluginUpgradeableSetup.sol";

Expand Down Expand Up @@ -44,8 +44,8 @@ contract TokenVotingSetup is PluginUpgradeableSetup {
bytes32 public constant SET_TARGET_CONFIG_PERMISSION_ID =
keccak256("SET_TARGET_CONFIG_PERMISSION");

/// @notice The ID of the permission required to call the `updateMetadata` function.
bytes32 public constant UPDATE_METADATA_PERMISSION_ID = keccak256("UPDATE_METADATA_PERMISSION");
/// @notice The ID of the permission required to call the `setMetadata` function.
bytes32 public constant SET_METADATA_PERMISSION_ID = keccak256("SET_METADATA_PERMISSION");

/// @notice The ID of the permission required to call the `upgradeToAndCall` function.
bytes32 internal constant UPGRADE_PLUGIN_PERMISSION_ID = keccak256("UPGRADE_PLUGIN_PERMISSION");
Expand Down Expand Up @@ -106,7 +106,7 @@ contract TokenVotingSetup is PluginUpgradeableSetup {
TokenSettings memory tokenSettings,
// only used for GovernanceERC20(token is not passed)
GovernanceERC20.MintSettings memory mintSettings,
PluginUUPSUpgradeable.TargetConfig memory targetConfig,
IPlugin.TargetConfig memory targetConfig,
uint256 minApprovals,
bytes memory pluginMetadata
) = abi.decode(
Expand All @@ -115,7 +115,7 @@ contract TokenVotingSetup is PluginUpgradeableSetup {
MajorityVotingBase.VotingSettings,
TokenSettings,
GovernanceERC20.MintSettings,
PluginUUPSUpgradeable.TargetConfig,
IPlugin.TargetConfig,
uint256,
bytes
)
Expand Down Expand Up @@ -219,7 +219,7 @@ contract TokenVotingSetup is PluginUpgradeableSetup {
where: plugin,
who: _dao,
condition: PermissionLib.NO_CONDITION,
permissionId: UPDATE_METADATA_PERMISSION_ID
permissionId: SET_METADATA_PERMISSION_ID
});

if (tokenSettings.addr == address(0)) {
Expand Down Expand Up @@ -283,7 +283,7 @@ contract TokenVotingSetup is PluginUpgradeableSetup {
where: _payload.plugin,
who: _dao,
condition: PermissionLib.NO_CONDITION,
permissionId: UPDATE_METADATA_PERMISSION_ID
permissionId: SET_METADATA_PERMISSION_ID
});

preparedSetupData.permissions = permissions;
Expand Down Expand Up @@ -332,7 +332,7 @@ contract TokenVotingSetup is PluginUpgradeableSetup {
where: _payload.plugin,
who: _dao,
condition: PermissionLib.NO_CONDITION,
permissionId: UPDATE_METADATA_PERMISSION_ID
permissionId: SET_METADATA_PERMISSION_ID
});

permissions[4] = PermissionLib.MultiTargetPermission({
Expand Down
14 changes: 7 additions & 7 deletions packages/contracts/test/10_unit-testing/12_plugin-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
MINT_PERMISSION_ID,
SET_TARGET_CONFIG_PERMISSION_ID,
TargetConfig,
UPDATE_METADATA_PERMISSION_ID,
SET_METADATA_PERMISSION_ID,
UPDATE_VOTING_SETTINGS_PERMISSION_ID,
} from '../test-utils/token-voting-constants';
import {Operation as Op} from '../test-utils/token-voting-constants';
Expand Down Expand Up @@ -435,7 +435,7 @@ describe('TokenVotingSetup', function () {
plugin,
dao.address,
AddressZero,
UPDATE_METADATA_PERMISSION_ID,
SET_METADATA_PERMISSION_ID,
],
]);
});
Expand Down Expand Up @@ -615,7 +615,7 @@ describe('TokenVotingSetup', function () {
plugin,
dao.address,
AddressZero,
UPDATE_METADATA_PERMISSION_ID,
SET_METADATA_PERMISSION_ID,
],
]);
});
Expand Down Expand Up @@ -699,7 +699,7 @@ describe('TokenVotingSetup', function () {
plugin,
dao.address,
AddressZero,
UPDATE_METADATA_PERMISSION_ID,
SET_METADATA_PERMISSION_ID,
],
[
Operation.Grant,
Expand Down Expand Up @@ -887,7 +887,7 @@ describe('TokenVotingSetup', function () {
plugin,
dao.address,
AddressZero,
UPDATE_METADATA_PERMISSION_ID,
SET_METADATA_PERMISSION_ID,
],
]);
});
Expand Down Expand Up @@ -972,7 +972,7 @@ describe('TokenVotingSetup', function () {
plugin,
dao.address,
AddressZero,
UPDATE_METADATA_PERMISSION_ID,
SET_METADATA_PERMISSION_ID,
],
]);
});
Expand Down Expand Up @@ -1071,7 +1071,7 @@ describe('TokenVotingSetup', function () {
plugin,
dao.address,
AddressZero,
UPDATE_METADATA_PERMISSION_ID,
SET_METADATA_PERMISSION_ID,
],
[
Operation.Revoke,
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/test/test-utils/token-voting-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const SET_TARGET_CONFIG_PERMISSION_ID = ethers.utils.id(
'SET_TARGET_CONFIG_PERMISSION'
);

export const UPDATE_METADATA_PERMISSION_ID = ethers.utils.id(
'UPDATE_METADATA_PERMISSION'
export const SET_METADATA_PERMISSION_ID = ethers.utils.id(
'SET_METADATA_PERMISSION'
);

export const VOTING_EVENTS = {
Expand Down

0 comments on commit 4e5d291

Please sign in to comment.