Skip to content

Commit

Permalink
Merge pull request #39 from HausDAO/feat/factory-contructor-addresses
Browse files Browse the repository at this point in the history
add loot and share singleton to factory constructor
  • Loading branch information
dekanbro authored Jul 6, 2022
2 parents a7593d8 + 895c86e commit eb40d85
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 80 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

*This is the most recent collaborative repository for Moloch V3, codename Baal. (Jan 13, 2022). This message will change when the repository is depricated.*

*this readme is out of date*

## Goerli test deploy

lootSingleton: 0x9391b6A7c55832a6802484dE054d81496D56545A
sharesSingleton: 0xF69CF34FcB54f71fBD4fd83664F7Db6d4926dD34
baalSingleton: 0x98B550caBec2602eE2c2259179d1A935777Ff257
Summoner Address: 0x93ac67998B80692366c537D3537ea6640fc65c97


Baal is a minimal yet composable DAO template continuing work from the [`Moloch`](https://github.com/MolochVentures/moloch), [`Minion`](https://github.com/raid-guild/moloch-minion) and [`Compound`](https://github.com/compound-finance/compound-protocol/tree/master/contracts/Governance) frameworks to make it easier for people to combine and command crypto assets with intuitive membership games.

*Guilds, venture clubs and control panels can benefit from Baal:*
Expand Down
37 changes: 21 additions & 16 deletions contracts/Baal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,12 @@ contract BaalSummoner is ModuleProxyFactory {
// Library to use for all safe transaction executions
address public immutable gnosisMultisendLibrary;

// template contract to clone for loot ERC20 token
address public immutable lootSingleton;

// template contract to clone for shares ERC20 token
address public immutable sharesSingleton;

// Proxy summoners
//
GnosisSafeProxyFactory gnosisSafeProxyFactory;
Expand All @@ -1102,7 +1108,9 @@ contract BaalSummoner is ModuleProxyFactory {
address _gnosisFallbackLibrary,
address _gnosisMultisendLibrary,
address _gnosisSafeProxyFactory,
address _moduleProxyFactory
address _moduleProxyFactory,
address _lootSingleton,
address _sharesSingleton
) {
template = _template;
gnosisSingleton = _gnosisSingleton;
Expand All @@ -1112,6 +1120,9 @@ contract BaalSummoner is ModuleProxyFactory {
_gnosisSafeProxyFactory
);
moduleProxyFactory = ModuleProxyFactory(_moduleProxyFactory);
lootSingleton = _lootSingleton;
sharesSingleton = _sharesSingleton;

}

function encodeMultisend(bytes[] memory _calls, address _target)
Expand Down Expand Up @@ -1144,13 +1155,10 @@ contract BaalSummoner is ModuleProxyFactory {
(
string memory _name, /*_name Name for erc20 `shares` accounting*/
string memory _symbol, /*_symbol Symbol for erc20 `shares` accounting*/
address _lootSingleton, /*template contract to clone for loot ERC20 token*/
address _sharesSingleton, /*template contract to clone for loot ERC20 token*/
address _multisendLibrary, /*address of multisend library*/
address _safeAddr /*address of safe*/
) = abi.decode(
initializationParams,
(string, string, address, address, address, address)
(string, string, address)
);

// TODO: allow safe to init baal
Expand All @@ -1165,9 +1173,9 @@ contract BaalSummoner is ModuleProxyFactory {
bytes memory _initializer = abi.encode(
_name,
_symbol,
_lootSingleton,
_sharesSingleton,
_multisendLibrary,
lootSingleton,
sharesSingleton,
gnosisMultisendLibrary,
_safeAddr,
_initializationMultisendData
);
Expand Down Expand Up @@ -1238,13 +1246,10 @@ contract BaalSummoner is ModuleProxyFactory {
) external returns (address) {
(
string memory _name, /*_name Name for erc20 `shares` accounting*/
string memory _symbol, /*_symbol Symbol for erc20 `shares` accounting*/
address _lootSingleton, /*template contract to clone for loot ERC20 token*/
address _sharesSingleton, /*template contract to clone for loot ERC20 token*/
address _multisendLibrary /*address of multisend library*/
string memory _symbol /*_symbol Symbol for erc20 `shares` accounting*/
) = abi.decode(
initializationParams,
(string, string, address, address, address)
(string, string)
);

bytes memory _anyCall = abi.encodeWithSignature("avatar()"); /*This call can be anything, it just needs to return successfully*/
Expand All @@ -1260,9 +1265,9 @@ contract BaalSummoner is ModuleProxyFactory {
bytes memory _initializer = abi.encode(
_name,
_symbol,
_lootSingleton,
_sharesSingleton,
_multisendLibrary,
lootSingleton,
sharesSingleton,
gnosisMultisendLibrary,
_safe,
_initializationMultisendData
);
Expand Down
20 changes: 16 additions & 4 deletions scripts/deployfactories.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ const _shamans = {
42: ['']
}

// same for all networks
// same default for all networks, but different sometimes
// https://github.com/gnosis/zodiac/blob/master/src/factory/constants.ts#L20
// https://github.com/safe-global/safe-deployments/tree/main/src/assets
// moduleProxyFactory default 0x00000000062c52e29e8029dc2413172f6d619d85 goerli, optimism and arbitrum at 0x270c012B6C2A61153e8A6d82F2Cb4F88ddB7fD5E
const _addresses = {
gnosisSingleton: "0xd9db270c1b5e3bd161e8c8503c55ceabee709552",
gnosisFallbackLibrary: "0xf48f2b2d2a534e402487b3ee7c18c33aec0fe5e4",
gnosisMultisendLibrary: "0xa238cbeb142c10ef7ad8442c6d1f9e89e07e7761",
poster: "0x000000000000cd17345801aa8147b8D3950260FF"
poster: "0x000000000000cd17345801aa8147b8D3950260FF",
gnosisSafeProxyFactory: "0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2",
moduleProxyFactory: "0x270c012B6C2A61153e8A6d82F2Cb4F88ddB7fD5E",
}



const _shares = ['1'];
const _loot = ['1'];
const _minVoting = 60;
Expand Down Expand Up @@ -78,10 +85,15 @@ async function main() {
baalSingleton.address,
_addresses.gnosisSingleton,
_addresses.gnosisFallbackLibrary,
_addresses.gnosisMultisendLibrary))
_addresses.gnosisMultisendLibrary,
_addresses.gnosisSafeProxyFactory,
_addresses.moduleProxyFactory,
lootSingleton.address,
sharesSingleton.address))

await baalSummoner.deployed();


// const factory = await ethers.getContractFactory('Baal');
// const Baal = await factory.deploy(
// _shamans[chainId],
Expand All @@ -103,7 +115,7 @@ async function main() {
const txHash = baalSummoner.deployTransaction.hash;
const receipt = await deployer.provider.getTransactionReceipt(txHash);
console.log('Transaction Hash:', txHash);
console.log('Contract Address:', baalSummoner.address);
console.log('Factory Contract Address:', baalSummoner.address);
console.log('Block Number:', receipt.blockNumber);
}

Expand Down
23 changes: 2 additions & 21 deletions tasks/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,6 @@ task("memberprop", "Submits a new member proposal")

task("summon", "Summons a new DAO")
.addParam("factory", "Dao factory address")
.addParam("loottemplate", "loot template")
.addParam("sharestemplate", "shares template")
.addParam(
"summoners",
'the summoner addresses (array) (escape quotes) (no spaces) ex [\\"0x123...\\"]'
Expand Down Expand Up @@ -362,9 +360,6 @@ task("summon", "Summons a new DAO")
const abiCoder = hre.ethers.utils.defaultAbiCoder;
const getBaalParams = async function (
baal: Baal,
multisend: MultiSend,
lootSingleton: Loot,
sharesSingleton: Shares,
poster: Poster,
config: {
PROPOSAL_OFFERING: any;
Expand Down Expand Up @@ -442,13 +437,10 @@ task("summon", "Summons a new DAO")
// )
return {
initParams: abiCoder.encode(
["string", "string", "address", "address", "address"],
["string", "string"],
[
config.TOKEN_NAME,
config.TOKEN_SYMBOL,
lootSingleton.address,
sharesSingleton.address,
multisend.address,
config.TOKEN_SYMBOL
]
),
initalizationActions,
Expand Down Expand Up @@ -486,14 +478,6 @@ task("summon", "Summons a new DAO")
const poster = (await posterFactory.attach(posterAddress)) as Poster;
console.log("**********************");

const LootFactory = await hre.ethers.getContractFactory("Loot");
const lootSingleton = (await LootFactory.attach(
taskArgs.loottemplate
)) as Loot;
const SharesFactory = await hre.ethers.getContractFactory("Shares");
const sharesSingleton = (await SharesFactory.attach(
taskArgs.sharestemplate
)) as Shares;
const Baal = await hre.ethers.getContractFactory("Baal");
const baalSingleton = (await Baal.attach(baalTemplateAddr)) as Baal;
const MultisendContract = await hre.ethers.getContractFactory("MultiSend");
Expand All @@ -503,9 +487,6 @@ task("summon", "Summons a new DAO")

encodedInitParams = await getBaalParams(
baalSingleton,
multisend,
lootSingleton,
sharesSingleton,
poster,
deploymentConfig,
[metadataConfig.CONTENT, metadataConfig.TAG],
Expand Down
39 changes: 12 additions & 27 deletions test/BaalSafe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ const abiCoder = ethers.utils.defaultAbiCoder;

const getBaalParams = async function (
baal: Baal,
multisend: MultiSend,
lootSingleton: Loot,
sharesSingleton: Shares,
poster: Poster,
config: {
PROPOSAL_OFFERING: any;
Expand Down Expand Up @@ -216,13 +213,10 @@ const getBaalParams = async function (
// )
return {
initParams: abiCoder.encode(
["string", "string", "address", "address", "address"],
["string", "string"],
[
config.TOKEN_NAME,
config.TOKEN_SYMBOL,
lootSingleton.address,
sharesSingleton.address,
multisend.address,
]
),
initalizationActions,
Expand Down Expand Up @@ -429,14 +423,13 @@ describe("Baal contract", function () {
handler.address,
multisend.address,
proxy.address,
moduleProxyFactory.address
moduleProxyFactory.address,
lootSingleton.address,
sharesSingleton.address,
)) as BaalSummoner;

encodedInitParams = await getBaalParams(
baalSingleton,
multisend,
lootSingleton,
sharesSingleton,
poster,
deploymentConfig,
[metadataConfig.CONTENT, metadataConfig.TAG],
Expand Down Expand Up @@ -3323,14 +3316,13 @@ describe("Baal contract - offering required", function () {
handler.address,
multisend.address,
proxy.address,
moduleProxyFactory.address
moduleProxyFactory.address,
lootSingleton.address,
sharesSingleton.address,
)) as BaalSummoner;

const encodedInitParams = await getBaalParams(
baalSingleton,
multisend,
lootSingleton,
sharesSingleton,
poster,
customConfig,
[metadataConfig.CONTENT, metadataConfig.TAG],
Expand All @@ -3343,7 +3335,7 @@ describe("Baal contract - offering required", function () {
const tx = await baalSummoner.summonBaalAndSafe(
encodedInitParams.initParams,
encodedInitParams.initalizationActions,
101
101 // nonce
);
const addresses = await getNewBaalAddresses(tx);

Expand Down Expand Up @@ -3448,9 +3440,6 @@ describe("Baal contract - offering required", function () {

const getBaalParamsWithAvatar = async function (
baal: Baal,
multisend: MultiSend,
lootSingleton: Loot,
sharesSingleton: Shares,
poster: Poster,
config: {
PROPOSAL_OFFERING: any;
Expand Down Expand Up @@ -3528,13 +3517,10 @@ const getBaalParamsWithAvatar = async function (
// )
return {
initParams: abiCoder.encode(
["string", "string", "address", "address", "address", "address"],
["string", "string", "address"],
[
config.TOKEN_NAME,
config.TOKEN_SYMBOL,
lootSingleton.address,
sharesSingleton.address,
multisend.address,
safeAddr,
]
),
Expand Down Expand Up @@ -3644,14 +3630,13 @@ describe("Baal contract - summon baal with current safe", function () {
handler.address,
multisend.address,
proxy.address,
moduleProxyFactory.address // use valid safe address
moduleProxyFactory.address,
lootSingleton.address,
sharesSingleton.address,
)) as BaalSummoner;

const encodedInitParams = await getBaalParamsWithAvatar(
baalSingleton,
multisend,
lootSingleton,
sharesSingleton,
poster,
customConfig,
[metadataConfig.CONTENT, metadataConfig.TAG],
Expand Down
17 changes: 5 additions & 12 deletions test/Tribute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ const abiCoder = ethers.utils.defaultAbiCoder;

const getBaalParams = async function (
baal: Baal,
multisend: MultiSend,
lootSingleton: Loot,
sharesSingleton: Shares,
poster: Poster,
config: {
PROPOSAL_OFFERING: any;
Expand Down Expand Up @@ -175,13 +172,10 @@ const getBaalParams = async function (

return {
initParams: abiCoder.encode(
["string", "string", "address", "address", "address"],
["string", "string"],
[
config.TOKEN_NAME,
config.TOKEN_SYMBOL,
lootSingleton.address,
sharesSingleton.address,
multisend.address,
config.TOKEN_SYMBOL
]
),
initalizationActions,
Expand Down Expand Up @@ -290,14 +284,13 @@ describe("Tribute proposal type", function () {
handler.address,
multisend.address,
proxy.address,
moduleProxyFactory.address
moduleProxyFactory.address,
lootSingleton.address,
sharesSingleton.address,
)) as BaalSummoner;

encodedInitParams = await getBaalParams(
baalSingleton,
multisend,
lootSingleton,
sharesSingleton,
poster,
deploymentConfig,
[sharesPaused, lootPaused],
Expand Down

0 comments on commit eb40d85

Please sign in to comment.