Skip to content

Commit

Permalink
Open the pool so anyone can send funds
Browse files Browse the repository at this point in the history
  • Loading branch information
sembrestels committed Sep 7, 2024
1 parent 881a9e0 commit 89c6ae0
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 14 deletions.
2 changes: 1 addition & 1 deletion contracts/councilhaus/contracts/PoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract contract PoolManager {
address(this),
PoolConfig({
transferabilityForUnitsOwner: false,
distributionFromAnyAddress: false
distributionFromAnyAddress: true
})
);
// Revert if pool creation fails
Expand Down
22 changes: 11 additions & 11 deletions contracts/councilhaus/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ const config: HardhatUserConfig = {
},
etherscan: {
apiKey: {
optimism: process.env.BLOCKSCOUT_KEY as string,
optimisticEthereum: process.env.ETHERSCAN_API_KEY as string,
},
customChains: [
{
network: "optimism",
chainId: 10,
urls: {
apiURL: "https://optimism.blockscout.com/api",
browserURL: "https://optimism.blockscout.com",
},
},
],
// customChains: [
// {
// network: "optimism",
// chainId: 10,
// urls: {
// apiURL: "https://optimism.blockscout.com/api",
// browserURL: "https://optimism.blockscout.com",
// },
// },
// ],
},
sourcify: {
enabled: false,
Expand Down
2 changes: 1 addition & 1 deletion contracts/councilhaus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"compile": "hardhat compile",
"deploy": "hardhat run scripts/deploy.ts --network hardhat",
"deploy": "hardhat run scripts/deploy.ts",
"dev": "hardhat node",
"test": "hardhat test --network hardhat",
"test:coverage": "SOLIDITY_COVERAGE=true hardhat coverage"
Expand Down
61 changes: 61 additions & 0 deletions contracts/councilhaus/scripts/createCouncil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { viem } from "hardhat";
import { parseEventLogs, parseUnits } from "viem";

async function main() {
const publicClient = await viem.getPublicClient();


const councilFactory = await viem.getContractAt("CouncilFactory", "0x207940b61c2b51ee1da56855ee745d10a34422ab");

const hash = await councilFactory.write.createCouncil([
{
councilName: "Spacing Guild",
councilSymbol: "SPA",
councilMembers: [
{ account: "0x0992b9c6eA15A09418fF454a436705aE29877D88", votingPower: parseUnits("100", 18) },
{ account: "0xf632ce27ea72dea30d30c1a9700b6b3bceaa05cf", votingPower: parseUnits("100", 18) },
{ account: "0xbaD8bcc9Eb5749829cF12189fDD5c1230D6C85e8", votingPower: parseUnits("100", 18) },
],
grantees: [
{ name: "ENS Wayback Machine", account: "0x6ea869B6870dd98552B0C7e47dA90702a436358b" },
{ name: "Giveth House", account: "0xB6989F472Bef8931e6Ca882b1f875539b7D5DA19" },
{ name: "EVMcrispr", account: "0xeafFF6dB1965886348657E79195EB6f1A84657eB" },
],
distributionToken: "0x7d342726b69c28d942ad8bfe6ac81b972349d524", // DAIx
},
]);

const receipt = await publicClient.waitForTransactionReceipt({
hash,
});

const logs = parseEventLogs({
abi: councilFactory.abi,
logs: receipt.logs,
});

// Type guard to check if log.args has the expected shape
function isCouncilCreatedArgs(
args: any,
): args is { council: `0x${string}`; pool: `0x${string}` } {
return (
args && typeof args.council === "string" && typeof args.pool === "string"
);
}

logs
.filter((log) => log.eventName === "CouncilCreated")
.map((log) => log.args)
.filter(isCouncilCreatedArgs)
.map(
({ council, pool }) => `Council deployed to ${council} with pool ${pool}`,
)
.map((s) => console.log(s));
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
2 changes: 1 addition & 1 deletion contracts/councilhaus/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function main() {
},
]);

const receipt = await publicClient.getTransactionReceipt({
const receipt = await publicClient.waitForTransactionReceipt({
hash,
});

Expand Down

0 comments on commit 89c6ae0

Please sign in to comment.