Skip to content

Commit

Permalink
Redeploy contract (fixes #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
sembrestels committed Sep 23, 2024
1 parent d2fa219 commit 56136ca
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 41 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ToastProvider } from "@repo/ui/components/ui/toast";
import { Toaster } from "@repo/ui/components/ui/toaster";
import type { Metadata } from "next";
import { Newsreader } from "next/font/google";
import { SITE_DESCRIPTION, SITE_NAME } from "../../../../constants";
import Footer from "../components/Footer";
import Header from "../components/Header";
import { SITE_DESCRIPTION, SITE_NAME } from "../constants";
import { WalletProvider } from "../context/WalletProvider";

const newsreader = Newsreader({
Expand Down
7 changes: 3 additions & 4 deletions apps/web/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { getAddress } from "viem";
import { useAccount } from "wagmi";
import { DEFAULT_COUNCIL_ADDRESS } from "../../../../constants";
import { CouncilName } from "../components/CouncilName";
import VotingCard from "../components/VotingCard";
import { useAllocation } from "../hooks/useAllocation";
import { useCouncil } from "../hooks/useCouncil";

const defaultCouncil = "0x5cE162b6e6Dd6B936B9dC183Df79F61DBf8c675f";

export default function Page() {
const router = useRouter();
const [council, setCouncil] = useState<`0x${string}` | undefined>(undefined);

useEffect(() => {
// Ensure the code runs only on the client side
if (!window.location.hash) {
router.push(`#${defaultCouncil}`);
router.push(`#${DEFAULT_COUNCIL_ADDRESS}`);
}
// Set the council value once the hash is present
const address = getAddress(
window.location.hash?.slice(1) || defaultCouncil,
window.location.hash?.slice(1) || DEFAULT_COUNCIL_ADDRESS,
);
setCouncil(address);
}, [router]);
Expand Down
3 changes: 0 additions & 3 deletions apps/web/src/constants.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/web/src/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getDefaultConfig } from "@rainbow-me/rainbowkit";
import { createPublicClient } from "viem";
import { http, createConfig } from "wagmi";
import { mainnet, optimism } from "wagmi/chains";
import { SITE_NAME } from "../constants";
import { SITE_NAME } from "../../../../constants";

export const WALLETCONNECT_PROJECT_ID =
process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID ?? "";
Expand Down
8 changes: 8 additions & 0 deletions constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const SITE_NAME = "Councilhaus";
export const SITE_DESCRIPTION =
"Democratically allocate a budget across projects";

export const DEFAULT_COUNCIL_ADDRESS =
"0xcb95ecd61ab17c9aecb5553287e1b77b4ff1e5e5";
export const COUNCIL_FACTORY_ADDRESS =
"0xca0b05c27d6856f450b6abfb7a2d8c9d32164ecf"; // Update also in contracts/councilhaus/subgraph/config/optimism.json
20 changes: 12 additions & 8 deletions contracts/councilhaus/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Sample Hardhat Project
# Councilhaus Contracts

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:
In order to deploy the contracts, you need to set the following variables:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat vars set ALCHEMY_KEY
npx hardhat vars set WALLET_KEY
npx hardhat run scripts/deploy.ts
```

In order to verify the contracts, you need to set the following variables:

```shell
npx hardhat vars set ETHERSCAN_KEY
npx hardhat verify --network <network> <factoryAddress> 0x6DA13Bde224A05a288748d857b9e7DDEffd1dE08
npx hardhat verify --network <network> <councilAddress> "Spacing Guild" "SPA" 0x7d342726b69c28d942ad8bfe6ac81b972349d524 0x6DA13Bde224A05a288748d857b9e7DDEffd1dE08
```
5 changes: 0 additions & 5 deletions contracts/councilhaus/contracts/Council.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ struct Allocation {
contract Council is NonTransferableToken, AccessControl, PoolManager {
// Custom error definitions
error InvalidMaxAllocations();
error FlowRateMustBePositive();
error CouncilMemberAlreadyAdded();
error CouncilMemberNotFound();
error TooManyAllocations();
Expand All @@ -36,13 +35,11 @@ contract Council is NonTransferableToken, AccessControl, PoolManager {

// Event definitions
event MaxAllocationsPerMemberSet(uint8 maxAllocationsPerMember);
event FlowRateSet(int96 flowRate);
event CouncilMemberAdded(address member, uint256 votingPower);
event CouncilMemberRemoved(address member);
event GranteeAdded(string name, address grantee);
event GranteeRemoved(address grantee);
event BudgetAllocated(address member, Allocation allocation);
event BudgetExecuted();
event Withdrawn(address token, address account, uint256 amount);

// Constants
Expand Down Expand Up @@ -75,8 +72,6 @@ contract Council is NonTransferableToken, AccessControl, PoolManager {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(MEMBER_MANAGER_ROLE, msg.sender);
_grantRole(GRANTEE_MANAGER_ROLE, msg.sender);

emit MaxAllocationsPerMemberSet(MAX_ALLOCATIONS_PER_MEMBER);
}

/**
Expand Down
25 changes: 9 additions & 16 deletions contracts/councilhaus/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox-viem";
import "hardhat-abi-exporter";
import { vars } from "hardhat/config";

const alchemyKey = vars.has("ALCHEMY_KEY") ? vars.get("ALCHEMY_KEY") : "";
const walletKey = vars.has("WALLET_KEY") ? [vars.get("WALLET_KEY")] : [];
const etherscanKey = vars.has("ETHERSCAN_KEY") ? vars.get("ETHERSCAN_KEY") : "";

const config: HardhatUserConfig = {
solidity: {
Expand All @@ -15,30 +20,18 @@ const config: HardhatUserConfig = {
networks: {
hardhat: {},
optimism: {
url: `https://opt-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`,
accounts: process.env.WALLET_KEY ? [process.env.WALLET_KEY] : [],
url: `https://opt-mainnet.g.alchemy.com/v2/${alchemyKey}`,
accounts: walletKey,
},
},
etherscan: {
apiKey: {
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",
// },
// },
// ],
apiKey: etherscanKey,
},
sourcify: {
enabled: false,
},
abiExporter: {
path: "../councilhaus-subgraph/abis",
path: "./subgraph/abis",
runOnCompile: true,
clear: true,
flat: true,
Expand Down
1 change: 1 addition & 0 deletions contracts/councilhaus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"scripts": {
"compile": "hardhat compile",
"deploy": "hardhat run scripts/deploy.ts",
"verify": "hardhat verify --network optimism",
"dev": "hardhat node",
"test": "hardhat test --network hardhat",
"test:coverage": "SOLIDITY_COVERAGE=true hardhat coverage"
Expand Down
3 changes: 2 additions & 1 deletion contracts/councilhaus/scripts/createCouncil.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { viem } from "hardhat";
import { parseEventLogs } from "viem";
import { COUNCIL_FACTORY_ADDRESS } from "../../../constants";

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

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

const hash = await councilFactory.write.createCouncil([
Expand Down
4 changes: 2 additions & 2 deletions contracts/councilhaus/subgraph/config/optimism.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"network": "optimism",
"address": "0x8e01ebaa4f4d660294e0d1301fe46ed96f4c44eb",
"startBlock": 125496765
"address": "0xca0b05c27d6856f450b6abfb7a2d8c9d32164ecf",
"startBlock": 125751727
}

0 comments on commit 56136ca

Please sign in to comment.