Skip to content

Commit

Permalink
Merge pull request #123 from HausDAO/feat/factory-upgrade
Browse files Browse the repository at this point in the history
Factory upgrade
  • Loading branch information
santteegt authored Jun 11, 2024
2 parents c60c6de + ecba013 commit ee3d5ab
Show file tree
Hide file tree
Showing 14 changed files with 2,557 additions and 575 deletions.
59 changes: 44 additions & 15 deletions contracts/BaalSummoner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,7 @@ contract BaalSummoner is Initializable, OwnableUpgradeable, UUPSUpgradeable {

}

// deploy a safe with module and single module signer setup
function deployAndSetupSafe(address _moduleAddr)
public
returns (address)
{
// Deploy new safe but do not set it up yet
GnosisSafe _safe = GnosisSafe(
payable(
gnosisSafeProxyFactory.createProxy(
gnosisSingleton,
bytes("")
)
)
);
function configureSafe(address _moduleAddr, GnosisSafe _safe) internal {
// Generate delegate calls so the safe calls enableModule on itself during setup
bytes memory _enableBaal = abi.encodeWithSignature(
"enableModule(address)",
Expand Down Expand Up @@ -230,6 +217,48 @@ contract BaalSummoner is Initializable, OwnableUpgradeable, UUPSUpgradeable {
0,
payable(address(0))
);
}


// deploy a safe with module and single module signer setup
// with nounce
function deployAndSetupSafe(address _moduleAddr, uint256 _saltNonce)
public
returns (address)
{
GnosisSafe _safe = GnosisSafe(
payable(
gnosisSafeProxyFactory.createProxyWithNonce(
gnosisSingleton,
bytes(""),
_saltNonce
)
)
);

configureSafe(_moduleAddr, _safe);

emit DeployBaalSafe(address(_safe), address(_moduleAddr));

return address(_safe);
}


// deploy a safe with module and single module signer setup
function deployAndSetupSafe(address _moduleAddr)
public
returns (address)
{
GnosisSafe _safe = GnosisSafe(
payable(
gnosisSafeProxyFactory.createProxy(
gnosisSingleton,
bytes("")
)
)
);

configureSafe(_moduleAddr, _safe);

emit DeployBaalSafe(address(_safe), address(_moduleAddr));

Expand Down Expand Up @@ -282,7 +311,7 @@ contract BaalSummoner is Initializable, OwnableUpgradeable, UUPSUpgradeable {
// if zero address deploy a new safe
// Needs to be a valid zodiac treasury
if(_safeAddr == address(0)){
_safeAddr = deployAndSetupSafe(address(_baal));
_safeAddr = deployAndSetupSafe(address(_baal), _saltNonce);
} else {
existingAddrs += 2;
}
Expand Down
34 changes: 34 additions & 0 deletions contracts/interfaces/IBaal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@
pragma solidity ^0.8.7;

interface IBaal {
// DATA STRUCTURES
struct Proposal {
/*Baal proposal details*/
uint32 id; /*id of this proposal, used in existence checks (increments from 1)*/
uint32 prevProposalId; /* id of the previous proposal - set at sponsorship from latestSponsoredProposalId */
uint32 votingStarts; /*starting time for proposal in seconds since unix epoch*/
uint32 votingEnds; /*termination date for proposal in seconds since unix epoch - derived from `votingPeriod` set on proposal*/
uint32 graceEnds; /*termination date for proposal in seconds since unix epoch - derived from `gracePeriod` set on proposal*/
uint32 expiration; /*timestamp after which proposal should be considered invalid and skipped. */
uint256 baalGas; /* gas needed to process proposal */
uint256 yesVotes; /*counter for `members` `approved` 'votes' to calculate approval on processing*/
uint256 noVotes; /*counter for `members` 'dis-approved' 'votes' to calculate approval on processing*/
uint256 maxTotalSharesAndLootAtVote; /* highest share+loot count during any individual yes vote*/
uint256 maxTotalSharesAtSponsor; /* highest share+loot count during any individual yes vote*/
bool[4] status; /* [cancelled, processed, passed, actionFailed] */
address sponsor; /* address of the sponsor - set at sponsor proposal - relevant for cancellation */
bytes32 proposalDataHash; /*hash of raw data associated with state updates*/
}

/* Unborn -> Submitted -> Voting -> Grace -> Ready -> Processed
\-> Cancelled \-> Defeated */
enum ProposalState {
Unborn, /* 0 - can submit */
Submitted, /* 1 - can sponsor -> voting */
Voting, /* 2 - can be cancelled, otherwise proceeds to grace */
Cancelled, /* 3 - terminal state, counts as processed */
Grace, /* 4 - proceeds to ready/defeated */
Ready, /* 5 - can be processed */
Processed, /* 6 - terminal state */
Defeated /* 7 - terminal state, yes votes <= no votes, counts as processed */
}

function lootToken() external view returns (address);
function sharesToken() external view returns (address);
function votingPeriod() external view returns (uint32);
Expand All @@ -12,6 +44,8 @@ interface IBaal {
function sponsorThreshold() external view returns (uint256);
function minRetentionPercent() external view returns (uint256);
function latestSponsoredProposalId() external view returns (uint32);
function state(uint32 id) external view returns (ProposalState);
function proposals(uint32 id) external view returns (Proposal memory);

function setUp(bytes memory initializationParams) external;
function multisendLibrary() external view returns (address);
Expand Down
42 changes: 42 additions & 0 deletions deploy/006_upgrade_b_factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';
const { ethers, upgrades } = require("hardhat");
import { DeployFunction } from 'hardhat-deploy/types';

import { getSetupAddresses } from '../src/addresses/setup';

const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {

const { deployments, ethers, getChainId, getNamedAccounts, network } = hre;

const { deployer } = await getNamedAccounts();
const chainId = await getChainId();

const _addresses = await getSetupAddresses(chainId, network, deployments);

if ((!_addresses.DAO || _addresses.DAO === ethers.constants.AddressZero) && network.name !== 'hardhat') {
console.log('You need to set DAO address to transfer ownership of summoner', _addresses.DAO);
return;
}

console.log('\n\nDeploying BaalSummoner factory on network:', network.name);
console.log('Deployer address:', `${chainId}:${deployer}`);
console.log(
'Deployer balance:',
ethers.utils.formatEther(await ethers.provider.getBalance(deployer)),
);

const { deploy } = deployments;

const summonerDeeployed = await deploy('BaalSummoner', {
contract: 'BaalSummoner',
from: deployer,
args: [],
log: true,
});
console.log('BaalSummoner deployment Tx ->', summonerDeeployed.transactionHash);


};

export default deployFn;
deployFn.tags = ['UpgradeBaalSummoner'];
384 changes: 286 additions & 98 deletions deployments/goerli/BaalSummoner.json

Large diffs are not rendered by default.

Loading

0 comments on commit ee3d5ab

Please sign in to comment.