Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

refactor: deployments decoupled from LlamaExecutor #25

Merged
merged 28 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/token-voting/LlamaTokenVotingFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity ^0.8.23;
import {Clones} from "@openzeppelin/proxy/Clones.sol";

import {ILlamaCore} from "src/interfaces/ILlamaCore.sol";
import {ILlamaExecutor} from "src/interfaces/ILlamaExecutor.sol";
import {ERC20TokenholderActionCreator} from "src/token-voting/ERC20TokenholderActionCreator.sol";
import {ERC20TokenholderCaster} from "src/token-voting/ERC20TokenholderCaster.sol";
import {ERC20Votes} from "@openzeppelin/token/ERC20/extensions/ERC20Votes.sol";
Expand Down Expand Up @@ -67,6 +66,7 @@ contract LlamaTokenVotingFactory {
///@param minDisapprovalPct The minimum percentage of tokens required to disapprove an action (set to 0 if not
/// deploying caster).
function deployTokenVotingModule(
ILlamaCore llamaCore,
address token,
bool isERC20,
uint8 actionCreatorRole,
Expand All @@ -75,17 +75,20 @@ contract LlamaTokenVotingFactory {
uint256 minApprovalPct,
uint256 minDisapprovalPct
) external returns (address actionCreator, address caster) {
ILlamaCore core = ILlamaCore(ILlamaExecutor(msg.sender).LLAMA_CORE());
if (isERC20) {
actionCreator =
address(_deployERC20TokenholderActionCreator(ERC20Votes(token), core, actionCreatorRole, creationThreshold));
caster =
address(_deployERC20TokenholderCaster(ERC20Votes(token), core, casterRole, minApprovalPct, minDisapprovalPct));
actionCreator = address(
_deployERC20TokenholderActionCreator(ERC20Votes(token), llamaCore, actionCreatorRole, creationThreshold)
);
caster = address(
_deployERC20TokenholderCaster(ERC20Votes(token), llamaCore, casterRole, minApprovalPct, minDisapprovalPct)
);
} else {
actionCreator =
address(_deployERC721TokenholderActionCreator(ERC721Votes(token), core, actionCreatorRole, creationThreshold));
caster =
address(_deployERC721TokenholderCaster(ERC721Votes(token), core, casterRole, minApprovalPct, minDisapprovalPct));
actionCreator = address(
_deployERC721TokenholderActionCreator(ERC721Votes(token), llamaCore, actionCreatorRole, creationThreshold)
);
caster = address(
_deployERC721TokenholderCaster(ERC721Votes(token), llamaCore, casterRole, minApprovalPct, minDisapprovalPct)
);
}
}

Expand Down
2 changes: 2 additions & 0 deletions test/token-voting/LlamaTokenVotingFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,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,
Expand Down Expand Up @@ -141,6 +142,7 @@ contract DeployTokenVotingModule is LlamaTokenVotingFactoryTest {
// Set up action to call `deployTokenVotingModule` with the ERC721 token.
bytes memory data = abi.encodeWithSelector(
LlamaTokenVotingFactory.deployTokenVotingModule.selector,
CORE,
address(erc721VotesToken),
false,
tokenVotingActionCreatorRole,
Expand Down
2 changes: 2 additions & 0 deletions test/token-voting/LlamaTokenVotingTestSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ contract LlamaTokenVotingTestSetup is LlamaPeripheryTestSetup, DeployLlamaTokenV
vm.startPrank(address(EXECUTOR));
// Deploy Token Voting Module
(address erc20TokenholderActionCreator, address erc20TokenholderCaster) = tokenVotingFactory.deployTokenVotingModule(
CORE,
address(erc20VotesToken),
true,
tokenVotingActionCreatorRole,
Expand Down Expand Up @@ -123,6 +124,7 @@ contract LlamaTokenVotingTestSetup is LlamaPeripheryTestSetup, DeployLlamaTokenV
// Deploy Token Voting Module
(address erc721TokenholderActionCreator, address erc721TokenholderCaster) = tokenVotingFactory
.deployTokenVotingModule(
CORE,
address(erc721VotesToken),
false,
tokenVotingActionCreatorRole,
Expand Down
Loading