From 7f3a9b2789f00e22babab33c18dcbe17d476e18b Mon Sep 17 00:00:00 2001 From: dd0sxx Date: Sat, 9 Dec 2023 14:37:27 -0500 Subject: [PATCH] compiling --- script/DeployLlamaTokenVotingFactory.s.sol | 40 +- .../ERC20TokenholderActionCreator.sol | 6 +- src/token-voting/ERC20TokenholderCaster.sol | 6 +- .../ERC721TokenholderActionCreator.sol | 6 +- src/token-voting/ERC721TokenholderCaster.sol | 6 +- src/token-voting/LlamaTokenVotingFactory.sol | 59 +-- src/token-voting/TokenholderActionCreator.sol | 2 +- src/token-voting/TokenholderCaster.sol | 29 +- .../ERC20TokenholderActionCreator.t.sol | 138 +++--- .../token-voting/ERC20TokenholderCaster.t.sol | 425 +++++++++--------- .../ERC721TokenholderActionCreator.t.sol | 140 +++--- .../ERC721TokenholderCaster.t.sol | 372 ++++++++------- .../LlamaTokenVotingFactory.t.sol | 102 +++-- .../LlamaTokenVotingTestSetup.sol | 34 +- test/utils/LlamaCoreSigUtils.sol | 60 +-- 15 files changed, 692 insertions(+), 733 deletions(-) diff --git a/script/DeployLlamaTokenVotingFactory.s.sol b/script/DeployLlamaTokenVotingFactory.s.sol index bd28a24..4942f6d 100644 --- a/script/DeployLlamaTokenVotingFactory.s.sol +++ b/script/DeployLlamaTokenVotingFactory.s.sol @@ -4,18 +4,18 @@ pragma solidity 0.8.23; import {Script} from "forge-std/Script.sol"; import {DeployUtils} from "script/DeployUtils.sol"; -import {ERC20TokenholderActionCreator} from "src/token-voting/ERC20TokenholderActionCreator.sol"; -import {ERC20TokenholderCaster} from "src/token-voting/ERC20TokenholderCaster.sol"; -import {ERC721TokenholderActionCreator} from "src/token-voting/ERC721TokenholderActionCreator.sol"; -import {ERC721TokenholderCaster} from "src/token-voting/ERC721TokenholderCaster.sol"; +import {ERC20TokenHolderActionCreator} from "src/token-voting/ERC20TokenHolderActionCreator.sol"; +import {ERC20TokenHolderCaster} from "src/token-voting/ERC20TokenHolderCaster.sol"; +import {ERC721TokenHolderActionCreator} from "src/token-voting/ERC721TokenHolderActionCreator.sol"; +import {ERC721TokenHolderCaster} from "src/token-voting/ERC721TokenHolderCaster.sol"; import {LlamaTokenVotingFactory} from "src/token-voting/LlamaTokenVotingFactory.sol"; contract DeployLlamaTokenVotingFactory is Script { // Logic contracts. - ERC20TokenholderActionCreator erc20TokenholderActionCreatorLogic; - ERC20TokenholderCaster erc20TokenholderCasterLogic; - ERC721TokenholderActionCreator erc721TokenholderActionCreatorLogic; - ERC721TokenholderCaster erc721TokenholderCasterLogic; + ERC20TokenHolderActionCreator erc20TokenHolderActionCreatorLogic; + ERC20TokenHolderCaster erc20TokenHolderCasterLogic; + ERC721TokenHolderActionCreator erc721TokenHolderActionCreatorLogic; + ERC721TokenHolderCaster erc721TokenHolderCasterLogic; // Factory contracts. LlamaTokenVotingFactory tokenVotingFactory; @@ -26,37 +26,37 @@ contract DeployLlamaTokenVotingFactory is Script { ); vm.broadcast(); - erc20TokenholderActionCreatorLogic = new ERC20TokenholderActionCreator(); + erc20TokenHolderActionCreatorLogic = new ERC20TokenHolderActionCreator(); DeployUtils.print( - string.concat(" ERC20TokenholderActionCreatorLogic: ", vm.toString(address(erc20TokenholderActionCreatorLogic))) + string.concat(" ERC20TokenHolderActionCreatorLogic: ", vm.toString(address(erc20TokenHolderActionCreatorLogic))) ); vm.broadcast(); - erc20TokenholderCasterLogic = new ERC20TokenholderCaster(); + erc20TokenHolderCasterLogic = new ERC20TokenHolderCaster(); DeployUtils.print( - string.concat(" ERC20TokenholderCasterLogic: ", vm.toString(address(erc20TokenholderCasterLogic))) + string.concat(" ERC20TokenHolderCasterLogic: ", vm.toString(address(erc20TokenHolderCasterLogic))) ); vm.broadcast(); - erc721TokenholderActionCreatorLogic = new ERC721TokenholderActionCreator(); + erc721TokenHolderActionCreatorLogic = new ERC721TokenHolderActionCreator(); DeployUtils.print( string.concat( - " ERC721TokenholderActionCreatorLogic: ", vm.toString(address(erc721TokenholderActionCreatorLogic)) + " ERC721TokenHolderActionCreatorLogic: ", vm.toString(address(erc721TokenHolderActionCreatorLogic)) ) ); vm.broadcast(); - erc721TokenholderCasterLogic = new ERC721TokenholderCaster(); + erc721TokenHolderCasterLogic = new ERC721TokenHolderCaster(); DeployUtils.print( - string.concat(" ERC721TokenholderCasterLogic: ", vm.toString(address(erc721TokenholderCasterLogic))) + string.concat(" ERC721TokenHolderCasterLogic: ", vm.toString(address(erc721TokenHolderCasterLogic))) ); vm.broadcast(); tokenVotingFactory = new LlamaTokenVotingFactory( - erc20TokenholderActionCreatorLogic, - erc20TokenholderCasterLogic, - erc721TokenholderActionCreatorLogic, - erc721TokenholderCasterLogic + erc20TokenHolderActionCreatorLogic, + erc20TokenHolderCasterLogic, + erc721TokenHolderActionCreatorLogic, + erc721TokenHolderCasterLogic ); DeployUtils.print(string.concat(" LlamaTokenVotingFactory: ", vm.toString(address(tokenVotingFactory)))); } diff --git a/src/token-voting/ERC20TokenholderActionCreator.sol b/src/token-voting/ERC20TokenholderActionCreator.sol index bef4931..b7c77da 100644 --- a/src/token-voting/ERC20TokenholderActionCreator.sol +++ b/src/token-voting/ERC20TokenholderActionCreator.sol @@ -9,7 +9,7 @@ import {ERC20Votes} from "@openzeppelin/token/ERC20/extensions/ERC20Votes.sol"; /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a specified `ERC20Votes` token create actions on a llama instance if their /// token balance is greater than or equal to the creation threshold. -contract ERC20TokenholderActionCreator is TokenholderActionCreator { +contract ERC20TokenHolderActionCreator is TokenHolderActionCreator { ERC20Votes public token; /// @dev This contract is deployed as a minimal proxy from the factory's `deployTokenVotingModule` function. The @@ -18,7 +18,7 @@ contract ERC20TokenholderActionCreator is TokenholderActionCreator { _disableInitializers(); } - /// @notice Initializes a new `ERC20TokenholderActionCreator` clone. + /// @notice Initializes a new `ERC20TokenHolderActionCreator` clone. /// @dev This function is called by the `deployTokenVotingModule` function in the `LlamaTokenVotingFactory` contract. /// The `initializer` modifier ensures that this function can be invoked at most once. /// @param _token The ERC20 token to be used for voting. @@ -31,7 +31,7 @@ contract ERC20TokenholderActionCreator is TokenholderActionCreator { external initializer { - __initializeTokenholderActionCreatorMinimalProxy(_llamaCore, _role, _creationThreshold); + __initializeTokenHolderActionCreatorMinimalProxy(_llamaCore, _role, _creationThreshold); token = _token; uint256 totalSupply = token.totalSupply(); if (totalSupply == 0) revert InvalidTokenAddress(); diff --git a/src/token-voting/ERC20TokenholderCaster.sol b/src/token-voting/ERC20TokenholderCaster.sol index 8447ee9..6749d34 100644 --- a/src/token-voting/ERC20TokenholderCaster.sol +++ b/src/token-voting/ERC20TokenholderCaster.sol @@ -9,7 +9,7 @@ import {ERC20Votes} from "@openzeppelin/token/ERC20/extensions/ERC20Votes.sol"; /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a given governance ERC20Votes token cast approvals and disapprovals /// on created actions. -contract ERC20TokenholderCaster is TokenholderCaster { +contract ERC20TokenHolderCaster is TokenHolderCaster { ERC20Votes public token; /// @dev This contract is deployed as a minimal proxy from the factory's `deployTokenVotingModule` function. The @@ -18,7 +18,7 @@ contract ERC20TokenholderCaster is TokenholderCaster { _disableInitializers(); } - /// @notice Initializes a new `ERC20TokenholderCaster` clone. + /// @notice Initializes a new `ERC20TokenHolderCaster` clone. /// @dev This function is called by the `deployTokenVotingModule` function in the `LlamaTokenVotingFactory` contract. /// The `initializer` modifier ensures that this function can be invoked at most once. /// @param _token The ERC20 token to be used for voting. @@ -33,7 +33,7 @@ contract ERC20TokenholderCaster is TokenholderCaster { uint256 _minApprovalPct, uint256 _minDisapprovalPct ) external initializer { - __initializeTokenholderCasterMinimalProxy(_llamaCore, _role, _minApprovalPct, _minDisapprovalPct); + __initializeTokenHolderCasterMinimalProxy(_llamaCore, _role, _minApprovalPct, _minDisapprovalPct); token = _token; uint256 totalSupply = token.totalSupply(); if (totalSupply == 0) revert InvalidTokenAddress(); diff --git a/src/token-voting/ERC721TokenholderActionCreator.sol b/src/token-voting/ERC721TokenholderActionCreator.sol index 5fc3b58..db4b06d 100644 --- a/src/token-voting/ERC721TokenholderActionCreator.sol +++ b/src/token-voting/ERC721TokenholderActionCreator.sol @@ -10,7 +10,7 @@ import {IERC721} from "@openzeppelin/token/ERC721/IERC721.sol"; /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a given governance ERC721Votes token create actions on the llama instance if /// they hold enough tokens. -contract ERC721TokenholderActionCreator is TokenholderActionCreator { +contract ERC721TokenHolderActionCreator is TokenHolderActionCreator { ERC721Votes public token; /// @dev This contract is deployed as a minimal proxy from the factory's `deployTokenVotingModule` function. The @@ -19,7 +19,7 @@ contract ERC721TokenholderActionCreator is TokenholderActionCreator { _disableInitializers(); } - /// @notice Initializes a new `ERC721TokenholderActionCreator` clone. + /// @notice Initializes a new `ERC721TokenHolderActionCreator` clone. /// @dev This function is called by the `deployTokenVotingModule` function in the `LlamaTokenVotingFactory` contract. /// The `initializer` modifier ensures that this function can be invoked at most once. /// @param _token The ERC721 token to be used for voting. @@ -32,7 +32,7 @@ contract ERC721TokenholderActionCreator is TokenholderActionCreator { external initializer { - __initializeTokenholderActionCreatorMinimalProxy(_llamaCore, _role, _creationThreshold); + __initializeTokenHolderActionCreatorMinimalProxy(_llamaCore, _role, _creationThreshold); token = _token; if (!token.supportsInterface(type(IERC721).interfaceId)) revert InvalidTokenAddress(); uint256 totalSupply = token.getPastTotalSupply(block.timestamp - 1); diff --git a/src/token-voting/ERC721TokenholderCaster.sol b/src/token-voting/ERC721TokenholderCaster.sol index 8d8b679..fb1fcf4 100644 --- a/src/token-voting/ERC721TokenholderCaster.sol +++ b/src/token-voting/ERC721TokenholderCaster.sol @@ -10,7 +10,7 @@ import {IERC721} from "@openzeppelin/token/ERC721/IERC721.sol"; /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a given governance ERC721Votes token cast approvals and disapprovals /// on created actions. -contract ERC721TokenholderCaster is TokenholderCaster { +contract ERC721TokenHolderCaster is TokenHolderCaster { ERC721Votes public token; /// @dev This contract is deployed as a minimal proxy from the factory's `deployTokenVotingModule` function. The @@ -19,7 +19,7 @@ contract ERC721TokenholderCaster is TokenholderCaster { _disableInitializers(); } - /// @notice Initializes a new `ERC721TokenholderCaster` clone. + /// @notice Initializes a new `ERC721TokenHolderCaster` clone. /// @dev This function is called by the `deployTokenVotingModule` function in the `LlamaTokenVotingFactory` contract. /// The `initializer` modifier ensures that this function can be invoked at most once. /// @param _token The ERC721 token to be used for voting. @@ -31,7 +31,7 @@ contract ERC721TokenholderCaster is TokenholderCaster { external initializer { - __initializeTokenholderCasterMinimalProxy(_llamaCore, _role, _voteQuorum, _vetoQuorum); + __initializeTokenHolderCasterMinimalProxy(_llamaCore, _role, _voteQuorum, _vetoQuorum); token = _token; if (!token.supportsInterface(type(IERC721).interfaceId)) revert InvalidTokenAddress(); } diff --git a/src/token-voting/LlamaTokenVotingFactory.sol b/src/token-voting/LlamaTokenVotingFactory.sol index 0b48b36..cb47c07 100644 --- a/src/token-voting/LlamaTokenVotingFactory.sol +++ b/src/token-voting/LlamaTokenVotingFactory.sol @@ -47,39 +47,14 @@ contract LlamaTokenVotingFactory { ERC721_TOKENHOLDER_CASTER_LOGIC = erc721TokenHolderCasterLogic; } - /// @notice The ERC20 Tokenholder Action Creator (logic) contract. - ERC20TokenholderActionCreator public immutable ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC; - - /// @notice The ERC20 Tokenholder Caster (logic) contract. - ERC20TokenholderCaster public immutable ERC20_TOKENHOLDER_CASTER_LOGIC; - - /// @notice The ERC721 Tokenholder Action Creator (logic) contract. - ERC721TokenholderActionCreator public immutable ERC721_TOKENHOLDER_ACTION_CREATOR_LOGIC; - - /// @notice The ERC721 Tokenholder Caster (logic) contract. - ERC721TokenholderCaster public immutable ERC721_TOKENHOLDER_CASTER_LOGIC; - - /// @dev Set the logic contracts used to deploy Token Voting modules. - constructor( - ERC20TokenholderActionCreator erc20TokenholderActionCreatorLogic, - ERC20TokenholderCaster erc20TokenholderCasterLogic, - ERC721TokenholderActionCreator erc721TokenholderActionCreatorLogic, - ERC721TokenholderCaster erc721TokenholderCasterLogic - ) { - ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC = erc20TokenholderActionCreatorLogic; - ERC20_TOKENHOLDER_CASTER_LOGIC = erc20TokenholderCasterLogic; - ERC721_TOKENHOLDER_ACTION_CREATOR_LOGIC = erc721TokenholderActionCreatorLogic; - ERC721_TOKENHOLDER_CASTER_LOGIC = erc721TokenholderCasterLogic; - } - ///@notice Deploys a token voting module in a single function so it can be deployed in a single llama action. ///@dev This method CAN NOT be used in tandem with `delegateCallDeployTokenVotingModuleWithRoles`. You must use one or /// the other due to the delegateCallDeployTokenVotingModuleWithRoles method requring the contract to be authorized as /// a script. ///@param token The address of the token to be used for voting. ///@param isERC20 Whether the token is an ERC20 or ERC721. - ///@param actionCreatorRole The role required by the TokenholderActionCreator to create an action. - ///@param casterRole The role required by the TokenholderCaster to cast approvals and disapprovals. + ///@param actionCreatorRole The role required by the TokenHolderActionCreator to create an action. + ///@param casterRole The role required by the TokenHolderCaster to cast approvals and disapprovals. ///@param creationThreshold The number of tokens required to create an action (set to 0 if not deploying action /// creator). ///@param voteQuorum The minimum percentage of tokens required to approve an action (set to 0 if not deploying @@ -97,45 +72,51 @@ contract LlamaTokenVotingFactory { uint256 vetoQuorum ) external returns (address actionCreator, address caster) { if (isERC20) { - actionCreator = address(_deployERC20TokenholderActionCreator(ERC20Votes(token), llamaCore, actionCreatorRole, creationThreshold)); - caster = address(_deployERC20TokenholderCaster(ERC20Votes(token), llamaCore, casterRole, voteQuorum, vetoQuorum)); + actionCreator = address( + _deployERC20TokenHolderActionCreator(ERC20Votes(token), llamaCore, actionCreatorRole, creationThreshold) + ); + caster = address(_deployERC20TokenHolderCaster(ERC20Votes(token), llamaCore, casterRole, voteQuorum, vetoQuorum)); } else { - actionCreator = address(_deployERC721TokenholderActionCreator(ERC721Votes(token), llamaCore, actionCreatorRole, creationThreshold)); - caster = address(_deployERC721TokenholderCaster(ERC721Votes(token), llamaCore, casterRole, voteQuorum, vetoQuorum)); + actionCreator = address( + _deployERC721TokenHolderActionCreator(ERC721Votes(token), llamaCore, actionCreatorRole, creationThreshold) + ); + caster = + address(_deployERC721TokenHolderCaster(ERC721Votes(token), llamaCore, casterRole, voteQuorum, vetoQuorum)); + } } // ==================================== // ======== Internal Functions ======== // ==================================== - function _deployERC20TokenholderActionCreator( + function _deployERC20TokenHolderActionCreator( ERC20Votes token, ILlamaCore llamaCore, uint8 role, uint256 creationThreshold - ) internal returns (ERC20TokenholderActionCreator actionCreator) { - actionCreator = ERC20TokenholderActionCreator( + ) internal returns (ERC20TokenHolderActionCreator actionCreator) { + actionCreator = ERC20TokenHolderActionCreator( Clones.cloneDeterministic( address(ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC), keccak256(abi.encodePacked(address(token), msg.sender)) ) ); actionCreator.initialize(token, llamaCore, role, creationThreshold); - emit ERC20TokenholderActionCreatorCreated(address(actionCreator), address(token)); + emit ERC20TokenHolderActionCreatorCreated(address(actionCreator), address(token)); } - function _deployERC721TokenholderActionCreator( + function _deployERC721TokenHolderActionCreator( ERC721Votes token, ILlamaCore llamaCore, uint8 role, uint256 creationThreshold - ) internal returns (ERC721TokenholderActionCreator actionCreator) { - actionCreator = ERC721TokenholderActionCreator( + ) internal returns (ERC721TokenHolderActionCreator actionCreator) { + actionCreator = ERC721TokenHolderActionCreator( Clones.cloneDeterministic( address(ERC721_TOKENHOLDER_ACTION_CREATOR_LOGIC), keccak256(abi.encodePacked(address(token), msg.sender)) ) ); actionCreator.initialize(token, llamaCore, role, creationThreshold); - emit ERC721TokenholderActionCreatorCreated(address(actionCreator), address(token)); + emit ERC721TokenHolderActionCreatorCreated(address(actionCreator), address(token)); } function _deployERC20TokenHolderCaster( diff --git a/src/token-voting/TokenholderActionCreator.sol b/src/token-voting/TokenholderActionCreator.sol index 53451cb..26e8f21 100644 --- a/src/token-voting/TokenholderActionCreator.sol +++ b/src/token-voting/TokenholderActionCreator.sol @@ -109,7 +109,7 @@ abstract contract TokenHolderActionCreator is Initializable { /// @param _creationThreshold The default number of tokens required to create an action. This must /// be in the same decimals as the token. For example, if the token has 18 decimals and you want a /// creation threshold of 1000 tokens, pass in 1000e18. - function __initializeTokenholderActionCreatorMinimalProxy( + function __initializeTokenHolderActionCreatorMinimalProxy( ILlamaCore _llamaCore, uint8 _role, uint256 _creationThreshold diff --git a/src/token-voting/TokenholderCaster.sol b/src/token-voting/TokenholderCaster.sol index c0612dd..842609f 100644 --- a/src/token-voting/TokenholderCaster.sol +++ b/src/token-voting/TokenholderCaster.sol @@ -18,7 +18,7 @@ import {ILlamaRelativeStrategyBase} from "src/interfaces/ILlamaRelativeStrategyB /// it must hold a Policy from the specified `LlamaCore` instance to actually be able to cast on an action. This /// contract does not verify that it holds the correct policy when voting and relies on `LlamaCore` to /// verify that during submission. -abstract contract TokenholderCaster is Initializable { +abstract contract TokenHolderCaster is Initializable { // ========================= // ======== Structs ======== // ========================= @@ -56,13 +56,13 @@ abstract contract TokenholderCaster is Initializable { error AlreadyCastVote(); /// @dev Thrown when a user tries to cast vote but the casts have already been submitted to `LlamaCore`. - error AlreadySubmittedVote(); + error AlreadySubmittedVotes(); /// @dev Thrown when a user tries to cast veto but has already casted. error AlreadyCastVeto(); /// @dev Thrown when a user tries to cast veto but the casts have already been submitted to `LlamaCore. - error AlreadySubmittedVeto(); + error AlreadySubmittedVetos(); /// @dev Thrown when a user tries to cast vote/veto but the casting period has ended. error CastingPeriodOver(); @@ -150,7 +150,7 @@ abstract contract TokenholderCaster is Initializable { uint256 public voteQuorum; /// @notice The minimum % of vetos required to submit vetos to `LlamaCore`. - uint256 public minVetoQuorum; + uint256 public vetoQuorum; /// @notice The role used by this contract to cast approvals and disapprovals. /// @dev This role is expected to have the ability to force approve and disapprove actions. @@ -187,22 +187,22 @@ abstract contract TokenholderCaster is Initializable { /// @param _llamaCore The `LlamaCore` contract for this Llama instance. /// @param _role The role used by this contract to cast votes and vetos. /// @param _voteQuorum The minimum % of votes required to submit votes to `LlamaCore`. - /// @param _VetoQuorum The minimum % of vetos required to submit vetos to `LlamaCore`. + /// @param _vetoQuorum The minimum % of vetos required to submit vetos to `LlamaCore`. function __initializeTokenHolderCasterMinimalProxy( ILlamaCore _llamaCore, uint8 _role, uint256 _voteQuorum, - uint256 _VetoQuorum + uint256 _vetoQuorum ) internal { if (_llamaCore.actionsCount() < 0) revert InvalidLlamaCoreAddress(); if (_role > _llamaCore.policy().numRoles()) revert RoleNotInitialized(_role); if (_voteQuorum > ONE_HUNDRED_IN_BPS || _voteQuorum <= 0) revert InvalidVotesQuorum(_voteQuorum); - if (_VetoQuorum > ONE_HUNDRED_IN_BPS || _VetoQuorum <= 0) revert InvalidVetoQuorum(_VetoQuorum); + if (_vetoQuorum > ONE_HUNDRED_IN_BPS || _vetoQuorum <= 0) revert InvalidVetoQuorum(_vetoQuorum); llamaCore = _llamaCore; role = _role; voteQuorum = _voteQuorum; - minVetoQuorum = _VetoQuorum; + vetoQuorum = _vetoQuorum; } /// @notice How tokenHolders add their support of an action with a vote and a reason. @@ -265,7 +265,7 @@ abstract contract TokenholderCaster is Initializable { function submitVotes(ActionInfo calldata actionInfo) external { Action memory action = llamaCore.getAction(actionInfo.id); - if (casts[actionInfo.id].votesSubmitted) revert AlreadySubmittedVote(); + if (casts[actionInfo.id].votesSubmitted) revert AlreadySubmittedVotes(); // check to make sure the casting period has ended uint256 votePeriod = ILlamaRelativeStrategyBase(address(actionInfo.strategy)).approvalPeriod(); if (block.timestamp < action.creationTime + (votePeriod * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS) { @@ -300,7 +300,7 @@ abstract contract TokenholderCaster is Initializable { Action memory action = llamaCore.getAction(actionInfo.id); actionInfo.strategy.checkIfDisapprovalEnabled(actionInfo, msg.sender, role); // Reverts if not allowed. - if (casts[actionInfo.id].vetoSubmitted) revert AlreadySubmittedVeto(); + if (casts[actionInfo.id].vetoSubmitted) revert AlreadySubmittedVetos(); uint256 queuingPeriod = ILlamaRelativeStrategyBase(address(actionInfo.strategy)).queuingPeriod(); // check to make sure the current timestamp is within the submitVetoBuffer period @@ -318,7 +318,7 @@ abstract contract TokenholderCaster is Initializable { uint96 vetosFor = casts[actionInfo.id].vetosFor; uint96 vetosAgainst = casts[actionInfo.id].vetosAgainst; uint96 vetosAbstain = casts[actionInfo.id].vetosAbstain; - uint256 quorum = FixedPointMathLib.mulDivUp(totalSupply, minVetoQuorum, ONE_HUNDRED_IN_BPS); + uint256 quorum = FixedPointMathLib.mulDivUp(totalSupply, vetoQuorum, ONE_HUNDRED_IN_BPS); if (vetosFor < quorum) revert InsufficientVotes(vetosFor, quorum); if (vetosFor <= vetosAgainst) revert ForDoesNotSurpassAgainst(vetosFor, vetosAgainst); @@ -446,12 +446,7 @@ abstract contract TokenholderCaster is Initializable { ActionInfo calldata actionInfo, string calldata reason ) internal returns (bytes32) { - bytes32 castVetoHash = keccak256( - abi.encode( - CAST_VETO_BY_SIG_TYPEHASH, - tokenHolder, - support, - ); + bytes32 castVetoHash = keccak256(abi.encode(CAST_VETO_BY_SIG_TYPEHASH, tokenHolder, support)); return keccak256(abi.encodePacked("\x19\x01", _getDomainHash(), castVetoHash)); } diff --git a/test/token-voting/ERC20TokenholderActionCreator.t.sol b/test/token-voting/ERC20TokenholderActionCreator.t.sol index 199a6b6..774ac54 100644 --- a/test/token-voting/ERC20TokenholderActionCreator.t.sol +++ b/test/token-voting/ERC20TokenholderActionCreator.t.sol @@ -10,10 +10,10 @@ import {ILlamaCore} from "src/interfaces/ILlamaCore.sol"; import {ILlamaStrategy} from "src/interfaces/ILlamaStrategy.sol"; import {ActionState} from "src/lib/Enums.sol"; import {Action, ActionInfo} from "src/lib/Structs.sol"; -import {ERC20TokenholderActionCreator} from "src/token-voting/ERC20TokenholderActionCreator.sol"; -import {TokenholderActionCreator} from "src/token-voting/TokenholderActionCreator.sol"; +import {ERC20TokenHolderActionCreator} from "src/token-voting/ERC20TokenHolderActionCreator.sol"; +import {TokenHolderActionCreator} from "src/token-voting/TokenHolderActionCreator.sol"; -contract ERC20TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaCoreSigUtils { +contract ERC20TokenHolderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaCoreSigUtils { event ActionCreated( uint256 id, address indexed creator, @@ -29,7 +29,7 @@ contract ERC20TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaCo event ActionThresholdSet(uint256 newThreshold); - ERC20TokenholderActionCreator erc20TokenholderActionCreator; + ERC20TokenHolderActionCreator erc20TokenHolderActionCreator; function setUp() public virtual override { LlamaTokenVotingTestSetup.setUp(); @@ -42,7 +42,7 @@ contract ERC20TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaCo mineBlock(); // Deploy ERC20 Token Voting Module. - (erc20TokenholderActionCreator,) = _deployERC20TokenVotingModuleAndSetRole(); + (erc20TokenHolderActionCreator,) = _deployERC20TokenVotingModuleAndSetRole(); // Setting ERC20TokenHolderActionCreator's EIP-712 Domain Hash setDomainHash( @@ -50,22 +50,22 @@ contract ERC20TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaCo name: CORE.name(), version: "1", chainId: block.chainid, - verifyingContract: address(erc20TokenholderActionCreator) + verifyingContract: address(erc20TokenHolderActionCreator) }) ); } } -// contract Constructor is ERC20TokenholderActionCreatorTest { +// contract Constructor is ERC20TokenHolderActionCreatorTest { // function test_RevertsIf_InvalidLlamaCore() public { -// // With invalid LlamaCore instance, TokenholderActionCreator.InvalidLlamaCoreAddress is unreachable +// // With invalid LlamaCore instance, TokenHolderActionCreator.InvalidLlamaCoreAddress is unreachable // vm.expectRevert(); -// new ERC20TokenholderActionCreator(erc20VotesToken, ILlamaCore(makeAddr("invalid-llama-core")), uint256(0)); +// new ERC20TokenHolderActionCreator(erc20VotesToken, ILlamaCore(makeAddr("invalid-llama-core")), uint256(0)); // } // function test_RevertsIf_InvalidTokenAddress() public { // vm.expectRevert(); // will EvmError: Revert vecause totalSupply fn does not exist -// new ERC20TokenholderActionCreator(ERC20Votes(makeAddr("invalid-erc20VotesToken")), CORE, uint256(0)); +// new ERC20TokenHolderActionCreator(ERC20Votes(makeAddr("invalid-erc20VotesToken")), CORE, uint256(0)); // } // function test_RevertsIf_CreationThresholdExceedsTotalSupply() public { @@ -74,8 +74,8 @@ contract ERC20TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaCo // vm.warp(block.timestamp + 1); -// vm.expectRevert(TokenholderActionCreator.InvalidCreationThreshold.selector); -// new ERC20TokenholderActionCreator(erc20VotesToken, CORE, 17_000_000_000_000_000_000_000_000); +// vm.expectRevert(TokenHolderActionCreator.InvalidCreationThreshold.selector); +// new ERC20TokenHolderActionCreator(erc20VotesToken, CORE, 17_000_000_000_000_000_000_000_000); // } // function test_ProperlySetsConstructorArguments() public { @@ -85,16 +85,16 @@ contract ERC20TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaCo // vm.warp(block.timestamp + 1); -// ERC20TokenholderActionCreator erc20TokenholderActionCreator = new ERC20TokenholderActionCreator(erc20VotesToken, +// ERC20TokenHolderActionCreator erc20TokenHolderActionCreator = new ERC20TokenHolderActionCreator(erc20VotesToken, // CORE, // threshold); -// assertEq(address(erc20TokenholderActionCreator.TOKEN()), address(erc20VotesToken)); -// assertEq(address(erc20TokenholderActionCreator.LLAMA_CORE()), address(CORE)); -// assertEq(erc20TokenholderActionCreator.creationThreshold(), threshold); +// assertEq(address(erc20TokenHolderActionCreator.TOKEN()), address(erc20VotesToken)); +// assertEq(address(erc20TokenHolderActionCreator.LLAMA_CORE()), address(CORE)); +// assertEq(erc20TokenHolderActionCreator.creationThreshold(), threshold); // } // } -contract CreateAction is ERC20TokenholderActionCreatorTest { +contract CreateAction is ERC20TokenHolderActionCreatorTest { bytes data = abi.encodeCall(mockProtocol.pause, (true)); function test_RevertsIf_InsufficientBalance() public { @@ -104,12 +104,12 @@ contract CreateAction is ERC20TokenholderActionCreatorTest { mineBlock(); - vm.expectRevert(abi.encodeWithSelector(TokenholderActionCreator.InsufficientBalance.selector, 0)); + vm.expectRevert(abi.encodeWithSelector(TokenHolderActionCreator.InsufficientBalance.selector, 0)); vm.prank(notTokenHolder); - erc20TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + erc20TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); } - function test_RevertsIf_TokenholderActionCreatorDoesNotHavePermission() public { + function test_RevertsIf_TokenHolderActionCreatorDoesNotHavePermission() public { erc20VotesToken.mint(tokenHolder1, ERC20_CREATION_THRESHOLD); vm.prank(tokenHolder1); erc20VotesToken.delegate(tokenHolder1); @@ -118,12 +118,12 @@ contract CreateAction is ERC20TokenholderActionCreatorTest { vm.expectRevert(ILlamaCore.PolicyholderDoesNotHavePermission.selector); vm.prank(tokenHolder1); - erc20TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + erc20TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); } function test_ProperlyCreatesAction() public { - // Assigns Permission to TokenholderActionCreator. - _setRolePermissionToTokenholderActionCreator(); + // Assigns Permission to TokenHolderActionCreator. + _setRolePermissionToTokenHolderActionCreator(); // Mint tokens to tokenholder so that they can create action. erc20VotesToken.mint(tokenHolder1, ERC20_CREATION_THRESHOLD); @@ -140,7 +140,7 @@ contract CreateAction is ERC20TokenholderActionCreatorTest { actionCount, address(tokenHolder1), tokenVotingActionCreatorRole, STRATEGY, address(mockProtocol), 0, data, "" ); vm.prank(tokenHolder1); - uint256 actionId = erc20TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + uint256 actionId = erc20TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); Action memory action = CORE.getAction(actionId); assertEq(actionId, actionCount); @@ -148,12 +148,12 @@ contract CreateAction is ERC20TokenholderActionCreatorTest { } } -contract CreateActionBySig is ERC20TokenholderActionCreatorTest { +contract CreateActionBySig is ERC20TokenHolderActionCreatorTest { function setUp() public virtual override { - ERC20TokenholderActionCreatorTest.setUp(); + ERC20TokenHolderActionCreatorTest.setUp(); - // Assigns Permission to TokenholderActionCreator. - _setRolePermissionToTokenholderActionCreator(); + // Assigns Permission to TokenHolderActionCreator. + _setRolePermissionToTokenHolderActionCreator(); // Mint tokens to tokenholder so that they can create action. erc20VotesToken.mint(tokenHolder1, ERC20_CREATION_THRESHOLD); @@ -187,7 +187,7 @@ contract CreateActionBySig is ERC20TokenholderActionCreatorTest { } function createActionBySig(uint8 v, bytes32 r, bytes32 s) internal returns (uint256 actionId) { - actionId = erc20TokenholderActionCreator.createActionBySig( + actionId = erc20TokenHolderActionCreator.createActionBySig( tokenHolder1, STRATEGY, address(mockProtocol), 0, abi.encodeCall(mockProtocol.pause, (true)), "", v, r, s ); } @@ -230,7 +230,7 @@ contract CreateActionBySig is ERC20TokenholderActionCreatorTest { "# Action 0 \n This is my action." ); - uint256 actionId = erc20TokenholderActionCreator.createActionBySig( + uint256 actionId = erc20TokenHolderActionCreator.createActionBySig( tokenHolder1, STRATEGY, address(mockProtocol), @@ -249,9 +249,9 @@ contract CreateActionBySig is ERC20TokenholderActionCreatorTest { function test_CheckNonceIncrements() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(tokenHolder1PrivateKey); - assertEq(erc20TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.createActionBySig.selector), 0); + assertEq(erc20TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.createActionBySig.selector), 0); createActionBySig(v, r, s); - assertEq(erc20TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.createActionBySig.selector), 1); + assertEq(erc20TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.createActionBySig.selector), 1); } function test_OperationCannotBeReplayed() public { @@ -259,7 +259,7 @@ contract CreateActionBySig is ERC20TokenholderActionCreatorTest { createActionBySig(v, r, s); // Invalid Signature error since the recovered signer address during the second call is not the same as // policyholder since nonce has increased. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); createActionBySig(v, r, s); } @@ -268,7 +268,7 @@ contract CreateActionBySig is ERC20TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(randomSignerPrivateKey); // Invalid Signature error since the recovered signer address is not the same as the policyholder passed in as // parameter. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); createActionBySig(v, r, s); } @@ -276,7 +276,7 @@ contract CreateActionBySig is ERC20TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(tokenHolder1PrivateKey); // Invalid Signature error since the recovered signer address is zero address due to invalid signature values // (v,r,s). - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); createActionBySig((v + 1), r, s); } @@ -284,24 +284,24 @@ contract CreateActionBySig is ERC20TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(tokenHolder1PrivateKey); vm.prank(tokenHolder1); - erc20TokenholderActionCreator.incrementNonce(TokenholderActionCreator.createActionBySig.selector); + erc20TokenHolderActionCreator.incrementNonce(TokenHolderActionCreator.createActionBySig.selector); // Invalid Signature error since the recovered signer address during the call is not the same as policyholder // since nonce has increased. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); createActionBySig(v, r, s); } } -contract CancelAction is ERC20TokenholderActionCreatorTest { +contract CancelAction is ERC20TokenHolderActionCreatorTest { uint256 actionId; ActionInfo actionInfo; function setUp() public virtual override { - ERC20TokenholderActionCreatorTest.setUp(); + ERC20TokenHolderActionCreatorTest.setUp(); - // Assigns Permission to TokenholderActionCreator. - _setRolePermissionToTokenholderActionCreator(); + // Assigns Permission to TokenHolderActionCreator. + _setRolePermissionToTokenHolderActionCreator(); // Mint tokens to tokenholder so that they can create action. erc20VotesToken.mint(tokenHolder1, ERC20_CREATION_THRESHOLD); @@ -314,11 +314,11 @@ contract CancelAction is ERC20TokenholderActionCreatorTest { bytes memory data = abi.encodeCall(mockProtocol.pause, (true)); vm.prank(tokenHolder1); - actionId = erc20TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + actionId = erc20TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); actionInfo = ActionInfo( actionId, - address(erc20TokenholderActionCreator), + address(erc20TokenHolderActionCreator), tokenVotingActionCreatorRole, STRATEGY, address(mockProtocol), @@ -331,26 +331,26 @@ contract CancelAction is ERC20TokenholderActionCreatorTest { vm.expectEmit(); emit ActionCanceled(actionId, tokenHolder1); vm.prank(tokenHolder1); - erc20TokenholderActionCreator.cancelAction(actionInfo); + erc20TokenHolderActionCreator.cancelAction(actionInfo); } function test_RevertsIf_CallerIsNotActionCreator(address notCreator) public { vm.assume(notCreator != tokenHolder1); - vm.expectRevert(TokenholderActionCreator.OnlyActionCreator.selector); + vm.expectRevert(TokenHolderActionCreator.OnlyActionCreator.selector); vm.prank(notCreator); - erc20TokenholderActionCreator.cancelAction(actionInfo); + erc20TokenHolderActionCreator.cancelAction(actionInfo); } } -contract CancelActionBySig is ERC20TokenholderActionCreatorTest { +contract CancelActionBySig is ERC20TokenHolderActionCreatorTest { uint256 actionId; ActionInfo actionInfo; function setUp() public virtual override { - ERC20TokenholderActionCreatorTest.setUp(); + ERC20TokenHolderActionCreatorTest.setUp(); - // Assigns Permission to TokenholderActionCreator. - _setRolePermissionToTokenholderActionCreator(); + // Assigns Permission to TokenHolderActionCreator. + _setRolePermissionToTokenHolderActionCreator(); // Mint tokens to tokenholder so that they can create action. erc20VotesToken.mint(tokenHolder1, ERC20_CREATION_THRESHOLD); @@ -363,11 +363,11 @@ contract CancelActionBySig is ERC20TokenholderActionCreatorTest { bytes memory data = abi.encodeCall(mockProtocol.pause, (true)); vm.prank(tokenHolder1); - actionId = erc20TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + actionId = erc20TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); actionInfo = ActionInfo( actionId, - address(erc20TokenholderActionCreator), + address(erc20TokenHolderActionCreator), tokenVotingActionCreatorRole, STRATEGY, address(mockProtocol), @@ -384,14 +384,14 @@ contract CancelActionBySig is ERC20TokenholderActionCreatorTest { LlamaCoreSigUtils.CancelAction memory cancelAction = LlamaCoreSigUtils.CancelAction({ tokenHolder: tokenHolder1, actionInfo: _actionInfo, - nonce: erc20TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.cancelActionBySig.selector) + nonce: erc20TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.cancelActionBySig.selector) }); bytes32 digest = getCancelActionTypedDataHash(cancelAction); (v, r, s) = vm.sign(privateKey, digest); } function cancelActionBySig(ActionInfo memory _actionInfo, uint8 v, bytes32 r, bytes32 s) internal { - erc20TokenholderActionCreator.cancelActionBySig(tokenHolder1, _actionInfo, v, r, s); + erc20TokenHolderActionCreator.cancelActionBySig(tokenHolder1, _actionInfo, v, r, s); } function test_CancelActionBySig() public { @@ -409,9 +409,9 @@ contract CancelActionBySig is ERC20TokenholderActionCreatorTest { function test_CheckNonceIncrements() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - assertEq(erc20TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.cancelActionBySig.selector), 0); + assertEq(erc20TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.cancelActionBySig.selector), 0); cancelActionBySig(actionInfo, v, r, s); - assertEq(erc20TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.cancelActionBySig.selector), 1); + assertEq(erc20TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.cancelActionBySig.selector), 1); } function test_OperationCannotBeReplayed() public { @@ -419,7 +419,7 @@ contract CancelActionBySig is ERC20TokenholderActionCreatorTest { cancelActionBySig(actionInfo, v, r, s); // Invalid Signature error since the recovered signer address during the second call is not the same as policyholder // since nonce has increased. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); cancelActionBySig(actionInfo, v, r, s); } @@ -428,7 +428,7 @@ contract CancelActionBySig is ERC20TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, randomSignerPrivateKey); // Invalid Signature error since the recovered signer address is not the same as the policyholder passed in as // parameter. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); cancelActionBySig(actionInfo, v, r, s); } @@ -436,7 +436,7 @@ contract CancelActionBySig is ERC20TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); // Invalid Signature error since the recovered signer address is zero address due to invalid signature values // (v,r,s). - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); cancelActionBySig(actionInfo, (v + 1), r, s); } @@ -444,42 +444,42 @@ contract CancelActionBySig is ERC20TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); vm.prank(tokenHolder1); - erc20TokenholderActionCreator.incrementNonce(TokenholderActionCreator.cancelActionBySig.selector); + erc20TokenHolderActionCreator.incrementNonce(TokenHolderActionCreator.cancelActionBySig.selector); // Invalid Signature error since the recovered signer address during the call is not the same as policyholder // since nonce has increased. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); cancelActionBySig(actionInfo, v, r, s); } } -contract SetActionThreshold is ERC20TokenholderActionCreatorTest { +contract SetActionThreshold is ERC20TokenHolderActionCreatorTest { function testFuzz_SetsCreationThreshold(uint256 threshold) public { threshold = bound(threshold, 0, erc20VotesToken.getPastTotalSupply(block.timestamp - 1)); - assertEq(erc20TokenholderActionCreator.creationThreshold(), ERC20_CREATION_THRESHOLD); + assertEq(erc20TokenHolderActionCreator.creationThreshold(), ERC20_CREATION_THRESHOLD); vm.expectEmit(); emit ActionThresholdSet(threshold); vm.prank(address(EXECUTOR)); - erc20TokenholderActionCreator.setActionThreshold(threshold); + erc20TokenHolderActionCreator.setActionThreshold(threshold); - assertEq(erc20TokenholderActionCreator.creationThreshold(), threshold); + assertEq(erc20TokenHolderActionCreator.creationThreshold(), threshold); } function testFuzz_RevertsIf_CreationThresholdExceedsTotalSupply(uint256 threshold) public { vm.assume(threshold > erc20VotesToken.getPastTotalSupply(block.timestamp - 1)); - vm.expectRevert(TokenholderActionCreator.InvalidCreationThreshold.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidCreationThreshold.selector); vm.prank(address(EXECUTOR)); - erc20TokenholderActionCreator.setActionThreshold(threshold); + erc20TokenHolderActionCreator.setActionThreshold(threshold); } function testFuzz_RevertsIf_CalledByNotLlamaExecutor(address notLlamaExecutor) public { vm.assume(notLlamaExecutor != address(EXECUTOR)); - vm.expectRevert(TokenholderActionCreator.OnlyLlamaExecutor.selector); + vm.expectRevert(TokenHolderActionCreator.OnlyLlamaExecutor.selector); vm.prank(notLlamaExecutor); - erc20TokenholderActionCreator.setActionThreshold(ERC20_CREATION_THRESHOLD); + erc20TokenHolderActionCreator.setActionThreshold(ERC20_CREATION_THRESHOLD); } } diff --git a/test/token-voting/ERC20TokenholderCaster.t.sol b/test/token-voting/ERC20TokenholderCaster.t.sol index 499cf50..8cb87ce 100644 --- a/test/token-voting/ERC20TokenholderCaster.t.sol +++ b/test/token-voting/ERC20TokenholderCaster.t.sol @@ -13,23 +13,26 @@ import {Action, ActionInfo, PermissionData} from "src/lib/Structs.sol"; import {ILlamaCore} from "src/interfaces/ILlamaCore.sol"; import {ILlamaRelativeStrategyBase} from "src/interfaces/ILlamaRelativeStrategyBase.sol"; import {ILlamaStrategy} from "src/interfaces/ILlamaStrategy.sol"; -import {ERC20TokenholderCaster} from "src/token-voting/ERC20TokenholderCaster.sol"; -import {TokenholderCaster} from "src/token-voting/TokenholderCaster.sol"; +import {ERC20TokenHolderCaster} from "src/token-voting/ERC20TokenHolderCaster.sol"; +import {TokenHolderCaster} from "src/token-voting/TokenHolderCaster.sol"; -contract ERC20TokenholderCasterTest is LlamaTokenVotingTestSetup { +contract ERC20TokenHolderCasterTest is LlamaTokenVotingTestSetup, LlamaCoreSigUtils { uint256 constant DEFAULT_APPROVAL_THRESHOLD = 1000; + + event VoteCast( + uint256 id, address indexed tokenHolder, uint8 indexed role, uint8 indexed support, uint256 quantity, string reason ); - event ApprovalsSubmitted(uint256 id, uint96 quantityFor, uint96 quantityAgainst, uint96 quantityAbstain); + event VotesSubmitted(uint256 id, uint96 quantityFor, uint96 quantityAgainst, uint96 quantityAbstain); - event DisapprovalCast( + event VetoCast( uint256 id, address indexed policyholder, uint8 indexed role, uint8 indexed support, uint256 quantity, string reason ); - event DisapprovalsSubmitted(uint256 id, uint96 quantityFor, uint96 quantityAgainst, uint96 quantityAbstain); + event VetosSubmitted(uint256 id, uint96 quantityFor, uint96 quantityAgainst, uint96 quantityAbstain); ActionInfo actionInfo; - ERC20TokenholderCaster erc20TokenholderCaster; + ERC20TokenHolderCaster erc20TokenHolderCaster; ILlamaStrategy tokenVotingStrategy; function setUp() public virtual override { @@ -53,7 +56,7 @@ contract ERC20TokenholderCasterTest is LlamaTokenVotingTestSetup { mineBlock(); // Deploy ERC20 Token Voting Module. - (, erc20TokenholderCaster) = _deployERC20TokenVotingModuleAndSetRole(); + (, erc20TokenHolderCaster) = _deployERC20TokenVotingModuleAndSetRole(); // Mine block so that Token Voting Caster Role will have supply during action creation (due to past timestamp check) mineBlock(); @@ -61,41 +64,41 @@ contract ERC20TokenholderCasterTest is LlamaTokenVotingTestSetup { tokenVotingStrategy = _deployRelativeQuantityQuorumAndSetRolePermissionToCoreTeam(tokenVotingCasterRole); actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); - // Setting ERC20TokenholderCaster's EIP-712 Domain Hash + // Setting ERC20TokenHolderCaster's EIP-712 Domain Hash setDomainHash( LlamaCoreSigUtils.EIP712Domain({ name: CORE.name(), version: "1", chainId: block.chainid, - verifyingContract: address(erc20TokenholderCaster) + verifyingContract: address(erc20TokenHolderCaster) }) ); } - function castApprovalsFor() public { + function castVoteFor() public { vm.prank(tokenHolder1); - erc20TokenholderCaster.castApproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVote(actionInfo, 1, ""); vm.prank(tokenHolder2); - erc20TokenholderCaster.castApproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVote(actionInfo, 1, ""); vm.prank(tokenHolder3); - erc20TokenholderCaster.castApproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVote(actionInfo, 1, ""); } - function castDisapprovalsFor() public { + function castVetosFor() public { vm.prank(tokenHolder1); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVeto(actionInfo, 1, ""); vm.prank(tokenHolder2); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVeto(actionInfo, 1, ""); vm.prank(tokenHolder3); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVeto(actionInfo, 1, ""); } } -// contract Constructor is ERC20TokenholderCasterTest { +// contract Constructor is ERC20TokenHolderCasterTest { // function test_RevertsIf_InvalidLlamaCoreAddress() public { -// // With invalid LlamaCore instance, TokenholderActionCreator.InvalidLlamaCoreAddress is unreachable +// // With invalid LlamaCore instance, TokenHolderActionCreator.InvalidLlamaCoreAddress is unreachable // vm.expectRevert(); -// new ERC20TokenholderCaster( +// new ERC20TokenHolderCaster( // erc20VotesToken, ILlamaCore(makeAddr("invalid-llama-core")), tokenVotingCasterRole, uint256(1), uint256(1) // ); // } @@ -104,32 +107,32 @@ contract ERC20TokenholderCasterTest is LlamaTokenVotingTestSetup { // vm.assume(notAToken != address(0)); // vm.assume(notAToken != address(erc20VotesToken)); // vm.expectRevert(); // will revert with EvmError: Revert because `totalSupply` is not a function -// new ERC20TokenholderCaster( +// new ERC20TokenHolderCaster( // ERC20Votes(notAToken), ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), uint256(1) // ); // } // function test_RevertsIf_InvalidRole(uint8 role) public { // role = uint8(bound(role, POLICY.numRoles(), 255)); -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.RoleNotInitialized.selector, uint8(255))); -// new ERC20TokenholderCaster(erc20VotesToken, ILlamaCore(address(CORE)), uint8(255), uint256(1), uint256(1)); +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.RoleNotInitialized.selector, uint8(255))); +// new ERC20TokenHolderCaster(erc20VotesToken, ILlamaCore(address(CORE)), uint8(255), uint256(1), uint256(1)); // } -// function test_RevertsIf_InvalidMinApprovalPct() public { -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidMinApprovalPct.selector, uint256(0))); -// new ERC20TokenholderCaster(erc20VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(0), +// function test_RevertsIf_InvalidMinVotesPct() public { +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidMinVotesPct.selector, uint256(0))); +// new ERC20TokenHolderCaster(erc20VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(0), // uint256(1)); -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidMinApprovalPct.selector, uint256(10_001))); -// new ERC20TokenholderCaster(erc20VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(10_001), +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidMinVotesPct.selector, uint256(10_001))); +// new ERC20TokenHolderCaster(erc20VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(10_001), // uint256(1)); // } -// function test_RevertsIf_InvalidMinDisapprovalPct() public { -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidMinDisapprovalPct.selector, uint256(0))); -// new ERC20TokenholderCaster(erc20VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), +// function test_RevertsIf_InvalidMinVetoPct() public { +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidMinVetoPct.selector, uint256(0))); +// new ERC20TokenHolderCaster(erc20VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), // uint256(0)); -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidMinDisapprovalPct.selector, uint256(10_001))); -// new ERC20TokenholderCaster(erc20VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidMinVetoPct.selector, uint256(10_001))); +// new ERC20TokenHolderCaster(erc20VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), // uint256(10_001)); // } @@ -137,73 +140,73 @@ contract ERC20TokenholderCasterTest is LlamaTokenVotingTestSetup { // erc20VotesToken.mint(address(this), 1_000_000e18); // we use erc20VotesToken because IVotesToken is an interface // // without the `mint` function -// erc20TokenholderCaster = new ERC20TokenholderCaster( +// erc20TokenHolderCaster = new ERC20TokenHolderCaster( // erc20VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, DEFAULT_APPROVAL_THRESHOLD, // DEFAULT_APPROVAL_THRESHOLD // ); -// assertEq(address(erc20TokenholderCaster.LLAMA_CORE()), address(CORE)); -// assertEq(address(erc20TokenholderCaster.TOKEN()), address(erc20VotesToken)); -// assertEq(erc20TokenholderCaster.ROLE(), tokenVotingCasterRole); -// assertEq(erc20TokenholderCaster.MIN_APPROVAL_PCT(), DEFAULT_APPROVAL_THRESHOLD); -// assertEq(erc20TokenholderCaster.MIN_DISAPPROVAL_PCT(), DEFAULT_APPROVAL_THRESHOLD); +// assertEq(address(erc20TokenHolderCaster.LLAMA_CORE()), address(CORE)); +// assertEq(address(erc20TokenHolderCaster.TOKEN()), address(erc20VotesToken)); +// assertEq(erc20TokenHolderCaster.ROLE(), tokenVotingCasterRole); +// assertEq(erc20TokenHolderCaster.MIN_APPROVAL_PCT(), DEFAULT_APPROVAL_THRESHOLD); +// assertEq(erc20TokenHolderCaster.MIN_DISAPPROVAL_PCT(), DEFAULT_APPROVAL_THRESHOLD); // } // } -contract CastApproval is ERC20TokenholderCasterTest { +contract CastVote is ERC20TokenHolderCasterTest { function test_RevertsIf_ActionInfoMismatch(ActionInfo memory notActionInfo) public { vm.assume(notActionInfo.id != actionInfo.id); vm.expectRevert(); - erc20TokenholderCaster.castApproval(notActionInfo, 1, ""); + erc20TokenHolderCaster.castVote(notActionInfo, 1, ""); } - function test_RevertsIf_ApprovalNotEnabled() public { - ERC20TokenholderCaster casterWithWrongRole = ERC20TokenholderCaster( + function test_RevertsIf_VotesNotEnabled() public { + ERC20TokenHolderCaster casterWithWrongRole = ERC20TokenHolderCaster( Clones.cloneDeterministic( - address(erc20TokenholderCasterLogic), keccak256(abi.encodePacked(address(erc20VotesToken), msg.sender)) + address(erc20TokenHolderCasterLogic), keccak256(abi.encodePacked(address(erc20VotesToken), msg.sender)) ) ); casterWithWrongRole.initialize(erc20VotesToken, CORE, madeUpRole, ERC20_MIN_APPROVAL_PCT, ERC20_MIN_DISAPPROVAL_PCT); vm.expectRevert(abi.encodeWithSelector(ILlamaRelativeStrategyBase.InvalidRole.selector, tokenVotingCasterRole)); - casterWithWrongRole.castApproval(actionInfo, 1, ""); + casterWithWrongRole.castVote(actionInfo, 1, ""); } function test_RevertsIf_ActionNotActive() public { vm.warp(block.timestamp + 1 days + 1); - vm.expectRevert(TokenholderCaster.ActionNotActive.selector); - erc20TokenholderCaster.castApproval(actionInfo, 1, ""); + vm.expectRevert(TokenHolderCaster.ActionNotActive.selector); + erc20TokenHolderCaster.castVote(actionInfo, 1, ""); } - function test_RevertsIf_AlreadyCastApproval() public { + function test_RevertsIf_AlreadyCastVote() public { vm.startPrank(tokenHolder1); - erc20TokenholderCaster.castApproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVote(actionInfo, 1, ""); - vm.expectRevert(TokenholderCaster.AlreadyCastApproval.selector); - erc20TokenholderCaster.castApproval(actionInfo, 1, ""); + vm.expectRevert(TokenHolderCaster.AlreadyCastVote.selector); + erc20TokenHolderCaster.castVote(actionInfo, 1, ""); } function test_RevertsIf_InvalidSupport() public { - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidSupport.selector, uint8(3))); - erc20TokenholderCaster.castApproval(actionInfo, 3, ""); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidSupport.selector, uint8(3))); + erc20TokenHolderCaster.castVote(actionInfo, 3, ""); } function test_RevertsIf_CastingPeriodOver() public { - vm.warp(block.timestamp + ((1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS) + 1); // 2/3 of the approval period - vm.expectRevert(TokenholderCaster.CastingPeriodOver.selector); + vm.warp(block.timestamp + ((1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS) + 1); // 2/3 of the voting period + vm.expectRevert(TokenHolderCaster.CastingPeriodOver.selector); vm.prank(tokenHolder1); - erc20TokenholderCaster.castApproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVote(actionInfo, 1, ""); } function test_RevertsIf_InsufficientBalance() public { - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InsufficientBalance.selector, 0)); - erc20TokenholderCaster.castApproval(actionInfo, 1, ""); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InsufficientBalance.selector, 0)); + erc20TokenHolderCaster.castVote(actionInfo, 1, ""); } - function test_CastsApprovalCorrectly(uint8 support) public { + function test_CastsVoteCorrectly(uint8 support) public { support = uint8(bound(support, 0, 2)); vm.expectEmit(); - emit ApprovalCast( + emit VoteCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -212,12 +215,12 @@ contract CastApproval is ERC20TokenholderCasterTest { "" ); vm.prank(tokenHolder1); - erc20TokenholderCaster.castApproval(actionInfo, support, ""); + erc20TokenHolderCaster.castVote(actionInfo, support, ""); } - function test_CastsApprovalCorrectly_WithReason() public { + function test_CastsVoteCorrectly_WithReason() public { vm.expectEmit(); - emit ApprovalCast( + emit VoteCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -226,13 +229,13 @@ contract CastApproval is ERC20TokenholderCasterTest { "reason" ); vm.prank(tokenHolder1); - erc20TokenholderCaster.castApproval(actionInfo, 1, "reason"); + erc20TokenHolderCaster.castVote(actionInfo, 1, "reason"); } } -contract CastApprovalBySig is ERC20TokenholderCasterTest { +contract CastVoteBySig is ERC20TokenHolderCasterTest { function setUp() public virtual override { - ERC20TokenholderCasterTest.setUp(); + ERC20TokenHolderCasterTest.setUp(); } function createOffchainSignature(ActionInfo memory _actionInfo, uint256 privateKey) @@ -240,26 +243,21 @@ contract CastApprovalBySig is ERC20TokenholderCasterTest { view returns (uint8 v, bytes32 r, bytes32 s) { - LlamaCoreSigUtils.CastApproval memory castApproval = LlamaCoreSigUtils.CastApproval({ - actionInfo: _actionInfo, - support: 1, - reason: "", - tokenHolder: tokenHolder1, - nonce: 0 - }); - bytes32 digest = getCastApprovalTypedDataHash(castApproval); + LlamaCoreSigUtils.CastVote memory castVote = + LlamaCoreSigUtils.CastVote({actionInfo: _actionInfo, support: 1, reason: "", tokenHolder: tokenHolder1, nonce: 0}); + bytes32 digest = getCastVoteTypedDataHash(castVote); (v, r, s) = vm.sign(privateKey, digest); } - function castApprovalBySig(ActionInfo memory _actionInfo, uint8 support, uint8 v, bytes32 r, bytes32 s) internal { - erc20TokenholderCaster.castApprovalBySig(tokenHolder1, support, _actionInfo, "", v, r, s); + function castVoteBySig(ActionInfo memory _actionInfo, uint8 support, uint8 v, bytes32 r, bytes32 s) internal { + erc20TokenHolderCaster.castVoteBySig(tokenHolder1, support, _actionInfo, "", v, r, s); } - function test_CastsApprovalBySig() public { + function test_CastsVoteBySig() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); vm.expectEmit(); - emit ApprovalCast( + emit VoteCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -268,33 +266,33 @@ contract CastApprovalBySig is ERC20TokenholderCasterTest { "" ); - castApprovalBySig(actionInfo, 1, v, r, s); + castVoteBySig(actionInfo, 1, v, r, s); } function test_CheckNonceIncrements() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - assertEq(erc20TokenholderCaster.nonces(tokenHolder1, TokenholderCaster.castApprovalBySig.selector), 0); - castApprovalBySig(actionInfo, 1, v, r, s); - assertEq(erc20TokenholderCaster.nonces(tokenHolder1, TokenholderCaster.castApprovalBySig.selector), 1); + assertEq(erc20TokenHolderCaster.nonces(tokenHolder1, TokenHolderCaster.castVoteBySig.selector), 0); + castVoteBySig(actionInfo, 1, v, r, s); + assertEq(erc20TokenHolderCaster.nonces(tokenHolder1, TokenHolderCaster.castVoteBySig.selector), 1); } function test_OperationCannotBeReplayed() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - castApprovalBySig(actionInfo, 1, v, r, s); + castVoteBySig(actionInfo, 1, v, r, s); // Invalid Signature error since the recovered signer address during the second call is not the same as - // erc20VotesTokenholder since nonce has increased. - vm.expectRevert(TokenholderCaster.InvalidSignature.selector); - castApprovalBySig(actionInfo, 1, v, r, s); + // erc20VotesTokenHolder since nonce has increased. + vm.expectRevert(TokenHolderCaster.InvalidSignature.selector); + castVoteBySig(actionInfo, 1, v, r, s); } function test_RevertIf_SignerIsNotTokenHolder() public { (, uint256 randomSignerPrivateKey) = makeAddrAndKey("randomSigner"); (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, randomSignerPrivateKey); - // Invalid Signature error since the recovered signer address is not the same as the erc20VotesTokenholder passed + // Invalid Signature error since the recovered signer address is not the same as the erc20VotesTokenHolder passed // in as parameter. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castApprovalBySig(actionInfo, 1, v, r, s); + castVoteBySig(actionInfo, 1, v, r, s); } function test_RevertIf_SignerIsZeroAddress() public { @@ -302,81 +300,81 @@ contract CastApprovalBySig is ERC20TokenholderCasterTest { // Invalid Signature error since the recovered signer address is zero address due to invalid signature values // (v,r,s). vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castApprovalBySig(actionInfo, 1, (v + 1), r, s); + castVoteBySig(actionInfo, 1, (v + 1), r, s); } function test_RevertIf_TokenHolderIncrementsNonce() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); vm.prank(tokenHolder1); - erc20TokenholderCaster.incrementNonce(ILlamaCore.castApprovalBySig.selector); + erc20TokenHolderCaster.incrementNonce(TokenHolderCaster.castVoteBySig.selector); // Invalid Signature error since the recovered signer address during the call is not the same as - // erc20VotesTokenholder since nonce has increased. + // erc20VotesTokenHolder since nonce has increased. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castApprovalBySig(actionInfo, 1, v, r, s); + castVoteBySig(actionInfo, 1, v, r, s); } } -contract CastDisapproval is ERC20TokenholderCasterTest { +contract CastVeto is ERC20TokenHolderCasterTest { function setUp() public virtual override { - ERC20TokenholderCasterTest.setUp(); + ERC20TokenHolderCasterTest.setUp(); - castApprovalsFor(); + castVoteFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); vm.prank(tokenHolder1); - erc20TokenholderCaster.submitApprovals(actionInfo); + erc20TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_ActionInfoMismatch(ActionInfo memory notActionInfo) public { vm.assume(notActionInfo.id != actionInfo.id); vm.expectRevert(); - erc20TokenholderCaster.castDisapproval(notActionInfo, tokenVotingCasterRole, ""); + erc20TokenHolderCaster.castVeto(notActionInfo, tokenVotingCasterRole, ""); } - function test_RevertsIf_DisapprovalNotEnabled() public { - ERC20TokenholderCaster casterWithWrongRole = ERC20TokenholderCaster( + function test_RevertsIf_VetoNotEnabled() public { + ERC20TokenHolderCaster casterWithWrongRole = ERC20TokenHolderCaster( Clones.cloneDeterministic( - address(erc20TokenholderCasterLogic), keccak256(abi.encodePacked(address(erc20VotesToken), msg.sender)) + address(erc20TokenHolderCasterLogic), keccak256(abi.encodePacked(address(erc20VotesToken), msg.sender)) ) ); casterWithWrongRole.initialize(erc20VotesToken, CORE, madeUpRole, ERC20_MIN_APPROVAL_PCT, ERC20_MIN_DISAPPROVAL_PCT); vm.expectRevert(abi.encodeWithSelector(ILlamaRelativeStrategyBase.InvalidRole.selector, tokenVotingCasterRole)); - casterWithWrongRole.castDisapproval(actionInfo, madeUpRole, ""); + casterWithWrongRole.castVeto(actionInfo, madeUpRole, ""); } - function test_RevertsIf_AlreadyCastApproval() public { + function test_RevertsIf_AlreadyCastVote() public { vm.startPrank(tokenHolder1); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVeto(actionInfo, 1, ""); - vm.expectRevert(TokenholderCaster.AlreadyCastDisapproval.selector); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, ""); + vm.expectRevert(TokenHolderCaster.AlreadyCastVeto.selector); + erc20TokenHolderCaster.castVeto(actionInfo, 1, ""); } function test_RevertsIf_InvalidSupport() public { - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidSupport.selector, uint8(3))); - erc20TokenholderCaster.castDisapproval(actionInfo, 3, ""); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidSupport.selector, uint8(3))); + erc20TokenHolderCaster.castVeto(actionInfo, 3, ""); } function test_RevertsIf_CastingPeriodOver() public { // TODO why do we need to add 2 here - vm.warp(block.timestamp + 2 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); // 2/3 of the approval period - vm.expectRevert(TokenholderCaster.CastingPeriodOver.selector); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, ""); + vm.warp(block.timestamp + 2 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); // 2/3 of the voting period + vm.expectRevert(TokenHolderCaster.CastingPeriodOver.selector); + erc20TokenHolderCaster.castVeto(actionInfo, 1, ""); } function test_RevertsIf_InsufficientBalance() public { - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InsufficientBalance.selector, 0)); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, ""); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InsufficientBalance.selector, 0)); + erc20TokenHolderCaster.castVeto(actionInfo, 1, ""); } - function test_CastsDisapprovalCorrectly(uint8 support) public { + function test_CastsVetoCorrectly(uint8 support) public { support = uint8(bound(support, 0, 2)); vm.expectEmit(); - emit DisapprovalCast( + emit VetoCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -385,12 +383,12 @@ contract CastDisapproval is ERC20TokenholderCasterTest { "" ); vm.prank(tokenHolder1); - erc20TokenholderCaster.castDisapproval(actionInfo, support, ""); + erc20TokenHolderCaster.castVeto(actionInfo, support, ""); } - function test_CastsDisapprovalCorrectly_WithReason() public { + function test_CastsVetoCorrectly_WithReason() public { vm.expectEmit(); - emit DisapprovalCast( + emit VetoCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -399,20 +397,20 @@ contract CastDisapproval is ERC20TokenholderCasterTest { "reason" ); vm.prank(tokenHolder1); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, "reason"); + erc20TokenHolderCaster.castVeto(actionInfo, 1, "reason"); } } -contract CastDisapprovalBySig is ERC20TokenholderCasterTest { +contract CastVetoBySig is ERC20TokenHolderCasterTest { function setUp() public virtual override { - ERC20TokenholderCasterTest.setUp(); + ERC20TokenHolderCasterTest.setUp(); - castApprovalsFor(); + castVoteFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); vm.prank(tokenHolder1); - erc20TokenholderCaster.submitApprovals(actionInfo); + erc20TokenHolderCaster.submitVotes(actionInfo); } function createOffchainSignature(ActionInfo memory _actionInfo, uint256 privateKey) @@ -420,26 +418,21 @@ contract CastDisapprovalBySig is ERC20TokenholderCasterTest { view returns (uint8 v, bytes32 r, bytes32 s) { - LlamaCoreSigUtils.CastDisapproval memory castDisapproval = LlamaCoreSigUtils.CastDisapproval({ - actionInfo: _actionInfo, - support: 1, - reason: "", - tokenHolder: tokenHolder1, - nonce: 0 - }); - bytes32 digest = getCastDisapprovalTypedDataHash(castDisapproval); + LlamaCoreSigUtils.CastVeto memory castVeto = + LlamaCoreSigUtils.CastVeto({actionInfo: _actionInfo, support: 1, reason: "", tokenHolder: tokenHolder1, nonce: 0}); + bytes32 digest = getCastVetoTypedDataHash(castVeto); (v, r, s) = vm.sign(privateKey, digest); } - function castDisapprovalBySig(ActionInfo memory _actionInfo, uint8 v, bytes32 r, bytes32 s) internal { - erc20TokenholderCaster.castDisapprovalBySig(tokenHolder1, 1, _actionInfo, "", v, r, s); + function castVetoBySig(ActionInfo memory _actionInfo, uint8 v, bytes32 r, bytes32 s) internal { + erc20TokenHolderCaster.castVetoBySig(tokenHolder1, 1, _actionInfo, "", v, r, s); } - function test_CastsDisapprovalBySig() public { + function test_CastsVetoBySig() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); vm.expectEmit(); - emit DisapprovalCast( + emit VetoCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -448,38 +441,38 @@ contract CastDisapprovalBySig is ERC20TokenholderCasterTest { "" ); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); - // assertEq(CORE.getAction(0).totalDisapprovals, 1); - // assertEq(CORE.disapprovals(0, disapproverDrake), true); + // assertEq(CORE.getAction(0).totalVetos, 1); + // assertEq(CORE.vetos(0, disapproverDrake), true); } function test_CheckNonceIncrements() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - assertEq(erc20TokenholderCaster.nonces(tokenHolder1, ILlamaCore.castDisapprovalBySig.selector), 0); - castDisapprovalBySig(actionInfo, v, r, s); - assertEq(erc20TokenholderCaster.nonces(tokenHolder1, ILlamaCore.castDisapprovalBySig.selector), 1); + assertEq(erc20TokenHolderCaster.nonces(tokenHolder1, TokenHolderCaster.castVetoBySig.selector), 0); + castVetoBySig(actionInfo, v, r, s); + assertEq(erc20TokenHolderCaster.nonces(tokenHolder1, TokenHolderCaster.castVetoBySig.selector), 1); } function test_OperationCannotBeReplayed() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); // Invalid Signature error since the recovered signer address during the second call is not the same as - // erc20VotesTokenholder + // erc20VotesTokenHolder // since nonce has increased. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); } function test_RevertIf_SignerIsNotPolicyHolder() public { (, uint256 randomSignerPrivateKey) = makeAddrAndKey("randomSigner"); (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, randomSignerPrivateKey); // Invalid Signature error since the recovered signer address during the second call is not the same as - // erc20VotesTokenholder + // erc20VotesTokenHolder // since nonce has increased. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); } function test_RevertIf_SignerIsZeroAddress() public { @@ -487,27 +480,27 @@ contract CastDisapprovalBySig is ERC20TokenholderCasterTest { // Invalid Signature error since the recovered signer address is zero address due to invalid signature values // (v,r,s). vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castDisapprovalBySig(actionInfo, (v + 1), r, s); + castVetoBySig(actionInfo, (v + 1), r, s); } function test_RevertIf_PolicyholderIncrementsNonce() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); vm.prank(tokenHolder1); - erc20TokenholderCaster.incrementNonce(ILlamaCore.castDisapprovalBySig.selector); + erc20TokenHolderCaster.incrementNonce(TokenHolderCaster.castVetoBySig.selector); // Invalid Signature error since the recovered signer address during the second call is not the same as policyholder // since nonce has increased. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); } - function test_FailsIfDisapproved() public { + function test_FailsIfVetoed() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - // First disapproval. + // First veto. vm.expectEmit(); - emit DisapprovalCast( + emit VetoCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -515,16 +508,16 @@ contract CastDisapprovalBySig is ERC20TokenholderCasterTest { erc20VotesToken.getPastVotes(tokenHolder1, erc20VotesToken.clock() - 1), "" ); - castDisapprovalBySig(actionInfo, v, r, s); - // assertEq(CORE.getAction(actionInfo.id).totalDisapprovals, 1); + castVetoBySig(actionInfo, v, r, s); + // assertEq(CORE.getAction(actionInfo.id).totalVetos, 1); - // Second disapproval. + // Second veto. vm.prank(tokenHolder2); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVeto(actionInfo, 1, ""); vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - erc20TokenholderCaster.submitDisapprovals(actionInfo); + erc20TokenHolderCaster.submitVetos(actionInfo); // Assertions. ActionState state = ActionState(CORE.getActionState(actionInfo)); @@ -535,11 +528,11 @@ contract CastDisapprovalBySig is ERC20TokenholderCasterTest { } } -contract SubmitApprovals is ERC20TokenholderCasterTest { +contract SubmitVotes is ERC20TokenHolderCasterTest { function setUp() public virtual override { - ERC20TokenholderCasterTest.setUp(); + ERC20TokenHolderCasterTest.setUp(); - castApprovalsFor(); + castVoteFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); } @@ -547,91 +540,91 @@ contract SubmitApprovals is ERC20TokenholderCasterTest { function test_RevertsIf_ActionInfoMismatch(ActionInfo memory notActionInfo) public { vm.assume(notActionInfo.id != actionInfo.id); vm.expectRevert(); - erc20TokenholderCaster.submitApprovals(notActionInfo); + erc20TokenHolderCaster.submitVotes(notActionInfo); } - function test_RevertsIf_AlreadySubmittedApproval() public { + function test_RevertsIf_AlreadySubmittedVotes() public { vm.startPrank(tokenHolder1); - erc20TokenholderCaster.submitApprovals(actionInfo); + erc20TokenHolderCaster.submitVotes(actionInfo); - vm.expectRevert(TokenholderCaster.AlreadySubmittedApproval.selector); - erc20TokenholderCaster.submitApprovals(actionInfo); + vm.expectRevert(TokenHolderCaster.AlreadySubmittedVotes.selector); + erc20TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_SubmissionPeriodOver() public { // TODO why do we need to add 2 here - vm.warp(block.timestamp + ((1 days * ONE_THIRD_IN_BPS) / ONE_HUNDRED_IN_BPS) + 2); // 1/3 of the approval period - vm.expectRevert(TokenholderCaster.SubmissionPeriodOver.selector); - erc20TokenholderCaster.submitApprovals(actionInfo); + vm.warp(block.timestamp + ((1 days * ONE_THIRD_IN_BPS) / ONE_HUNDRED_IN_BPS) + 2); // 1/3 of the voting period + vm.expectRevert(TokenHolderCaster.SubmissionPeriodOver.selector); + erc20TokenHolderCaster.submitVotes(actionInfo); } - function test_RevertsIf_InsufficientApprovals() public { + function test_RevertsIf_InsufficientVotes() public { actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InsufficientApprovals.selector, 0, 75_000e18)); - erc20TokenholderCaster.submitApprovals(actionInfo); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InsufficientVotes.selector, 0, 75_000e18)); + erc20TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_CastingPeriodNotOver() public { actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); - vm.warp(block.timestamp + (1 days * ONE_THIRD_IN_BPS) / ONE_HUNDRED_IN_BPS); // 1/3 of the approval period - vm.expectRevert(TokenholderCaster.CantSubmitYet.selector); - erc20TokenholderCaster.submitApprovals(actionInfo); + vm.warp(block.timestamp + (1 days * ONE_THIRD_IN_BPS) / ONE_HUNDRED_IN_BPS); // 1/3 of the voting period + vm.expectRevert(TokenHolderCaster.CantSubmitYet.selector); + erc20TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_ForDoesNotSurpassAgainst() public { actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); vm.prank(tokenHolder1); - erc20TokenholderCaster.castApproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVote(actionInfo, 1, ""); vm.prank(tokenHolder2); - erc20TokenholderCaster.castApproval(actionInfo, 0, ""); + erc20TokenHolderCaster.castVote(actionInfo, 0, ""); vm.prank(tokenHolder3); - erc20TokenholderCaster.castApproval(actionInfo, 0, ""); + erc20TokenHolderCaster.castVote(actionInfo, 0, ""); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.ForDoesNotSurpassAgainst.selector, 250_000e18, 500_000e18)); - erc20TokenholderCaster.submitApprovals(actionInfo); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.ForDoesNotSurpassAgainst.selector, 250_000e18, 500_000e18)); + erc20TokenHolderCaster.submitVotes(actionInfo); } - function test_SubmitsApprovalsCorrectly() public { + function test_SubmitsVotesCorrectly() public { vm.expectEmit(); - emit ApprovalsSubmitted(actionInfo.id, 750_000e18, 0, 0); - erc20TokenholderCaster.submitApprovals(actionInfo); + emit VotesSubmitted(actionInfo.id, 750_000e18, 0, 0); + erc20TokenHolderCaster.submitVotes(actionInfo); } } -contract SubmitDisapprovals is ERC20TokenholderCasterTest { +contract SubmitVetos is ERC20TokenHolderCasterTest { function setUp() public virtual override { - ERC20TokenholderCasterTest.setUp(); + ERC20TokenHolderCasterTest.setUp(); - castApprovalsFor(); + castVoteFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - erc20TokenholderCaster.submitApprovals(actionInfo); + erc20TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_ActionInfoMismatch(ActionInfo memory notActionInfo) public { vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); vm.assume(notActionInfo.id != actionInfo.id); vm.expectRevert(); - erc20TokenholderCaster.submitDisapprovals(notActionInfo); + erc20TokenHolderCaster.submitVetos(notActionInfo); } - function test_RevertsIf_DisapprovalNotEnabled() public { + function test_RevertsIf_VetoNotEnabled() public { vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - ERC20TokenholderCaster casterWithWrongRole = ERC20TokenholderCaster( + ERC20TokenHolderCaster casterWithWrongRole = ERC20TokenHolderCaster( Clones.cloneDeterministic( - address(erc20TokenholderCasterLogic), keccak256(abi.encodePacked(address(erc20VotesToken), msg.sender)) + address(erc20TokenHolderCasterLogic), keccak256(abi.encodePacked(address(erc20VotesToken), msg.sender)) ) ); casterWithWrongRole.initialize(erc20VotesToken, CORE, madeUpRole, ERC20_MIN_APPROVAL_PCT, ERC20_MIN_DISAPPROVAL_PCT); vm.expectRevert(abi.encodeWithSelector(ILlamaRelativeStrategyBase.InvalidRole.selector, tokenVotingCasterRole)); - casterWithWrongRole.submitDisapprovals(actionInfo); + casterWithWrongRole.submitVetos(actionInfo); } - function test_RevertsIf_AlreadySubmittedDisapproval() public { + function test_RevertsIf_AlreadySubmittedVetos() public { Action memory action = CORE.getAction(actionInfo.id); vm.warp( action.minExecutionTime @@ -639,61 +632,61 @@ contract SubmitDisapprovals is ERC20TokenholderCasterTest { / ONE_HUNDRED_IN_BPS ); - castDisapprovalsFor(); + castVetosFor(); vm.startPrank(tokenHolder1); - erc20TokenholderCaster.submitDisapprovals(actionInfo); + erc20TokenHolderCaster.submitVetos(actionInfo); - vm.expectRevert(TokenholderCaster.AlreadySubmittedDisapproval.selector); - erc20TokenholderCaster.submitDisapprovals(actionInfo); + vm.expectRevert(TokenHolderCaster.AlreadySubmittedVetos.selector); + erc20TokenHolderCaster.submitVetos(actionInfo); } function test_RevertsIf_SubmissionPeriodOver() public { - castDisapprovalsFor(); + castVetosFor(); vm.warp(block.timestamp + 1 days); - vm.expectRevert(TokenholderCaster.SubmissionPeriodOver.selector); - erc20TokenholderCaster.submitDisapprovals(actionInfo); + vm.expectRevert(TokenHolderCaster.SubmissionPeriodOver.selector); + erc20TokenHolderCaster.submitVetos(actionInfo); } - function test_RevertsIf_InsufficientDisapprovals() public { + function test_RevertsIf_InsufficientVetos() public { actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); - castApprovalsFor(); + castVoteFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - erc20TokenholderCaster.submitApprovals(actionInfo); + erc20TokenHolderCaster.submitVotes(actionInfo); //TODO why add 1 here vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InsufficientApprovals.selector, 0, 75_000e18)); - erc20TokenholderCaster.submitDisapprovals(actionInfo); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InsufficientVotes.selector, 0, 75_000e18)); + erc20TokenHolderCaster.submitVetos(actionInfo); } function test_RevertsIf_CastingPeriodNotOver() public { - vm.warp(block.timestamp + (1 days * 3333) / ONE_HUNDRED_IN_BPS); // 1/3 of the approval period - vm.expectRevert(TokenholderCaster.CantSubmitYet.selector); - erc20TokenholderCaster.submitDisapprovals(actionInfo); + vm.warp(block.timestamp + (1 days * 3333) / ONE_HUNDRED_IN_BPS); // 1/3 of the voting period + vm.expectRevert(TokenHolderCaster.CantSubmitYet.selector); + erc20TokenHolderCaster.submitVetos(actionInfo); } function test_RevertsIf_ForDoesNotSurpassAgainst() public { vm.prank(tokenHolder1); - erc20TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc20TokenHolderCaster.castVeto(actionInfo, 1, ""); vm.prank(tokenHolder2); - erc20TokenholderCaster.castDisapproval(actionInfo, 0, ""); + erc20TokenHolderCaster.castVeto(actionInfo, 0, ""); vm.prank(tokenHolder3); - erc20TokenholderCaster.castDisapproval(actionInfo, 0, ""); + erc20TokenHolderCaster.castVeto(actionInfo, 0, ""); // TODO why add 1 here? vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.ForDoesNotSurpassAgainst.selector, 250_000e18, 500_000e18)); - erc20TokenholderCaster.submitDisapprovals(actionInfo); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.ForDoesNotSurpassAgainst.selector, 250_000e18, 500_000e18)); + erc20TokenHolderCaster.submitVetos(actionInfo); } - function test_SubmitsDisapprovalsCorrectly() public { - castDisapprovalsFor(); + function test_SubmitsVetosCorrectly() public { + castVetosFor(); //TODO why add 1 here? vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); vm.expectEmit(); - emit DisapprovalsSubmitted(actionInfo.id, 750_000e18, 0, 0); - erc20TokenholderCaster.submitDisapprovals(actionInfo); + emit VetosSubmitted(actionInfo.id, 750_000e18, 0, 0); + erc20TokenHolderCaster.submitVetos(actionInfo); } } diff --git a/test/token-voting/ERC721TokenholderActionCreator.t.sol b/test/token-voting/ERC721TokenholderActionCreator.t.sol index 3a117f3..7fe8ff9 100644 --- a/test/token-voting/ERC721TokenholderActionCreator.t.sol +++ b/test/token-voting/ERC721TokenholderActionCreator.t.sol @@ -10,10 +10,10 @@ import {ILlamaCore} from "src/interfaces/ILlamaCore.sol"; import {ILlamaStrategy} from "src/interfaces/ILlamaStrategy.sol"; import {ActionState} from "src/lib/Enums.sol"; import {Action, ActionInfo} from "src/lib/Structs.sol"; -import {ERC721TokenholderActionCreator} from "src/token-voting/ERC721TokenholderActionCreator.sol"; -import {TokenholderActionCreator} from "src/token-voting/TokenholderActionCreator.sol"; +import {ERC721TokenHolderActionCreator} from "src/token-voting/ERC721TokenHolderActionCreator.sol"; +import {TokenHolderActionCreator} from "src/token-voting/TokenHolderActionCreator.sol"; -contract ERC721TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaCoreSigUtils { +contract ERC721TokenHolderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaCoreSigUtils { event ActionCreated( uint256 id, address indexed creator, @@ -29,7 +29,7 @@ contract ERC721TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaC event ActionThresholdSet(uint256 newThreshold); - ERC721TokenholderActionCreator erc721TokenholderActionCreator; + ERC721TokenHolderActionCreator erc721TokenHolderActionCreator; function setUp() public virtual override { LlamaTokenVotingTestSetup.setUp(); @@ -42,7 +42,7 @@ contract ERC721TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaC mineBlock(); // Deploy ERC20 Token Voting Module. - (erc721TokenholderActionCreator,) = _deployERC721TokenVotingModuleAndSetRole(); + (erc721TokenHolderActionCreator,) = _deployERC721TokenVotingModuleAndSetRole(); // Setting ERC20TokenHolderActionCreator's EIP-712 Domain Hash setDomainHash( @@ -50,22 +50,22 @@ contract ERC721TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaC name: CORE.name(), version: "1", chainId: block.chainid, - verifyingContract: address(erc721TokenholderActionCreator) + verifyingContract: address(erc721TokenHolderActionCreator) }) ); } } -// contract Constructor is ERC721TokenholderActionCreatorTest { +// contract Constructor is ERC721TokenHolderActionCreatorTest { // function test_RevertsIf_InvalidLlamaCore() public { -// // With invalid LlamaCore instance, TokenholderActionCreator.InvalidLlamaCoreAddress is unreachable +// // With invalid LlamaCore instance, TokenHolderActionCreator.InvalidLlamaCoreAddress is unreachable // vm.expectRevert(); -// new ERC721TokenholderActionCreator(erc721VotesToken, ILlamaCore(makeAddr("invalid-llama-core")), uint256(0)); +// new ERC721TokenHolderActionCreator(erc721VotesToken, ILlamaCore(makeAddr("invalid-llama-core")), uint256(0)); // } // function test_RevertsIf_InvalidTokenAddress() public { // vm.expectRevert(); // will EvmError: Revert vecause totalSupply fn does not exist -// new ERC721TokenholderActionCreator(ERC20Votes(makeAddr("invalid-erc721VotesToken")), CORE, uint256(0)); +// new ERC721TokenHolderActionCreator(ERC20Votes(makeAddr("invalid-erc721VotesToken")), CORE, uint256(0)); // } // function test_RevertsIf_CreationThresholdExceedsTotalSupply() public { @@ -74,8 +74,8 @@ contract ERC721TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaC // vm.warp(block.timestamp + 1); -// vm.expectRevert(TokenholderActionCreator.InvalidCreationThreshold.selector); -// new ERC721TokenholderActionCreator(erc721VotesToken, CORE, 17_000_000_000_000_000_000_000_000); +// vm.expectRevert(TokenHolderActionCreator.InvalidCreationThreshold.selector); +// new ERC721TokenHolderActionCreator(erc721VotesToken, CORE, 17_000_000_000_000_000_000_000_000); // } // function test_ProperlySetsConstructorArguments() public { @@ -85,17 +85,17 @@ contract ERC721TokenholderActionCreatorTest is LlamaTokenVotingTestSetup, LlamaC // vm.warp(block.timestamp + 1); -// ERC721TokenholderActionCreator erc721TokenholderActionCreator = new -// ERC721TokenholderActionCreator(erc721VotesToken, +// ERC721TokenHolderActionCreator erc721TokenHolderActionCreator = new +// ERC721TokenHolderActionCreator(erc721VotesToken, // CORE, // threshold); -// assertEq(address(erc721TokenholderActionCreator.TOKEN()), address(erc721VotesToken)); -// assertEq(address(erc721TokenholderActionCreator.LLAMA_CORE()), address(CORE)); -// assertEq(erc721TokenholderActionCreator.creationThreshold(), threshold); +// assertEq(address(erc721TokenHolderActionCreator.TOKEN()), address(erc721VotesToken)); +// assertEq(address(erc721TokenHolderActionCreator.LLAMA_CORE()), address(CORE)); +// assertEq(erc721TokenHolderActionCreator.creationThreshold(), threshold); // } // } -contract CreateAction is ERC721TokenholderActionCreatorTest { +contract CreateAction is ERC721TokenHolderActionCreatorTest { bytes data = abi.encodeCall(mockProtocol.pause, (true)); function test_RevertsIf_InsufficientBalance() public { @@ -105,12 +105,12 @@ contract CreateAction is ERC721TokenholderActionCreatorTest { mineBlock(); - vm.expectRevert(abi.encodeWithSelector(TokenholderActionCreator.InsufficientBalance.selector, 0)); + vm.expectRevert(abi.encodeWithSelector(TokenHolderActionCreator.InsufficientBalance.selector, 0)); vm.prank(notTokenHolder); - erc721TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + erc721TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); } - function test_RevertsIf_TokenholderActionCreatorDoesNotHavePermission() public { + function test_RevertsIf_TokenHolderActionCreatorDoesNotHavePermission() public { erc721VotesToken.mint(tokenHolder1, ERC721_CREATION_THRESHOLD); vm.prank(tokenHolder1); erc721VotesToken.delegate(tokenHolder1); @@ -119,12 +119,12 @@ contract CreateAction is ERC721TokenholderActionCreatorTest { vm.expectRevert(ILlamaCore.PolicyholderDoesNotHavePermission.selector); vm.prank(tokenHolder1); - erc721TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + erc721TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); } function test_ProperlyCreatesAction() public { - // Assigns Permission to TokenholderActionCreator. - _setRolePermissionToTokenholderActionCreator(); + // Assigns Permission to TokenHolderActionCreator. + _setRolePermissionToTokenHolderActionCreator(); // Mint tokens to tokenholder so that they can create action. erc721VotesToken.mint(tokenHolder1, ERC721_CREATION_THRESHOLD); @@ -141,7 +141,7 @@ contract CreateAction is ERC721TokenholderActionCreatorTest { actionCount, address(tokenHolder1), tokenVotingActionCreatorRole, STRATEGY, address(mockProtocol), 0, data, "" ); vm.prank(tokenHolder1); - uint256 actionId = erc721TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + uint256 actionId = erc721TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); Action memory action = CORE.getAction(actionId); assertEq(actionId, actionCount); @@ -149,12 +149,12 @@ contract CreateAction is ERC721TokenholderActionCreatorTest { } } -contract CreateActionBySig is ERC721TokenholderActionCreatorTest { +contract CreateActionBySig is ERC721TokenHolderActionCreatorTest { function setUp() public virtual override { - ERC721TokenholderActionCreatorTest.setUp(); + ERC721TokenHolderActionCreatorTest.setUp(); - // Assigns Permission to TokenholderActionCreator. - _setRolePermissionToTokenholderActionCreator(); + // Assigns Permission to TokenHolderActionCreator. + _setRolePermissionToTokenHolderActionCreator(); // Mint tokens to tokenholder so that they can create action. erc721VotesToken.mint(tokenHolder1, ERC721_CREATION_THRESHOLD); @@ -188,7 +188,7 @@ contract CreateActionBySig is ERC721TokenholderActionCreatorTest { } function createActionBySig(uint8 v, bytes32 r, bytes32 s) internal returns (uint256 actionId) { - actionId = erc721TokenholderActionCreator.createActionBySig( + actionId = erc721TokenHolderActionCreator.createActionBySig( tokenHolder1, STRATEGY, address(mockProtocol), 0, abi.encodeCall(mockProtocol.pause, (true)), "", v, r, s ); } @@ -231,7 +231,7 @@ contract CreateActionBySig is ERC721TokenholderActionCreatorTest { "# Action 0 \n This is my action." ); - uint256 actionId = erc721TokenholderActionCreator.createActionBySig( + uint256 actionId = erc721TokenHolderActionCreator.createActionBySig( tokenHolder1, STRATEGY, address(mockProtocol), @@ -252,11 +252,11 @@ contract CreateActionBySig is ERC721TokenholderActionCreatorTest { function test_CheckNonceIncrements() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(tokenHolder1PrivateKey); assertEq( - erc721TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.createActionBySig.selector), 0 + erc721TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.createActionBySig.selector), 0 ); createActionBySig(v, r, s); assertEq( - erc721TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.createActionBySig.selector), 1 + erc721TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.createActionBySig.selector), 1 ); } @@ -265,7 +265,7 @@ contract CreateActionBySig is ERC721TokenholderActionCreatorTest { createActionBySig(v, r, s); // Invalid Signature error since the recovered signer address during the second call is not the same as // policyholder since nonce has increased. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); createActionBySig(v, r, s); } @@ -274,7 +274,7 @@ contract CreateActionBySig is ERC721TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(randomSignerPrivateKey); // Invalid Signature error since the recovered signer address is not the same as the policyholder passed in as // parameter. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); createActionBySig(v, r, s); } @@ -282,7 +282,7 @@ contract CreateActionBySig is ERC721TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(tokenHolder1PrivateKey); // Invalid Signature error since the recovered signer address is zero address due to invalid signature values // (v,r,s). - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); createActionBySig((v + 1), r, s); } @@ -290,24 +290,24 @@ contract CreateActionBySig is ERC721TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(tokenHolder1PrivateKey); vm.prank(tokenHolder1); - erc721TokenholderActionCreator.incrementNonce(TokenholderActionCreator.createActionBySig.selector); + erc721TokenHolderActionCreator.incrementNonce(TokenHolderActionCreator.createActionBySig.selector); // Invalid Signature error since the recovered signer address during the call is not the same as policyholder // since nonce has increased. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); createActionBySig(v, r, s); } } -contract CancelAction is ERC721TokenholderActionCreatorTest { +contract CancelAction is ERC721TokenHolderActionCreatorTest { uint256 actionId; ActionInfo actionInfo; function setUp() public virtual override { - ERC721TokenholderActionCreatorTest.setUp(); + ERC721TokenHolderActionCreatorTest.setUp(); - // Assigns Permission to TokenholderActionCreator. - _setRolePermissionToTokenholderActionCreator(); + // Assigns Permission to TokenHolderActionCreator. + _setRolePermissionToTokenHolderActionCreator(); // Mint tokens to tokenholder so that they can create action. erc721VotesToken.mint(tokenHolder1, ERC721_CREATION_THRESHOLD); @@ -320,11 +320,11 @@ contract CancelAction is ERC721TokenholderActionCreatorTest { bytes memory data = abi.encodeCall(mockProtocol.pause, (true)); vm.prank(tokenHolder1); - actionId = erc721TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + actionId = erc721TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); actionInfo = ActionInfo( actionId, - address(erc721TokenholderActionCreator), + address(erc721TokenHolderActionCreator), tokenVotingActionCreatorRole, STRATEGY, address(mockProtocol), @@ -337,26 +337,26 @@ contract CancelAction is ERC721TokenholderActionCreatorTest { vm.expectEmit(); emit ActionCanceled(actionId, tokenHolder1); vm.prank(tokenHolder1); - erc721TokenholderActionCreator.cancelAction(actionInfo); + erc721TokenHolderActionCreator.cancelAction(actionInfo); } function test_RevertsIf_CallerIsNotActionCreator(address notCreator) public { vm.assume(notCreator != tokenHolder1); - vm.expectRevert(TokenholderActionCreator.OnlyActionCreator.selector); + vm.expectRevert(TokenHolderActionCreator.OnlyActionCreator.selector); vm.prank(notCreator); - erc721TokenholderActionCreator.cancelAction(actionInfo); + erc721TokenHolderActionCreator.cancelAction(actionInfo); } } -contract CancelActionBySig is ERC721TokenholderActionCreatorTest { +contract CancelActionBySig is ERC721TokenHolderActionCreatorTest { uint256 actionId; ActionInfo actionInfo; function setUp() public virtual override { - ERC721TokenholderActionCreatorTest.setUp(); + ERC721TokenHolderActionCreatorTest.setUp(); - // Assigns Permission to TokenholderActionCreator. - _setRolePermissionToTokenholderActionCreator(); + // Assigns Permission to TokenHolderActionCreator. + _setRolePermissionToTokenHolderActionCreator(); // Mint tokens to tokenholder so that they can create action. erc721VotesToken.mint(tokenHolder1, ERC721_CREATION_THRESHOLD); @@ -369,11 +369,11 @@ contract CancelActionBySig is ERC721TokenholderActionCreatorTest { bytes memory data = abi.encodeCall(mockProtocol.pause, (true)); vm.prank(tokenHolder1); - actionId = erc721TokenholderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); + actionId = erc721TokenHolderActionCreator.createAction(STRATEGY, address(mockProtocol), 0, data, ""); actionInfo = ActionInfo( actionId, - address(erc721TokenholderActionCreator), + address(erc721TokenHolderActionCreator), tokenVotingActionCreatorRole, STRATEGY, address(mockProtocol), @@ -390,14 +390,14 @@ contract CancelActionBySig is ERC721TokenholderActionCreatorTest { LlamaCoreSigUtils.CancelAction memory cancelAction = LlamaCoreSigUtils.CancelAction({ tokenHolder: tokenHolder1, actionInfo: _actionInfo, - nonce: erc721TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.cancelActionBySig.selector) + nonce: erc721TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.cancelActionBySig.selector) }); bytes32 digest = getCancelActionTypedDataHash(cancelAction); (v, r, s) = vm.sign(privateKey, digest); } function cancelActionBySig(ActionInfo memory _actionInfo, uint8 v, bytes32 r, bytes32 s) internal { - erc721TokenholderActionCreator.cancelActionBySig(tokenHolder1, _actionInfo, v, r, s); + erc721TokenHolderActionCreator.cancelActionBySig(tokenHolder1, _actionInfo, v, r, s); } function test_CancelActionBySig() public { @@ -416,11 +416,11 @@ contract CancelActionBySig is ERC721TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); assertEq( - erc721TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.cancelActionBySig.selector), 0 + erc721TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.cancelActionBySig.selector), 0 ); cancelActionBySig(actionInfo, v, r, s); assertEq( - erc721TokenholderActionCreator.nonces(tokenHolder1, TokenholderActionCreator.cancelActionBySig.selector), 1 + erc721TokenHolderActionCreator.nonces(tokenHolder1, TokenHolderActionCreator.cancelActionBySig.selector), 1 ); } @@ -429,7 +429,7 @@ contract CancelActionBySig is ERC721TokenholderActionCreatorTest { cancelActionBySig(actionInfo, v, r, s); // Invalid Signature error since the recovered signer address during the second call is not the same as policyholder // since nonce has increased. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); cancelActionBySig(actionInfo, v, r, s); } @@ -438,7 +438,7 @@ contract CancelActionBySig is ERC721TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, randomSignerPrivateKey); // Invalid Signature error since the recovered signer address is not the same as the policyholder passed in as // parameter. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); cancelActionBySig(actionInfo, v, r, s); } @@ -446,7 +446,7 @@ contract CancelActionBySig is ERC721TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); // Invalid Signature error since the recovered signer address is zero address due to invalid signature values // (v,r,s). - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); cancelActionBySig(actionInfo, (v + 1), r, s); } @@ -454,42 +454,42 @@ contract CancelActionBySig is ERC721TokenholderActionCreatorTest { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); vm.prank(tokenHolder1); - erc721TokenholderActionCreator.incrementNonce(TokenholderActionCreator.cancelActionBySig.selector); + erc721TokenHolderActionCreator.incrementNonce(TokenHolderActionCreator.cancelActionBySig.selector); // Invalid Signature error since the recovered signer address during the call is not the same as policyholder // since nonce has increased. - vm.expectRevert(TokenholderActionCreator.InvalidSignature.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidSignature.selector); cancelActionBySig(actionInfo, v, r, s); } } -contract SetActionThreshold is ERC721TokenholderActionCreatorTest { +contract SetActionThreshold is ERC721TokenHolderActionCreatorTest { function testFuzz_SetsCreationThreshold(uint256 threshold) public { threshold = bound(threshold, 0, erc721VotesToken.getPastTotalSupply(block.timestamp - 1)); - assertEq(erc721TokenholderActionCreator.creationThreshold(), ERC721_CREATION_THRESHOLD); + assertEq(erc721TokenHolderActionCreator.creationThreshold(), ERC721_CREATION_THRESHOLD); vm.expectEmit(); emit ActionThresholdSet(threshold); vm.prank(address(EXECUTOR)); - erc721TokenholderActionCreator.setActionThreshold(threshold); + erc721TokenHolderActionCreator.setActionThreshold(threshold); - assertEq(erc721TokenholderActionCreator.creationThreshold(), threshold); + assertEq(erc721TokenHolderActionCreator.creationThreshold(), threshold); } function testFuzz_RevertsIf_CreationThresholdExceedsTotalSupply(uint256 threshold) public { vm.assume(threshold > erc721VotesToken.getPastTotalSupply(block.timestamp - 1)); - vm.expectRevert(TokenholderActionCreator.InvalidCreationThreshold.selector); + vm.expectRevert(TokenHolderActionCreator.InvalidCreationThreshold.selector); vm.prank(address(EXECUTOR)); - erc721TokenholderActionCreator.setActionThreshold(threshold); + erc721TokenHolderActionCreator.setActionThreshold(threshold); } function testFuzz_RevertsIf_CalledByNotLlamaExecutor(address notLlamaExecutor) public { vm.assume(notLlamaExecutor != address(EXECUTOR)); - vm.expectRevert(TokenholderActionCreator.OnlyLlamaExecutor.selector); + vm.expectRevert(TokenHolderActionCreator.OnlyLlamaExecutor.selector); vm.prank(notLlamaExecutor); - erc721TokenholderActionCreator.setActionThreshold(ERC721_CREATION_THRESHOLD); + erc721TokenHolderActionCreator.setActionThreshold(ERC721_CREATION_THRESHOLD); } } diff --git a/test/token-voting/ERC721TokenholderCaster.t.sol b/test/token-voting/ERC721TokenholderCaster.t.sol index 40c7d1a..c831731 100644 --- a/test/token-voting/ERC721TokenholderCaster.t.sol +++ b/test/token-voting/ERC721TokenholderCaster.t.sol @@ -13,15 +13,15 @@ import {Action, ActionInfo, PermissionData} from "src/lib/Structs.sol"; import {ILlamaCore} from "src/interfaces/ILlamaCore.sol"; import {ILlamaRelativeStrategyBase} from "src/interfaces/ILlamaRelativeStrategyBase.sol"; import {ILlamaStrategy} from "src/interfaces/ILlamaStrategy.sol"; -import {ERC721TokenholderCaster} from "src/token-voting/ERC721TokenholderCaster.sol"; -import {TokenholderCaster} from "src/token-voting/TokenholderCaster.sol"; +import {ERC721TokenHolderCaster} from "src/token-voting/ERC721TokenHolderCaster.sol"; +import {TokenHolderCaster} from "src/token-voting/TokenHolderCaster.sol"; -contract ERC721TokenholderCasterTest is LlamaTokenVotingTestSetup, LlamaCoreSigUtils { - event ApprovalCast( +contract ERC721TokenHolderCasterTest is LlamaTokenVotingTestSetup, LlamaCoreSigUtils { + event VoteCast( uint256 id, address indexed policyholder, uint8 indexed role, uint8 indexed support, uint256 quantity, string reason ); - event ApprovalsSubmitted(uint256 id, uint96 quantityFor, uint96 quantityAgainst, uint96 quantityAbstain); + event VotesSubmitted(uint256 id, uint96 quantityFor, uint96 quantityAgainst, uint96 quantityAbstain); event DisapprovalCast( uint256 id, address indexed policyholder, uint8 indexed role, uint8 indexed support, uint256 quantity, string reason @@ -30,7 +30,7 @@ contract ERC721TokenholderCasterTest is LlamaTokenVotingTestSetup, LlamaCoreSigU event DisapprovalsSubmitted(uint256 id, uint96 quantityFor, uint96 quantityAgainst, uint96 quantityAbstain); ActionInfo actionInfo; - ERC721TokenholderCaster erc721TokenholderCaster; + ERC721TokenHolderCaster erc721TokenHolderCaster; ILlamaStrategy tokenVotingStrategy; function setUp() public virtual override { @@ -54,7 +54,7 @@ contract ERC721TokenholderCasterTest is LlamaTokenVotingTestSetup, LlamaCoreSigU mineBlock(); // Deploy ERC20 Token Voting Module. - (, erc721TokenholderCaster) = _deployERC721TokenVotingModuleAndSetRole(); + (, erc721TokenHolderCaster) = _deployERC721TokenVotingModuleAndSetRole(); // Mine block so that Token Voting Caster Role will have supply during action creation (due to past timestamp check) mineBlock(); @@ -62,41 +62,41 @@ contract ERC721TokenholderCasterTest is LlamaTokenVotingTestSetup, LlamaCoreSigU tokenVotingStrategy = _deployRelativeQuantityQuorumAndSetRolePermissionToCoreTeam(tokenVotingCasterRole); actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); - // Setting ERC721TokenholderCaster's EIP-712 Domain Hash + // Setting ERC721TokenHolderCaster's EIP-712 Domain Hash setDomainHash( LlamaCoreSigUtils.EIP712Domain({ name: CORE.name(), version: "1", chainId: block.chainid, - verifyingContract: address(erc721TokenholderCaster) + verifyingContract: address(erc721TokenHolderCaster) }) ); } - function castApprovalsFor() public { + function castVotesFor() public { vm.prank(tokenHolder1); - erc721TokenholderCaster.castApproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVote(actionInfo, 1, ""); vm.prank(tokenHolder2); - erc721TokenholderCaster.castApproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVote(actionInfo, 1, ""); vm.prank(tokenHolder3); - erc721TokenholderCaster.castApproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVote(actionInfo, 1, ""); } - function castDisapprovalsFor() public { + function castVetosFor() public { vm.prank(tokenHolder1); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVeto(actionInfo, 1, ""); vm.prank(tokenHolder2); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVeto(actionInfo, 1, ""); vm.prank(tokenHolder3); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVeto(actionInfo, 1, ""); } } -// contract Constructor is ERC721TokenholderCasterTest { +// contract Constructor is ERC721TokenHolderCasterTest { // function test_RevertsIf_InvalidLlamaCoreAddress() public { -// // With invalid LlamaCore instance, TokenholderActionCreator.InvalidLlamaCoreAddress is unreachable +// // With invalid LlamaCore instance, TokenHolderActionCreator.InvalidLlamaCoreAddress is unreachable // vm.expectRevert(); -// new ERC721TokenholderCaster( +// new ERC721TokenHolderCaster( // erc721VotesToken, ILlamaCore(makeAddr("invalid-llama-core")), tokenVotingCasterRole, uint256(1), uint256(1) // ); // } @@ -105,32 +105,32 @@ contract ERC721TokenholderCasterTest is LlamaTokenVotingTestSetup, LlamaCoreSigU // vm.assume(notAToken != address(0)); // vm.assume(notAToken != address(erc721VotesToken)); // vm.expectRevert(); // will revert with EvmError: Revert because `totalSupply` is not a function -// new ERC721TokenholderCaster( +// new ERC721TokenHolderCaster( // ERC20Votes(notAToken), ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), uint256(1) // ); // } // function test_RevertsIf_InvalidRole(uint8 role) public { // role = uint8(bound(role, POLICY.numRoles(), 255)); -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.RoleNotInitialized.selector, uint8(255))); -// new ERC721TokenholderCaster(erc721VotesToken, ILlamaCore(address(CORE)), uint8(255), uint256(1), uint256(1)); +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.RoleNotInitialized.selector, uint8(255))); +// new ERC721TokenHolderCaster(erc721VotesToken, ILlamaCore(address(CORE)), uint8(255), uint256(1), uint256(1)); // } -// function test_RevertsIf_InvalidMinApprovalPct() public { -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidMinApprovalPct.selector, uint256(0))); -// new ERC721TokenholderCaster(erc721VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(0), +// function test_RevertsIf_InvalidMinVotePct() public { +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidMinVotePct.selector, uint256(0))); +// new ERC721TokenHolderCaster(erc721VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(0), // uint256(1)); -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidMinApprovalPct.selector, uint256(10_001))); -// new ERC721TokenholderCaster(erc721VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(10_001), +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidMinVotePct.selector, uint256(10_001))); +// new ERC721TokenHolderCaster(erc721VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(10_001), // uint256(1)); // } // function test_RevertsIf_InvalidMinDisapprovalPct() public { -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidMinDisapprovalPct.selector, uint256(0))); -// new ERC721TokenholderCaster(erc721VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidMinDisapprovalPct.selector, uint256(0))); +// new ERC721TokenHolderCaster(erc721VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), // uint256(0)); -// vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidMinDisapprovalPct.selector, uint256(10_001))); -// new ERC721TokenholderCaster(erc721VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), +// vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidMinDisapprovalPct.selector, uint256(10_001))); +// new ERC721TokenHolderCaster(erc721VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, uint256(1), // uint256(10_001)); // } @@ -139,30 +139,30 @@ contract ERC721TokenholderCasterTest is LlamaTokenVotingTestSetup, LlamaCoreSigU // interface // // without the `mint` function -// erc721TokenholderCaster = new ERC721TokenholderCaster( +// erc721TokenHolderCaster = new ERC721TokenHolderCaster( // erc721VotesToken, ILlamaCore(address(CORE)), tokenVotingCasterRole, DEFAULT_APPROVAL_THRESHOLD, // DEFAULT_APPROVAL_THRESHOLD // ); -// assertEq(address(erc721TokenholderCaster.LLAMA_CORE()), address(CORE)); -// assertEq(address(erc721TokenholderCaster.TOKEN()), address(erc721VotesToken)); -// assertEq(erc721TokenholderCaster.ROLE(), tokenVotingCasterRole); -// assertEq(erc721TokenholderCaster.MIN_APPROVAL_PCT(), DEFAULT_APPROVAL_THRESHOLD); -// assertEq(erc721TokenholderCaster.MIN_DISAPPROVAL_PCT(), DEFAULT_APPROVAL_THRESHOLD); +// assertEq(address(erc721TokenHolderCaster.LLAMA_CORE()), address(CORE)); +// assertEq(address(erc721TokenHolderCaster.TOKEN()), address(erc721VotesToken)); +// assertEq(erc721TokenHolderCaster.ROLE(), tokenVotingCasterRole); +// assertEq(erc721TokenHolderCaster.MIN_APPROVAL_PCT(), DEFAULT_APPROVAL_THRESHOLD); +// assertEq(erc721TokenHolderCaster.MIN_DISAPPROVAL_PCT(), DEFAULT_APPROVAL_THRESHOLD); // } // } -contract CastApproval is ERC721TokenholderCasterTest { +contract CastVote is ERC721TokenHolderCasterTest { function test_RevertsIf_ActionInfoMismatch(ActionInfo memory notActionInfo) public { vm.assume(notActionInfo.id != actionInfo.id); vm.expectRevert(); - erc721TokenholderCaster.castApproval(notActionInfo, 1, ""); + erc721TokenHolderCaster.castVote(notActionInfo, 1, ""); } - function test_RevertsIf_ApprovalNotEnabled() public { - ERC721TokenholderCaster casterWithWrongRole = ERC721TokenholderCaster( + function test_RevertsIf_VoteNotEnabled() public { + ERC721TokenHolderCaster casterWithWrongRole = ERC721TokenHolderCaster( Clones.cloneDeterministic( - address(erc721TokenholderCasterLogic), keccak256(abi.encodePacked(address(erc721VotesToken), msg.sender)) + address(erc721TokenHolderCasterLogic), keccak256(abi.encodePacked(address(erc721VotesToken), msg.sender)) ) ); casterWithWrongRole.initialize( @@ -170,44 +170,44 @@ contract CastApproval is ERC721TokenholderCasterTest { ); vm.expectRevert(abi.encodeWithSelector(ILlamaRelativeStrategyBase.InvalidRole.selector, tokenVotingCasterRole)); - casterWithWrongRole.castApproval(actionInfo, 1, ""); + casterWithWrongRole.castVote(actionInfo, 1, ""); } function test_RevertsIf_ActionNotActive() public { vm.warp(block.timestamp + 1 days + 1); - vm.expectRevert(TokenholderCaster.ActionNotActive.selector); - erc721TokenholderCaster.castApproval(actionInfo, 1, ""); + vm.expectRevert(TokenHolderCaster.ActionNotActive.selector); + erc721TokenHolderCaster.castVote(actionInfo, 1, ""); } - function test_RevertsIf_AlreadyCastApproval() public { + function test_RevertsIf_AlreadyCastVote() public { vm.startPrank(tokenHolder1); - erc721TokenholderCaster.castApproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVote(actionInfo, 1, ""); - vm.expectRevert(TokenholderCaster.AlreadyCastApproval.selector); - erc721TokenholderCaster.castApproval(actionInfo, 1, ""); + vm.expectRevert(TokenHolderCaster.AlreadyCastVote.selector); + erc721TokenHolderCaster.castVote(actionInfo, 1, ""); } function test_RevertsIf_InvalidSupport() public { - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidSupport.selector, uint8(3))); - erc721TokenholderCaster.castApproval(actionInfo, 3, ""); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidSupport.selector, uint8(3))); + erc721TokenHolderCaster.castVote(actionInfo, 3, ""); } function test_RevertsIf_CastingPeriodOver() public { vm.warp(block.timestamp + ((1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS) + 1); // 2/3 of the approval period - vm.expectRevert(TokenholderCaster.CastingPeriodOver.selector); + vm.expectRevert(TokenHolderCaster.CastingPeriodOver.selector); vm.prank(tokenHolder1); - erc721TokenholderCaster.castApproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVote(actionInfo, 1, ""); } function test_RevertsIf_InsufficientBalance() public { - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InsufficientBalance.selector, 0)); - erc721TokenholderCaster.castApproval(actionInfo, 1, ""); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InsufficientBalance.selector, 0)); + erc721TokenHolderCaster.castVote(actionInfo, 1, ""); } - function test_CastsApprovalCorrectly(uint8 support) public { + function test_CastsVoteCorrectly(uint8 support) public { support = uint8(bound(support, 0, 2)); vm.expectEmit(); - emit ApprovalCast( + emit VoteCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -216,12 +216,12 @@ contract CastApproval is ERC721TokenholderCasterTest { "" ); vm.prank(tokenHolder1); - erc721TokenholderCaster.castApproval(actionInfo, support, ""); + erc721TokenHolderCaster.castVote(actionInfo, support, ""); } - function test_CastsApprovalCorrectly_WithReason() public { + function test_CastsVoteCorrectly_WithReason() public { vm.expectEmit(); - emit ApprovalCast( + emit VoteCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -230,13 +230,13 @@ contract CastApproval is ERC721TokenholderCasterTest { "reason" ); vm.prank(tokenHolder1); - erc721TokenholderCaster.castApproval(actionInfo, 1, "reason"); + erc721TokenHolderCaster.castVote(actionInfo, 1, "reason"); } } -contract CastApprovalBySig is ERC721TokenholderCasterTest { +contract CastVoteBySig is ERC721TokenHolderCasterTest { function setUp() public virtual override { - ERC721TokenholderCasterTest.setUp(); + ERC721TokenHolderCasterTest.setUp(); } function createOffchainSignature(ActionInfo memory _actionInfo, uint256 privateKey) @@ -244,26 +244,21 @@ contract CastApprovalBySig is ERC721TokenholderCasterTest { view returns (uint8 v, bytes32 r, bytes32 s) { - LlamaCoreSigUtils.CastApproval memory castApproval = LlamaCoreSigUtils.CastApproval({ - actionInfo: _actionInfo, - support: 1, - reason: "", - tokenHolder: tokenHolder1, - nonce: 0 - }); - bytes32 digest = getCastApprovalTypedDataHash(castApproval); + LlamaCoreSigUtils.CastVote memory castVote = + LlamaCoreSigUtils.CastVote({actionInfo: _actionInfo, support: 1, reason: "", tokenHolder: tokenHolder1, nonce: 0}); + bytes32 digest = getCastVoteTypedDataHash(castVote); (v, r, s) = vm.sign(privateKey, digest); } - function castApprovalBySig(ActionInfo memory _actionInfo, uint8 support, uint8 v, bytes32 r, bytes32 s) internal { - erc721TokenholderCaster.castApprovalBySig(tokenHolder1, support, _actionInfo, "", v, r, s); + function castVoteBySig(ActionInfo memory _actionInfo, uint8 support, uint8 v, bytes32 r, bytes32 s) internal { + erc721TokenHolderCaster.castVoteBySig(tokenHolder1, support, _actionInfo, "", v, r, s); } - function test_CastsApprovalBySig() public { + function test_CastsVoteBySig() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); vm.expectEmit(); - emit ApprovalCast( + emit VoteCast( actionInfo.id, tokenHolder1, tokenVotingCasterRole, @@ -272,33 +267,33 @@ contract CastApprovalBySig is ERC721TokenholderCasterTest { "" ); - castApprovalBySig(actionInfo, 1, v, r, s); + castVoteBySig(actionInfo, 1, v, r, s); } function test_CheckNonceIncrements() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - assertEq(erc721TokenholderCaster.nonces(tokenHolder1, TokenholderCaster.castApprovalBySig.selector), 0); - castApprovalBySig(actionInfo, 1, v, r, s); - assertEq(erc721TokenholderCaster.nonces(tokenHolder1, TokenholderCaster.castApprovalBySig.selector), 1); + assertEq(erc721TokenHolderCaster.nonces(tokenHolder1, TokenHolderCaster.castVoteBySig.selector), 0); + castVoteBySig(actionInfo, 1, v, r, s); + assertEq(erc721TokenHolderCaster.nonces(tokenHolder1, TokenHolderCaster.castVoteBySig.selector), 1); } function test_OperationCannotBeReplayed() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - castApprovalBySig(actionInfo, 1, v, r, s); + castVoteBySig(actionInfo, 1, v, r, s); // Invalid Signature error since the recovered signer address during the second call is not the same as - // erc20VotesTokenholder since nonce has increased. - vm.expectRevert(TokenholderCaster.InvalidSignature.selector); - castApprovalBySig(actionInfo, 1, v, r, s); + // erc20VotesTokenHolder since nonce has increased. + vm.expectRevert(TokenHolderCaster.InvalidSignature.selector); + castVoteBySig(actionInfo, 1, v, r, s); } function test_RevertIf_SignerIsNotTokenHolder() public { (, uint256 randomSignerPrivateKey) = makeAddrAndKey("randomSigner"); (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, randomSignerPrivateKey); - // Invalid Signature error since the recovered signer address is not the same as the erc20VotesTokenholder passed + // Invalid Signature error since the recovered signer address is not the same as the erc20VotesTokenHolder passed // in as parameter. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castApprovalBySig(actionInfo, 1, v, r, s); + castVoteBySig(actionInfo, 1, v, r, s); } function test_RevertIf_SignerIsZeroAddress() public { @@ -306,44 +301,44 @@ contract CastApprovalBySig is ERC721TokenholderCasterTest { // Invalid Signature error since the recovered signer address is zero address due to invalid signature values // (v,r,s). vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castApprovalBySig(actionInfo, 1, (v + 1), r, s); + castVoteBySig(actionInfo, 1, (v + 1), r, s); } function test_RevertIf_TokenHolderIncrementsNonce() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); vm.prank(tokenHolder1); - erc721TokenholderCaster.incrementNonce(ILlamaCore.castApprovalBySig.selector); + erc721TokenHolderCaster.incrementNonce(TokenHolderCaster.castVoteBySig.selector); // Invalid Signature error since the recovered signer address during the call is not the same as - // erc20VotesTokenholder since nonce has increased. + // erc20VotesTokenHolder since nonce has increased. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castApprovalBySig(actionInfo, 1, v, r, s); + castVoteBySig(actionInfo, 1, v, r, s); } } -contract CastDisapproval is ERC721TokenholderCasterTest { +contract CastVeto is ERC721TokenHolderCasterTest { function setUp() public virtual override { - ERC721TokenholderCasterTest.setUp(); + ERC721TokenHolderCasterTest.setUp(); - castApprovalsFor(); + castVotesFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); vm.prank(tokenHolder1); - erc721TokenholderCaster.submitApprovals(actionInfo); + erc721TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_ActionInfoMismatch(ActionInfo memory notActionInfo) public { vm.assume(notActionInfo.id != actionInfo.id); vm.expectRevert(); - erc721TokenholderCaster.castDisapproval(notActionInfo, tokenVotingCasterRole, ""); + erc721TokenHolderCaster.castVeto(notActionInfo, tokenVotingCasterRole, ""); } function test_RevertsIf_DisapprovalNotEnabled() public { - ERC721TokenholderCaster casterWithWrongRole = ERC721TokenholderCaster( + ERC721TokenHolderCaster casterWithWrongRole = ERC721TokenHolderCaster( Clones.cloneDeterministic( - address(erc721TokenholderCasterLogic), keccak256(abi.encodePacked(address(erc721VotesToken), msg.sender)) + address(erc721TokenHolderCasterLogic), keccak256(abi.encodePacked(address(erc721VotesToken), msg.sender)) ) ); casterWithWrongRole.initialize( @@ -351,32 +346,32 @@ contract CastDisapproval is ERC721TokenholderCasterTest { ); vm.expectRevert(abi.encodeWithSelector(ILlamaRelativeStrategyBase.InvalidRole.selector, tokenVotingCasterRole)); - casterWithWrongRole.castDisapproval(actionInfo, madeUpRole, ""); + casterWithWrongRole.castVeto(actionInfo, madeUpRole, ""); } - function test_RevertsIf_AlreadyCastApproval() public { + function test_RevertsIf_AlreadyCastVote() public { vm.startPrank(tokenHolder1); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVeto(actionInfo, 1, ""); - vm.expectRevert(TokenholderCaster.AlreadyCastDisapproval.selector); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, ""); + vm.expectRevert(TokenHolderCaster.AlreadyCastVeto.selector); + erc721TokenHolderCaster.castVeto(actionInfo, 1, ""); } function test_RevertsIf_InvalidSupport() public { - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InvalidSupport.selector, uint8(3))); - erc721TokenholderCaster.castDisapproval(actionInfo, 3, ""); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InvalidSupport.selector, uint8(3))); + erc721TokenHolderCaster.castVeto(actionInfo, 3, ""); } function test_RevertsIf_CastingPeriodOver() public { // TODO why do we need to add 2 here vm.warp(block.timestamp + 2 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); // 2/3 of the approval period - vm.expectRevert(TokenholderCaster.CastingPeriodOver.selector); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, ""); + vm.expectRevert(TokenHolderCaster.CastingPeriodOver.selector); + erc721TokenHolderCaster.castVeto(actionInfo, 1, ""); } function test_RevertsIf_InsufficientBalance() public { - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InsufficientBalance.selector, 0)); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, ""); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InsufficientBalance.selector, 0)); + erc721TokenHolderCaster.castVeto(actionInfo, 1, ""); } function test_CastsDisapprovalCorrectly(uint8 support) public { @@ -391,7 +386,7 @@ contract CastDisapproval is ERC721TokenholderCasterTest { "" ); vm.prank(tokenHolder1); - erc721TokenholderCaster.castDisapproval(actionInfo, support, ""); + erc721TokenHolderCaster.castVeto(actionInfo, support, ""); } function test_CastsDisapprovalCorrectly_WithReason() public { @@ -405,20 +400,20 @@ contract CastDisapproval is ERC721TokenholderCasterTest { "reason" ); vm.prank(tokenHolder1); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, "reason"); + erc721TokenHolderCaster.castVeto(actionInfo, 1, "reason"); } } -contract CastDisapprovalBySig is ERC721TokenholderCasterTest { +contract CastVetoBySig is ERC721TokenHolderCasterTest { function setUp() public virtual override { - ERC721TokenholderCasterTest.setUp(); + ERC721TokenHolderCasterTest.setUp(); - castApprovalsFor(); + castVotesFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); vm.prank(tokenHolder1); - erc721TokenholderCaster.submitApprovals(actionInfo); + erc721TokenHolderCaster.submitVotes(actionInfo); } function createOffchainSignature(ActionInfo memory _actionInfo, uint256 privateKey) @@ -426,19 +421,14 @@ contract CastDisapprovalBySig is ERC721TokenholderCasterTest { view returns (uint8 v, bytes32 r, bytes32 s) { - LlamaCoreSigUtils.CastDisapproval memory castDisapproval = LlamaCoreSigUtils.CastDisapproval({ - actionInfo: _actionInfo, - support: 1, - reason: "", - tokenHolder: tokenHolder1, - nonce: 0 - }); - bytes32 digest = getCastDisapprovalTypedDataHash(castDisapproval); + LlamaCoreSigUtils.CastVeto memory castVeto = + LlamaCoreSigUtils.CastVeto({actionInfo: _actionInfo, support: 1, reason: "", tokenHolder: tokenHolder1, nonce: 0}); + bytes32 digest = getCastVetoTypedDataHash(castVeto); (v, r, s) = vm.sign(privateKey, digest); } - function castDisapprovalBySig(ActionInfo memory _actionInfo, uint8 v, bytes32 r, bytes32 s) internal { - erc721TokenholderCaster.castDisapprovalBySig(tokenHolder1, 1, _actionInfo, "", v, r, s); + function castVetoBySig(ActionInfo memory _actionInfo, uint8 v, bytes32 r, bytes32 s) internal { + erc721TokenHolderCaster.castVetoBySig(tokenHolder1, 1, _actionInfo, "", v, r, s); } function test_CastsDisapprovalBySig() public { @@ -454,7 +444,7 @@ contract CastDisapprovalBySig is ERC721TokenholderCasterTest { "" ); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); // assertEq(CORE.getAction(0).totalDisapprovals, 1); // assertEq(CORE.disapprovals(0, disapproverDrake), true); @@ -463,29 +453,29 @@ contract CastDisapprovalBySig is ERC721TokenholderCasterTest { function test_CheckNonceIncrements() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - assertEq(erc721TokenholderCaster.nonces(tokenHolder1, ILlamaCore.castDisapprovalBySig.selector), 0); - castDisapprovalBySig(actionInfo, v, r, s); - assertEq(erc721TokenholderCaster.nonces(tokenHolder1, ILlamaCore.castDisapprovalBySig.selector), 1); + assertEq(erc721TokenHolderCaster.nonces(tokenHolder1, TokenHolderCaster.castVetoBySig.selector), 0); + castVetoBySig(actionInfo, v, r, s); + assertEq(erc721TokenHolderCaster.nonces(tokenHolder1, TokenHolderCaster.castVetoBySig.selector), 1); } function test_OperationCannotBeReplayed() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); // Invalid Signature error since the recovered signer address during the second call is not the same as - // erc20VotesTokenholder + // erc20VotesTokenHolder // since nonce has increased. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); } function test_RevertIf_SignerIsNotPolicyHolder() public { (, uint256 randomSignerPrivateKey) = makeAddrAndKey("randomSigner"); (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, randomSignerPrivateKey); // Invalid Signature error since the recovered signer address during the second call is not the same as - // erc20VotesTokenholder + // erc20VotesTokenHolder // since nonce has increased. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); } function test_RevertIf_SignerIsZeroAddress() public { @@ -493,19 +483,19 @@ contract CastDisapprovalBySig is ERC721TokenholderCasterTest { // Invalid Signature error since the recovered signer address is zero address due to invalid signature values // (v,r,s). vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castDisapprovalBySig(actionInfo, (v + 1), r, s); + castVetoBySig(actionInfo, (v + 1), r, s); } function test_RevertIf_PolicyholderIncrementsNonce() public { (uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey); vm.prank(tokenHolder1); - erc721TokenholderCaster.incrementNonce(ILlamaCore.castDisapprovalBySig.selector); + erc721TokenHolderCaster.incrementNonce(TokenHolderCaster.castVetoBySig.selector); // Invalid Signature error since the recovered signer address during the second call is not the same as policyholder // since nonce has increased. vm.expectRevert(ILlamaCore.InvalidSignature.selector); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); } function test_FailsIfDisapproved() public { @@ -521,16 +511,16 @@ contract CastDisapprovalBySig is ERC721TokenholderCasterTest { erc721VotesToken.getPastVotes(tokenHolder1, erc721VotesToken.clock() - 1), "" ); - castDisapprovalBySig(actionInfo, v, r, s); + castVetoBySig(actionInfo, v, r, s); // assertEq(CORE.getAction(actionInfo.id).totalDisapprovals, 1); // Second disapproval. vm.prank(tokenHolder2); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVeto(actionInfo, 1, ""); vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - erc721TokenholderCaster.submitDisapprovals(actionInfo); + erc721TokenHolderCaster.submitVetos(actionInfo); // Assertions. ActionState state = ActionState(CORE.getActionState(actionInfo)); @@ -541,11 +531,11 @@ contract CastDisapprovalBySig is ERC721TokenholderCasterTest { } } -contract SubmitApprovals is ERC721TokenholderCasterTest { +contract SubmitVotes is ERC721TokenHolderCasterTest { function setUp() public virtual override { - ERC721TokenholderCasterTest.setUp(); + ERC721TokenHolderCasterTest.setUp(); - castApprovalsFor(); + castVotesFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); } @@ -553,93 +543,93 @@ contract SubmitApprovals is ERC721TokenholderCasterTest { function test_RevertsIf_ActionInfoMismatch(ActionInfo memory notActionInfo) public { vm.assume(notActionInfo.id != actionInfo.id); vm.expectRevert(); - erc721TokenholderCaster.submitApprovals(notActionInfo); + erc721TokenHolderCaster.submitVotes(notActionInfo); } - function test_RevertsIf_AlreadySubmittedApproval() public { + function test_RevertsIf_AlreadySubmittedVotes() public { vm.startPrank(tokenHolder1); - erc721TokenholderCaster.submitApprovals(actionInfo); + erc721TokenHolderCaster.submitVotes(actionInfo); - vm.expectRevert(TokenholderCaster.AlreadySubmittedApproval.selector); - erc721TokenholderCaster.submitApprovals(actionInfo); + vm.expectRevert(TokenHolderCaster.AlreadySubmittedVotes.selector); + erc721TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_SubmissionPeriodOver() public { // TODO why do we need to add 2 here vm.warp(block.timestamp + ((1 days * ONE_THIRD_IN_BPS) / ONE_HUNDRED_IN_BPS) + 2); // 1/3 of the approval period - vm.expectRevert(TokenholderCaster.SubmissionPeriodOver.selector); - erc721TokenholderCaster.submitApprovals(actionInfo); + vm.expectRevert(TokenHolderCaster.SubmissionPeriodOver.selector); + erc721TokenHolderCaster.submitVotes(actionInfo); } - function test_RevertsIf_InsufficientApprovals() public { + function test_RevertsIf_InsufficientVotes() public { actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InsufficientApprovals.selector, 0, 1)); - erc721TokenholderCaster.submitApprovals(actionInfo); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InsufficientVotes.selector, 0, 1)); + erc721TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_CastingPeriodNotOver() public { actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); vm.warp(block.timestamp + (1 days * ONE_THIRD_IN_BPS) / ONE_HUNDRED_IN_BPS); // 1/3 of the approval period - vm.expectRevert(TokenholderCaster.CantSubmitYet.selector); - erc721TokenholderCaster.submitApprovals(actionInfo); + vm.expectRevert(TokenHolderCaster.CantSubmitYet.selector); + erc721TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_ForDoesNotSurpassAgainst() public { actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); vm.prank(tokenHolder1); - erc721TokenholderCaster.castApproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVote(actionInfo, 1, ""); vm.prank(tokenHolder2); - erc721TokenholderCaster.castApproval(actionInfo, 0, ""); + erc721TokenHolderCaster.castVote(actionInfo, 0, ""); vm.prank(tokenHolder3); - erc721TokenholderCaster.castApproval(actionInfo, 0, ""); + erc721TokenHolderCaster.castVote(actionInfo, 0, ""); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.ForDoesNotSurpassAgainst.selector, 1, 2)); - erc721TokenholderCaster.submitApprovals(actionInfo); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.ForDoesNotSurpassAgainst.selector, 1, 2)); + erc721TokenHolderCaster.submitVotes(actionInfo); } - function test_SubmitsApprovalsCorrectly() public { + function test_SubmitsVotesCorrectly() public { vm.expectEmit(); - emit ApprovalsSubmitted(actionInfo.id, 3, 0, 0); - erc721TokenholderCaster.submitApprovals(actionInfo); + emit VotesSubmitted(actionInfo.id, 3, 0, 0); + erc721TokenHolderCaster.submitVotes(actionInfo); } } -contract SubmitDisapprovals is ERC721TokenholderCasterTest { +contract SubmitDisapprovals is ERC721TokenHolderCasterTest { function setUp() public virtual override { - ERC721TokenholderCasterTest.setUp(); + ERC721TokenHolderCasterTest.setUp(); - castApprovalsFor(); + castVotesFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - erc721TokenholderCaster.submitApprovals(actionInfo); + erc721TokenHolderCaster.submitVotes(actionInfo); } function test_RevertsIf_ActionInfoMismatch(ActionInfo memory notActionInfo) public { vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); vm.assume(notActionInfo.id != actionInfo.id); vm.expectRevert(); - erc721TokenholderCaster.submitDisapprovals(notActionInfo); + erc721TokenHolderCaster.submitVetos(notActionInfo); } function test_RevertsIf_DisapprovalNotEnabled() public { vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - ERC721TokenholderCaster casterWithWrongRole = ERC721TokenholderCaster( + ERC721TokenHolderCaster casterWithWrongRole = ERC721TokenHolderCaster( Clones.cloneDeterministic( - address(erc721TokenholderCasterLogic), keccak256(abi.encodePacked(address(erc721VotesToken), msg.sender)) + address(erc721TokenHolderCasterLogic), keccak256(abi.encodePacked(address(erc721VotesToken), msg.sender)) ) ); casterWithWrongRole.initialize( erc721VotesToken, CORE, madeUpRole, ERC721_MIN_APPROVAL_PCT, ERC721_MIN_DISAPPROVAL_PCT ); vm.expectRevert(abi.encodeWithSelector(ILlamaRelativeStrategyBase.InvalidRole.selector, tokenVotingCasterRole)); - casterWithWrongRole.submitDisapprovals(actionInfo); + casterWithWrongRole.submitVetos(actionInfo); } - function test_RevertsIf_AlreadySubmittedDisapproval() public { + function test_RevertsIf_AlreadySubmittedVetos() public { Action memory action = CORE.getAction(actionInfo.id); vm.warp( action.minExecutionTime @@ -647,61 +637,61 @@ contract SubmitDisapprovals is ERC721TokenholderCasterTest { / ONE_HUNDRED_IN_BPS ); - castDisapprovalsFor(); + castVetosFor(); vm.startPrank(tokenHolder1); - erc721TokenholderCaster.submitDisapprovals(actionInfo); + erc721TokenHolderCaster.submitVetos(actionInfo); - vm.expectRevert(TokenholderCaster.AlreadySubmittedDisapproval.selector); - erc721TokenholderCaster.submitDisapprovals(actionInfo); + vm.expectRevert(TokenHolderCaster.AlreadySubmittedVetos.selector); + erc721TokenHolderCaster.submitVetos(actionInfo); } function test_RevertsIf_SubmissionPeriodOver() public { - castDisapprovalsFor(); + castVetosFor(); vm.warp(block.timestamp + 1 days); - vm.expectRevert(TokenholderCaster.SubmissionPeriodOver.selector); - erc721TokenholderCaster.submitDisapprovals(actionInfo); + vm.expectRevert(TokenHolderCaster.SubmissionPeriodOver.selector); + erc721TokenHolderCaster.submitVetos(actionInfo); } function test_RevertsIf_InsufficientDisapprovals() public { actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy); - castApprovalsFor(); + castVotesFor(); vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - erc721TokenholderCaster.submitApprovals(actionInfo); + erc721TokenHolderCaster.submitVotes(actionInfo); //TODO why add 1 here vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.InsufficientApprovals.selector, 0, 1)); - erc721TokenholderCaster.submitDisapprovals(actionInfo); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.InsufficientVotes.selector, 0, 1)); + erc721TokenHolderCaster.submitVetos(actionInfo); } function test_RevertsIf_CastingPeriodNotOver() public { vm.warp(block.timestamp + (1 days * 3333) / ONE_HUNDRED_IN_BPS); // 1/3 of the approval period - vm.expectRevert(TokenholderCaster.CantSubmitYet.selector); - erc721TokenholderCaster.submitDisapprovals(actionInfo); + vm.expectRevert(TokenHolderCaster.CantSubmitYet.selector); + erc721TokenHolderCaster.submitVetos(actionInfo); } function test_RevertsIf_ForDoesNotSurpassAgainst() public { vm.prank(tokenHolder1); - erc721TokenholderCaster.castDisapproval(actionInfo, 1, ""); + erc721TokenHolderCaster.castVeto(actionInfo, 1, ""); vm.prank(tokenHolder2); - erc721TokenholderCaster.castDisapproval(actionInfo, 0, ""); + erc721TokenHolderCaster.castVeto(actionInfo, 0, ""); vm.prank(tokenHolder3); - erc721TokenholderCaster.castDisapproval(actionInfo, 0, ""); + erc721TokenHolderCaster.castVeto(actionInfo, 0, ""); // TODO why add 1 here? vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); - vm.expectRevert(abi.encodeWithSelector(TokenholderCaster.ForDoesNotSurpassAgainst.selector, 1, 2)); - erc721TokenholderCaster.submitDisapprovals(actionInfo); + vm.expectRevert(abi.encodeWithSelector(TokenHolderCaster.ForDoesNotSurpassAgainst.selector, 1, 2)); + erc721TokenHolderCaster.submitVetos(actionInfo); } function test_SubmitsDisapprovalsCorrectly() public { - castDisapprovalsFor(); + castVetosFor(); //TODO why add 1 here? vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS); vm.expectEmit(); emit DisapprovalsSubmitted(actionInfo.id, 3, 0, 0); - erc721TokenholderCaster.submitDisapprovals(actionInfo); + erc721TokenHolderCaster.submitVetos(actionInfo); } } diff --git a/test/token-voting/LlamaTokenVotingFactory.t.sol b/test/token-voting/LlamaTokenVotingFactory.t.sol index 75a6811..482f140 100644 --- a/test/token-voting/LlamaTokenVotingFactory.t.sol +++ b/test/token-voting/LlamaTokenVotingFactory.t.sol @@ -9,21 +9,17 @@ import {LlamaTokenVotingTestSetup} from "test/token-voting/LlamaTokenVotingTestS import {ActionInfo} from "src/lib/Structs.sol"; import {ILlamaPolicy} from "src/interfaces/ILlamaPolicy.sol"; -import {ERC20TokenholderActionCreator} from "src/token-voting/ERC20TokenholderActionCreator.sol"; -import {ERC20TokenholderCaster} from "src/token-voting/ERC20TokenholderCaster.sol"; -import {ERC721TokenholderActionCreator} from "src/token-voting/ERC721TokenholderActionCreator.sol"; -import {ERC721TokenholderCaster} from "src/token-voting/ERC721TokenholderCaster.sol"; +import {ERC20TokenHolderActionCreator} from "src/token-voting/ERC20TokenHolderActionCreator.sol"; +import {ERC20TokenHolderCaster} from "src/token-voting/ERC20TokenHolderCaster.sol"; +import {ERC721TokenHolderActionCreator} from "src/token-voting/ERC721TokenHolderActionCreator.sol"; +import {ERC721TokenHolderCaster} from "src/token-voting/ERC721TokenHolderCaster.sol"; import {LlamaTokenVotingFactory} from "src/token-voting/LlamaTokenVotingFactory.sol"; contract LlamaTokenVotingFactoryTest is LlamaTokenVotingTestSetup { - event ERC20TokenholderActionCreatorCreated(address actionCreator, address indexed token); - event ERC721TokenholderActionCreatorCreated(address actionCreator, address indexed token); - event ERC20TokenholderCasterCreated( - address caster, address indexed token, uint256 minApprovalPct, uint256 minDisapprovalPct - ); - event ERC721TokenholderCasterCreated( - address caster, address indexed token, uint256 minApprovalPct, uint256 minDisapprovalPct - ); + event ERC20TokenHolderActionCreatorCreated(address actionCreator, address indexed token); + event ERC721TokenHolderActionCreatorCreated(address actionCreator, address indexed token); + event ERC20TokenHolderCasterCreated(address caster, address indexed token, uint256 voteQuorum, uint256 vetoQuorum); + event ERC721TokenHolderCasterCreated(address caster, address indexed token, uint256 voteQuorum, uint256 vetoQuorum); event ActionThresholdSet(uint256 newThreshold); function setUp() public override { @@ -40,25 +36,25 @@ contract LlamaTokenVotingFactoryTest is LlamaTokenVotingTestSetup { } contract Constructor is LlamaTokenVotingFactoryTest { - function test_SetsERC20TokenholderActionCreatorLogicAddress() public { + function test_SetsERC20TokenHolderActionCreatorLogicAddress() public { assertEq( - address(tokenVotingFactory.ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC()), address(erc20TokenholderActionCreatorLogic) + address(tokenVotingFactory.ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC()), address(erc20TokenHolderActionCreatorLogic) ); } - function test_SetsERC20TokenholderCasterLogicAddress() public { - assertEq(address(tokenVotingFactory.ERC20_TOKENHOLDER_CASTER_LOGIC()), address(erc20TokenholderCasterLogic)); + function test_SetsERC20TokenHolderCasterLogicAddress() public { + assertEq(address(tokenVotingFactory.ERC20_TOKENHOLDER_CASTER_LOGIC()), address(erc20TokenHolderCasterLogic)); } - function test_SetsERC721TokenholderActionCreatorLogicAddress() public { + function test_SetsERC721TokenHolderActionCreatorLogicAddress() public { assertEq( address(tokenVotingFactory.ERC721_TOKENHOLDER_ACTION_CREATOR_LOGIC()), - address(erc721TokenholderActionCreatorLogic) + address(erc721TokenHolderActionCreatorLogic) ); } - function test_SetsERC721TokenholderCasterLogicAddress() public { - assertEq(address(tokenVotingFactory.ERC721_TOKENHOLDER_CASTER_LOGIC()), address(erc721TokenholderCasterLogic)); + function test_SetsERC721TokenHolderCasterLogicAddress() public { + assertEq(address(tokenVotingFactory.ERC721_TOKENHOLDER_CASTER_LOGIC()), address(erc721TokenHolderCasterLogic)); } } @@ -89,6 +85,7 @@ contract DeployTokenVotingModule is LlamaTokenVotingFactoryTest { // Set up action to call `deployTokenVotingModule` with the ERC20 token. bytes memory data = abi.encodeWithSelector( LlamaTokenVotingFactory.deployTokenVotingModule.selector, + CORE, address(erc20VotesToken), true, tokenVotingActionCreatorRole, @@ -100,16 +97,16 @@ contract DeployTokenVotingModule is LlamaTokenVotingFactoryTest { ActionInfo memory actionInfo = _setPermissionCreateApproveAndQueueAction(data); // Compute addresses of ERC20 Token Voting Module - ERC20TokenholderActionCreator erc20TokenholderActionCreator = ERC20TokenholderActionCreator( + ERC20TokenHolderActionCreator erc20TokenHolderActionCreator = ERC20TokenHolderActionCreator( Clones.predictDeterministicAddress( - address(erc20TokenholderActionCreatorLogic), + address(erc20TokenHolderActionCreatorLogic), keccak256(abi.encodePacked(address(erc20VotesToken), address(EXECUTOR))), // salt address(tokenVotingFactory) // deployer ) ); - ERC20TokenholderCaster erc20TokenholderCaster = ERC20TokenholderCaster( + ERC20TokenHolderCaster erc20TokenHolderCaster = ERC20TokenHolderCaster( Clones.predictDeterministicAddress( - address(erc20TokenholderCasterLogic), + address(erc20TokenHolderCasterLogic), keccak256(abi.encodePacked(address(erc20VotesToken), address(EXECUTOR))), // salt address(tokenVotingFactory) // deployer ) @@ -119,28 +116,29 @@ contract DeployTokenVotingModule is LlamaTokenVotingFactoryTest { vm.expectEmit(); emit ActionThresholdSet(ERC20_CREATION_THRESHOLD); vm.expectEmit(); - emit ERC20TokenholderActionCreatorCreated(address(erc20TokenholderActionCreator), address(erc20VotesToken)); + emit ERC20TokenHolderActionCreatorCreated(address(erc20TokenHolderActionCreator), address(erc20VotesToken)); vm.expectEmit(); - emit ERC20TokenholderCasterCreated( - address(erc20TokenholderCaster), address(erc20VotesToken), ERC20_MIN_APPROVAL_PCT, ERC20_MIN_DISAPPROVAL_PCT + emit ERC20TokenHolderCasterCreated( + address(erc20TokenHolderCaster), address(erc20VotesToken), ERC20_MIN_APPROVAL_PCT, ERC20_MIN_DISAPPROVAL_PCT ); CORE.executeAction(actionInfo); - assertEq(address(erc20TokenholderActionCreator.token()), address(erc20VotesToken)); - assertEq(address(erc20TokenholderActionCreator.llamaCore()), address(CORE)); - assertEq(erc20TokenholderActionCreator.role(), tokenVotingActionCreatorRole); - assertEq(erc20TokenholderActionCreator.creationThreshold(), ERC20_CREATION_THRESHOLD); - assertEq(address(erc20TokenholderCaster.token()), address(erc20VotesToken)); - assertEq(address(erc20TokenholderCaster.llamaCore()), address(CORE)); - assertEq(erc20TokenholderCaster.role(), tokenVotingCasterRole); - assertEq(erc20TokenholderCaster.minApprovalPct(), ERC20_MIN_APPROVAL_PCT); - assertEq(erc20TokenholderCaster.minDisapprovalPct(), ERC20_MIN_DISAPPROVAL_PCT); + assertEq(address(erc20TokenHolderActionCreator.token()), address(erc20VotesToken)); + assertEq(address(erc20TokenHolderActionCreator.llamaCore()), address(CORE)); + assertEq(erc20TokenHolderActionCreator.role(), tokenVotingActionCreatorRole); + assertEq(erc20TokenHolderActionCreator.creationThreshold(), ERC20_CREATION_THRESHOLD); + assertEq(address(erc20TokenHolderCaster.token()), address(erc20VotesToken)); + assertEq(address(erc20TokenHolderCaster.llamaCore()), address(CORE)); + assertEq(erc20TokenHolderCaster.role(), tokenVotingCasterRole); + assertEq(erc20TokenHolderCaster.voteQuorum(), ERC20_MIN_APPROVAL_PCT); + assertEq(erc20TokenHolderCaster.vetoQuorum(), ERC20_MIN_DISAPPROVAL_PCT); } function test_CanDeployERC721TokenVotingModule() public { // Set up action to call `deployTokenVotingModule` with the ERC721 token. bytes memory data = abi.encodeWithSelector( LlamaTokenVotingFactory.deployTokenVotingModule.selector, + CORE, address(erc721VotesToken), false, tokenVotingActionCreatorRole, @@ -152,16 +150,16 @@ contract DeployTokenVotingModule is LlamaTokenVotingFactoryTest { ActionInfo memory actionInfo = _setPermissionCreateApproveAndQueueAction(data); // Compute addresses of ERC721 Token Voting Module - ERC721TokenholderActionCreator erc721TokenholderActionCreator = ERC721TokenholderActionCreator( + ERC721TokenHolderActionCreator erc721TokenHolderActionCreator = ERC721TokenHolderActionCreator( Clones.predictDeterministicAddress( - address(erc721TokenholderActionCreatorLogic), + address(erc721TokenHolderActionCreatorLogic), keccak256(abi.encodePacked(address(erc721VotesToken), address(EXECUTOR))), // salt address(tokenVotingFactory) // deployer ) ); - ERC721TokenholderCaster erc721TokenholderCaster = ERC721TokenholderCaster( + ERC721TokenHolderCaster erc721TokenHolderCaster = ERC721TokenHolderCaster( Clones.predictDeterministicAddress( - address(erc721TokenholderCasterLogic), + address(erc721TokenHolderCasterLogic), keccak256(abi.encodePacked(address(erc721VotesToken), address(EXECUTOR))), // salt address(tokenVotingFactory) // deployer ) @@ -171,21 +169,21 @@ contract DeployTokenVotingModule is LlamaTokenVotingFactoryTest { vm.expectEmit(); emit ActionThresholdSet(ERC721_CREATION_THRESHOLD); vm.expectEmit(); - emit ERC721TokenholderActionCreatorCreated(address(erc721TokenholderActionCreator), address(erc721VotesToken)); + emit ERC721TokenHolderActionCreatorCreated(address(erc721TokenHolderActionCreator), address(erc721VotesToken)); vm.expectEmit(); - emit ERC721TokenholderCasterCreated( - address(erc721TokenholderCaster), address(erc721VotesToken), ERC721_MIN_APPROVAL_PCT, ERC721_MIN_DISAPPROVAL_PCT + emit ERC721TokenHolderCasterCreated( + address(erc721TokenHolderCaster), address(erc721VotesToken), ERC721_MIN_APPROVAL_PCT, ERC721_MIN_DISAPPROVAL_PCT ); CORE.executeAction(actionInfo); - assertEq(address(erc721TokenholderActionCreator.token()), address(erc721VotesToken)); - assertEq(address(erc721TokenholderActionCreator.llamaCore()), address(CORE)); - assertEq(erc721TokenholderActionCreator.role(), tokenVotingActionCreatorRole); - assertEq(erc721TokenholderActionCreator.creationThreshold(), ERC721_CREATION_THRESHOLD); - assertEq(address(erc721TokenholderCaster.token()), address(erc721VotesToken)); - assertEq(address(erc721TokenholderCaster.llamaCore()), address(CORE)); - assertEq(erc721TokenholderCaster.role(), tokenVotingCasterRole); - assertEq(erc721TokenholderCaster.minApprovalPct(), ERC721_MIN_APPROVAL_PCT); - assertEq(erc721TokenholderCaster.minDisapprovalPct(), ERC721_MIN_DISAPPROVAL_PCT); + assertEq(address(erc721TokenHolderActionCreator.token()), address(erc721VotesToken)); + assertEq(address(erc721TokenHolderActionCreator.llamaCore()), address(CORE)); + assertEq(erc721TokenHolderActionCreator.role(), tokenVotingActionCreatorRole); + assertEq(erc721TokenHolderActionCreator.creationThreshold(), ERC721_CREATION_THRESHOLD); + assertEq(address(erc721TokenHolderCaster.token()), address(erc721VotesToken)); + assertEq(address(erc721TokenHolderCaster.llamaCore()), address(CORE)); + assertEq(erc721TokenHolderCaster.role(), tokenVotingCasterRole); + assertEq(erc721TokenHolderCaster.voteQuorum(), ERC721_MIN_APPROVAL_PCT); + assertEq(erc721TokenHolderCaster.vetoQuorum(), ERC721_MIN_DISAPPROVAL_PCT); } } diff --git a/test/token-voting/LlamaTokenVotingTestSetup.sol b/test/token-voting/LlamaTokenVotingTestSetup.sol index ae0cf7c..f403b7f 100644 --- a/test/token-voting/LlamaTokenVotingTestSetup.sol +++ b/test/token-voting/LlamaTokenVotingTestSetup.sol @@ -15,10 +15,10 @@ import {ILlamaPolicy} from "src/interfaces/ILlamaPolicy.sol"; import {ILlamaStrategy} from "src/interfaces/ILlamaStrategy.sol"; import {ILlamaRelativeStrategyBase} from "src/interfaces/ILlamaRelativeStrategyBase.sol"; import {RoleDescription} from "src/lib/UDVTs.sol"; -import {ERC20TokenholderActionCreator} from "src/token-voting/ERC20TokenholderActionCreator.sol"; -import {ERC20TokenholderCaster} from "src/token-voting/ERC20TokenholderCaster.sol"; -import {ERC721TokenholderActionCreator} from "src/token-voting/ERC721TokenholderActionCreator.sol"; -import {ERC721TokenholderCaster} from "src/token-voting/ERC721TokenholderCaster.sol"; +import {ERC20TokenHolderActionCreator} from "src/token-voting/ERC20TokenHolderActionCreator.sol"; +import {ERC20TokenHolderCaster} from "src/token-voting/ERC20TokenHolderCaster.sol"; +import {ERC721TokenHolderActionCreator} from "src/token-voting/ERC721TokenHolderActionCreator.sol"; +import {ERC721TokenHolderCaster} from "src/token-voting/ERC721TokenHolderCaster.sol"; contract LlamaTokenVotingTestSetup is LlamaPeripheryTestSetup, DeployLlamaTokenVotingFactory { // Percentages @@ -91,11 +91,12 @@ contract LlamaTokenVotingTestSetup is LlamaPeripheryTestSetup, DeployLlamaTokenV function _deployERC20TokenVotingModuleAndSetRole() internal - returns (ERC20TokenholderActionCreator, ERC20TokenholderCaster) + returns (ERC20TokenHolderActionCreator, ERC20TokenHolderCaster) { vm.startPrank(address(EXECUTOR)); // Deploy Token Voting Module - (address erc20TokenholderActionCreator, address erc20TokenholderCaster) = tokenVotingFactory.deployTokenVotingModule( + (address erc20TokenHolderActionCreator, address erc20TokenHolderCaster) = tokenVotingFactory.deployTokenVotingModule( + CORE, address(erc20VotesToken), true, tokenVotingActionCreatorRole, @@ -106,23 +107,24 @@ contract LlamaTokenVotingTestSetup is LlamaPeripheryTestSetup, DeployLlamaTokenV ); // Assign roles to Token Voting Modules POLICY.setRoleHolder( - tokenVotingActionCreatorRole, erc20TokenholderActionCreator, DEFAULT_ROLE_QTY, DEFAULT_ROLE_EXPIRATION + tokenVotingActionCreatorRole, erc20TokenHolderActionCreator, DEFAULT_ROLE_QTY, DEFAULT_ROLE_EXPIRATION ); - POLICY.setRoleHolder(tokenVotingCasterRole, erc20TokenholderCaster, DEFAULT_ROLE_QTY, DEFAULT_ROLE_EXPIRATION); + POLICY.setRoleHolder(tokenVotingCasterRole, erc20TokenHolderCaster, DEFAULT_ROLE_QTY, DEFAULT_ROLE_EXPIRATION); vm.stopPrank(); return - (ERC20TokenholderActionCreator(erc20TokenholderActionCreator), ERC20TokenholderCaster(erc20TokenholderCaster)); + (ERC20TokenHolderActionCreator(erc20TokenHolderActionCreator), ERC20TokenHolderCaster(erc20TokenHolderCaster)); } function _deployERC721TokenVotingModuleAndSetRole() internal - returns (ERC721TokenholderActionCreator, ERC721TokenholderCaster) + returns (ERC721TokenHolderActionCreator, ERC721TokenHolderCaster) { vm.startPrank(address(EXECUTOR)); // Deploy Token Voting Module - (address erc721TokenholderActionCreator, address erc721TokenholderCaster) = tokenVotingFactory + (address erc721TokenHolderActionCreator, address erc721TokenHolderCaster) = tokenVotingFactory .deployTokenVotingModule( + CORE, address(erc721VotesToken), false, tokenVotingActionCreatorRole, @@ -133,17 +135,17 @@ contract LlamaTokenVotingTestSetup is LlamaPeripheryTestSetup, DeployLlamaTokenV ); // Assign roles to Token Voting Modules POLICY.setRoleHolder( - tokenVotingActionCreatorRole, erc721TokenholderActionCreator, DEFAULT_ROLE_QTY, DEFAULT_ROLE_EXPIRATION + tokenVotingActionCreatorRole, erc721TokenHolderActionCreator, DEFAULT_ROLE_QTY, DEFAULT_ROLE_EXPIRATION ); - POLICY.setRoleHolder(tokenVotingCasterRole, erc721TokenholderCaster, DEFAULT_ROLE_QTY, DEFAULT_ROLE_EXPIRATION); + POLICY.setRoleHolder(tokenVotingCasterRole, erc721TokenHolderCaster, DEFAULT_ROLE_QTY, DEFAULT_ROLE_EXPIRATION); vm.stopPrank(); return - (ERC721TokenholderActionCreator(erc721TokenholderActionCreator), ERC721TokenholderCaster(erc721TokenholderCaster)); + (ERC721TokenHolderActionCreator(erc721TokenHolderActionCreator), ERC721TokenHolderCaster(erc721TokenHolderCaster)); } - function _setRolePermissionToTokenholderActionCreator() internal { - // Assign permission for `MockProtocol.pause` to the TokenholderActionCreator. + function _setRolePermissionToTokenHolderActionCreator() internal { + // Assign permission for `MockProtocol.pause` to the TokenHolderActionCreator. vm.prank(address(EXECUTOR)); POLICY.setRolePermission( tokenVotingActionCreatorRole, diff --git a/test/utils/LlamaCoreSigUtils.sol b/test/utils/LlamaCoreSigUtils.sol index ad44bd7..18579cc 100644 --- a/test/utils/LlamaCoreSigUtils.sol +++ b/test/utils/LlamaCoreSigUtils.sol @@ -27,7 +27,7 @@ contract LlamaCoreSigUtils { uint256 nonce; } - struct CastApproval { + struct CastVote { address tokenHolder; uint8 support; ActionInfo actionInfo; @@ -35,7 +35,7 @@ contract LlamaCoreSigUtils { uint256 nonce; } - struct CastDisapproval { + struct CastVeto { address tokenHolder; uint8 support; ActionInfo actionInfo; @@ -57,14 +57,14 @@ contract LlamaCoreSigUtils { "CancelAction(address tokenHolder,ActionInfo actionInfo,uint256 nonce)ActionInfo(uint256 id,address creator,uint8 creatorRole,address strategy,address target,uint256 value,bytes data)" ); - /// @notice EIP-712 castApproval typehash. - bytes32 internal constant CAST_APPROVAL_TYPEHASH = keccak256( - "CastApproval(address tokenHolder,uint8 support,ActionInfo actionInfo,string reason,uint256 nonce)ActionInfo(uint256 id,address creator,uint8 creatorRole,address strategy,address target,uint256 value,bytes data)" + /// @notice EIP-712 castVote typehash. + bytes32 internal constant CAST_VOTE_TYPEHASH = keccak256( + "CastVote(address tokenHolder,uint8 support,ActionInfo actionInfo,string reason,uint256 nonce)ActionInfo(uint256 id,address creator,uint8 creatorRole,address strategy,address target,uint256 value,bytes data)" ); - /// @notice EIP-712 castDisapproval typehash. - bytes32 internal constant CAST_DISAPPROVAL_TYPEHASH = keccak256( - "CastDisapproval(address tokenHolder,uint8 role,ActionInfo actionInfo,string reason,uint256 nonce)ActionInfo(uint256 id,address creator,uint8 creatorRole,address strategy,address target,uint256 value,bytes data)" + /// @notice EIP-712 castVeto typehash. + bytes32 internal constant CAST_VETO_TYPEHASH = keccak256( + "CastVeto(address tokenHolder,uint8 role,ActionInfo actionInfo,string reason,uint256 nonce)ActionInfo(uint256 id,address creator,uint8 creatorRole,address strategy,address target,uint256 value,bytes data)" ); /// @notice EIP-712 actionInfo typehash. @@ -124,44 +124,44 @@ contract LlamaCoreSigUtils { return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, getCancelActionHash(cancelAction))); } - /// @notice Returns the hash of CastApproval. - function getCastApprovalHash(CastApproval memory castApproval) internal pure returns (bytes32) { + /// @notice Returns the hash of CastVote. + function getCastVoteHash(CastVote memory castVote) internal pure returns (bytes32) { return keccak256( abi.encode( - CAST_APPROVAL_TYPEHASH, - castApproval.tokenHolder, - castApproval.support, - getActionInfoHash(castApproval.actionInfo), - keccak256(bytes(castApproval.reason)), - castApproval.nonce + CAST_VOTE_TYPEHASH, + castVote.tokenHolder, + castVote.support, + getActionInfoHash(castVote.actionInfo), + keccak256(bytes(castVote.reason)), + castVote.nonce ) ); } - /// @notice Returns the hash of the fully encoded EIP-712 message for the CastApproval domain, which can be used to + /// @notice Returns the hash of the fully encoded EIP-712 message for the CastVote domain, which can be used to /// recover the signer. - function getCastApprovalTypedDataHash(CastApproval memory castApproval) internal view returns (bytes32) { - return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, getCastApprovalHash(castApproval))); + function getCastVoteTypedDataHash(CastVote memory castVote) internal view returns (bytes32) { + return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, getCastVoteHash(castVote))); } - /// @notice Returns the hash of CastDisapprovalBySig. - function getCastDisapprovalHash(CastDisapproval memory castDisapproval) internal pure returns (bytes32) { + /// @notice Returns the hash of CastVetoBySig. + function getCastVetoHash(CastVeto memory castVeto) internal pure returns (bytes32) { return keccak256( abi.encode( - CAST_DISAPPROVAL_TYPEHASH, - castDisapproval.tokenHolder, - castDisapproval.support, - getActionInfoHash(castDisapproval.actionInfo), - keccak256(bytes(castDisapproval.reason)), - castDisapproval.nonce + CAST_VETO_TYPEHASH, + castVeto.tokenHolder, + castVeto.support, + getActionInfoHash(castVeto.actionInfo), + keccak256(bytes(castVeto.reason)), + castVeto.nonce ) ); } - /// @notice Returns the hash of the fully encoded EIP-712 message for the CastDisapproval domain, which can be used to + /// @notice Returns the hash of the fully encoded EIP-712 message for the CastVeto domain, which can be used to /// recover the signer. - function getCastDisapprovalTypedDataHash(CastDisapproval memory castDisapproval) internal view returns (bytes32) { - return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, getCastDisapprovalHash(castDisapproval))); + function getCastVetoTypedDataHash(CastVeto memory castVeto) internal view returns (bytes32) { + return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, getCastVetoHash(castVeto))); } /// @notice Returns the hash of ActionInfo.