Skip to content

Commit

Permalink
Rename "election eligibility" to "elections eligibility", and "regist…
Browse files Browse the repository at this point in the history
…ry" to "erc6551Registry"
  • Loading branch information
adamgall committed Oct 30, 2024
1 parent 971ba59 commit 302c147
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 47 deletions.
8 changes: 4 additions & 4 deletions contracts/DecentAutonomousAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.28;

import {IHats} from "./interfaces/hats/full/IHats.sol";
import {IHatsElectionEligibility} from "./interfaces/hats/full/IHatsElectionEligibility.sol";
import {IHatsElectionsEligibility} from "./interfaces/hats/full/modules/IHatsElectionsEligibility.sol";
import {FactoryFriendly} from "@gnosis.pm/zodiac/contracts/factory/FactoryFriendly.sol";
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IDecentAutonomousAdmin} from "./interfaces/IDecentAutonomousAdmin.sol";
Expand All @@ -26,9 +26,9 @@ contract DecentAutonomousAdmin is
false
) revert NotCurrentWearer();

IHatsElectionEligibility hatsElectionModule = IHatsElectionEligibility(
args.hatsProtocol.getHatEligibilityModule(args.hatId)
);
IHatsElectionsEligibility hatsElectionModule = IHatsElectionsEligibility(
args.hatsProtocol.getHatEligibilityModule(args.hatId)
);

hatsElectionModule.startNextTerm();

Expand Down
22 changes: 11 additions & 11 deletions contracts/DecentHatsCreationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {IERC6551Registry} from "./interfaces/IERC6551Registry.sol";
import {IHats} from "./interfaces/hats/full/IHats.sol";
import {LockupLinear, Broker} from "./interfaces/sablier/full/types/DataTypes.sol";
import {IHatsModuleFactory} from "./interfaces/hats/full/IHatsModuleFactory.sol";
import {IHatsElectionEligibility} from "./interfaces/hats/full/IHatsElectionEligibility.sol";
import {IHatsElectionsEligibility} from "./interfaces/hats/full/modules/IHatsElectionsEligibility.sol";
import {ModuleProxyFactory} from "@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol";
import {ISablierV2LockupLinear} from "./interfaces/sablier/ISablierV2LockupLinear.sol";

Expand Down Expand Up @@ -51,13 +51,13 @@ contract DecentHatsCreationModule {

struct CreateTreeParams {
IHats hatsProtocol;
IERC6551Registry registry;
IERC6551Registry erc6551Registry;
IHatsModuleFactory hatsModuleFactory;
ModuleProxyFactory moduleProxyFactory;
address keyValuePairs;
address decentAutonomousAdminMasterCopy;
address hatsAccountImplementation;
address keyValuePairs;
address hatsElectionEligibilityImplementation;
address hatsElectionsEligibilityImplementation;
TopHatParams topHat;
AdminHatParams adminHat;
HatParams[] hats;
Expand Down Expand Up @@ -87,7 +87,7 @@ contract DecentHatsCreationModule {
function createAndDeclareTree(CreateTreeParams calldata params) external {
IHats hatsProtocol = params.hatsProtocol;
address hatsAccountImplementation = params.hatsAccountImplementation;
IERC6551Registry registry = params.registry;
IERC6551Registry registry = params.erc6551Registry;

// Create Top Hat
(uint256 topHatId, address topHatAccount) = processTopHat(
Expand Down Expand Up @@ -119,7 +119,7 @@ contract DecentHatsCreationModule {
topHatId,
topHatAccount,
params.hatsModuleFactory,
params.hatsElectionEligibilityImplementation,
params.hatsElectionsEligibilityImplementation,
adminHatId,
hat
);
Expand Down Expand Up @@ -232,15 +232,15 @@ contract DecentHatsCreationModule {
uint256 topHatId,
address topHatAccount,
IHatsModuleFactory hatsModuleFactory,
address hatsElectionEligibilityImplementation,
address hatsElectionsEligibilityImplementation,
uint256 adminHatId,
HatParams memory hat
) internal {
// Create eligibility module if needed
address eligibilityAddress = createEligibilityModule(
hatsProtocol,
hatsModuleFactory,
hatsElectionEligibilityImplementation,
hatsElectionsEligibilityImplementation,
topHatId,
topHatAccount,
adminHatId,
Expand Down Expand Up @@ -274,7 +274,7 @@ contract DecentHatsCreationModule {
function createEligibilityModule(
IHats hatsProtocol,
IHatsModuleFactory hatsModuleFactory,
address hatsElectionEligibilityImplementation,
address hatsElectionsEligibilityImplementation,
uint256 topHatId,
address topHatAccount,
uint256 adminHatId,
Expand All @@ -283,7 +283,7 @@ contract DecentHatsCreationModule {
if (termEndDateTs != 0) {
return
hatsModuleFactory.createHatsModule(
hatsElectionEligibilityImplementation,
hatsElectionsEligibilityImplementation,
hatsProtocol.getNextId(adminHatId),
abi.encode(topHatId, uint256(0)), // [BALLOT_BOX_ID, ADMIN_HAT_ID]
abi.encode(termEndDateTs),
Expand Down Expand Up @@ -315,7 +315,7 @@ contract DecentHatsCreationModule {
if (hat.termEndDateTs != 0) {
address[] memory nominatedWearers = new address[](1);
nominatedWearers[0] = hat.wearer;
IHatsElectionEligibility(eligibilityAddress).elect(
IHatsElectionsEligibility(eligibilityAddress).elect(
hat.termEndDateTs,
nominatedWearers
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

interface IHatsElectionEligibility {
interface IHatsElectionsEligibility {
event ElectionOpened(uint128 nextTermEnd);
event ElectionCompleted(uint128 termEnd, address[] winners);
event NewTermStarted(uint128 termEnd);
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/MockHatsElectionEligibility.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import {IHatsElectionEligibility} from "../interfaces/hats/full/IHatsElectionEligibility.sol";
import {IHatsElectionsEligibility} from "../interfaces/hats/full/modules/IHatsElectionsEligibility.sol";

contract MockHatsElectionEligibility is IHatsElectionEligibility {
contract MockHatsElectionsEligibility is IHatsElectionsEligibility {
function currentTermEnd() external view returns (uint128) {}

function nextTermEnd() external view returns (uint128) {}
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/MockHatsModuleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.19;

import {IHatsModuleFactory} from "../interfaces/hats/full/IHatsModuleFactory.sol";
import {MockHatsElectionEligibility} from "./MockHatsElectionEligibility.sol";
import {MockHatsElectionsEligibility} from "./MockHatsElectionEligibility.sol";

contract MockHatsModuleFactory is IHatsModuleFactory {
function createHatsModule(
Expand All @@ -13,7 +13,7 @@ contract MockHatsModuleFactory is IHatsModuleFactory {
uint256
) external override returns (address _instance) {
// Deploy a new instance of MockHatsElectionEligibility
MockHatsElectionEligibility newModule = new MockHatsElectionEligibility();
MockHatsElectionsEligibility newModule = new MockHatsElectionsEligibility();
_instance = address(newModule);
}

Expand Down
8 changes: 4 additions & 4 deletions test/DecentAutonomousAdmin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
DecentAutonomousAdmin__factory,
MockHats,
MockHats__factory,
MockHatsElectionEligibility,
MockHatsElectionEligibility__factory,
MockHatsElectionsEligibility,
MockHatsElectionsEligibility__factory,
} from '../typechain-types';

describe('DecentAutonomousAdminHat', function () {
Expand All @@ -19,7 +19,7 @@ describe('DecentAutonomousAdminHat', function () {

// Contract instances
let hatsProtocol: MockHats;
let hatsElectionModule: MockHatsElectionEligibility;
let hatsElectionModule: MockHatsElectionsEligibility;
let decentAutonomousAdminInstance: DecentAutonomousAdmin;

// Variables
Expand All @@ -33,7 +33,7 @@ describe('DecentAutonomousAdminHat', function () {
hatsProtocol = await new MockHats__factory(deployer).deploy();

// Deploy MockHatsElectionEligibility (Eligibility Module)
hatsElectionModule = await new MockHatsElectionEligibility__factory(deployer).deploy();
hatsElectionModule = await new MockHatsElectionsEligibility__factory(deployer).deploy();

// Create Admin Hat
const createAdminTx = await hatsProtocol.createHat(
Expand Down
45 changes: 22 additions & 23 deletions test/DecentHatsCreationModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
MockERC20,
DecentAutonomousAdmin,
DecentAutonomousAdmin__factory,
MockHatsElectionEligibility__factory,
MockHatsElectionsEligibility__factory,
MockHatsModuleFactory__factory,
ModuleProxyFactory,
ModuleProxyFactory__factory,
Expand All @@ -32,7 +32,7 @@ import {
import { getGnosisSafeL2Singleton, getGnosisSafeProxyFactory } from './GlobalSafeDeployments.test';
import { executeSafeTransaction, getHatAccount, predictGnosisSafeAddress } from './helpers';

describe('DecentHats', () => {
describe('DecentHatsCreationModule', () => {
let dao: SignerWithAddress;

let mockHats: MockHats;
Expand All @@ -56,7 +56,7 @@ describe('DecentHats', () => {
let mockERC20: MockERC20;
let mockERC20Address: string;

let mockHatsElectionEligibilityImplementationAddress: string;
let mockHatsElectionsEligibilityImplementationAddress: string;
let mockHatsModuleFactoryAddress: string;

let moduleProxyFactory: ModuleProxyFactory;
Expand All @@ -70,10 +70,10 @@ describe('DecentHats', () => {
mockHats = await new MockHats__factory(deployer).deploy();
mockHatsAddress = await mockHats.getAddress();

const mockHatsElectionEligibilityImplementation =
await new MockHatsElectionEligibility__factory(deployer).deploy();
mockHatsElectionEligibilityImplementationAddress =
await mockHatsElectionEligibilityImplementation.getAddress();
const mockHatsElectionsEligibilityImplementation =
await new MockHatsElectionsEligibility__factory(deployer).deploy();
mockHatsElectionsEligibilityImplementationAddress =
await mockHatsElectionsEligibilityImplementation.getAddress();

const mockHatsModuleFactory = await new MockHatsModuleFactory__factory(deployer).deploy();
mockHatsModuleFactoryAddress = await mockHatsModuleFactory.getAddress();
Expand Down Expand Up @@ -172,15 +172,14 @@ describe('DecentHats', () => {
[
{
hatsProtocol: mockHatsAddress,
registry: await erc6551Registry.getAddress(),
erc6551Registry: await erc6551Registry.getAddress(),
hatsModuleFactory: mockHatsModuleFactoryAddress,
moduleProxyFactory: await moduleProxyFactory.getAddress(),
decentAutonomousAdminMasterCopy: await decentAutonomousAdminMasterCopy.getAddress(),
hatsAccountImplementation: mockHatsAccountImplementationAddress,
keyValuePairs: await keyValuePairs.getAddress(),
hatsElectionEligibilityImplementation:
mockHatsElectionEligibilityImplementationAddress,

hatsElectionsEligibilityImplementation:
mockHatsElectionsEligibilityImplementationAddress,
topHat: {
details: '',
imageURI: '',
Expand Down Expand Up @@ -246,7 +245,7 @@ describe('DecentHats', () => {
{
hatsProtocol: mockHatsAddress,
hatsAccountImplementation: mockHatsAccountImplementationAddress,
registry: await erc6551Registry.getAddress(),
erc6551Registry: await erc6551Registry.getAddress(),
keyValuePairs: await keyValuePairs.getAddress(),
topHat: {
details: '',
Expand All @@ -262,8 +261,8 @@ describe('DecentHats', () => {
},
hats: [],
hatsModuleFactory: mockHatsModuleFactoryAddress,
hatsElectionEligibilityImplementation:
mockHatsElectionEligibilityImplementationAddress,
hatsElectionsEligibilityImplementation:
mockHatsElectionsEligibilityImplementationAddress,
},
],
),
Expand Down Expand Up @@ -317,7 +316,7 @@ describe('DecentHats', () => {
{
hatsProtocol: mockHatsAddress,
hatsAccountImplementation: mockHatsAccountImplementationAddress,
registry: await erc6551Registry.getAddress(),
erc6551Registry: await erc6551Registry.getAddress(),
keyValuePairs: await keyValuePairs.getAddress(),
topHat: {
details: '',
Expand Down Expand Up @@ -351,8 +350,8 @@ describe('DecentHats', () => {
},
],
hatsModuleFactory: mockHatsModuleFactoryAddress,
hatsElectionEligibilityImplementation:
mockHatsElectionEligibilityImplementationAddress,
hatsElectionsEligibilityImplementation:
mockHatsElectionsEligibilityImplementationAddress,
},
],
),
Expand Down Expand Up @@ -393,7 +392,7 @@ describe('DecentHats', () => {
{
hatsProtocol: mockHatsAddress,
hatsAccountImplementation: mockHatsAccountImplementationAddress,
registry: await erc6551Registry.getAddress(),
erc6551Registry: await erc6551Registry.getAddress(),
keyValuePairs: await keyValuePairs.getAddress(),
topHat: {
details: '',
Expand Down Expand Up @@ -442,8 +441,8 @@ describe('DecentHats', () => {
},
],
hatsModuleFactory: mockHatsModuleFactoryAddress,
hatsElectionEligibilityImplementation:
mockHatsElectionEligibilityImplementationAddress,
hatsElectionsEligibilityImplementation:
mockHatsElectionsEligibilityImplementationAddress,
},
],
),
Expand Down Expand Up @@ -515,7 +514,7 @@ describe('DecentHats', () => {
{
hatsProtocol: mockHatsAddress,
hatsAccountImplementation: mockHatsAccountImplementationAddress,
registry: await erc6551Registry.getAddress(),
erc6551Registry: await erc6551Registry.getAddress(),
keyValuePairs: await keyValuePairs.getAddress(),
topHat: {
details: '',
Expand Down Expand Up @@ -569,8 +568,8 @@ describe('DecentHats', () => {
},
],
hatsModuleFactory: mockHatsModuleFactoryAddress,
hatsElectionEligibilityImplementation:
mockHatsElectionEligibilityImplementationAddress,
hatsElectionsEligibilityImplementation:
mockHatsElectionsEligibilityImplementationAddress,
},
],
),
Expand Down

0 comments on commit 302c147

Please sign in to comment.