Skip to content

Commit

Permalink
update bare bones for 0.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
dekanbro committed Nov 1, 2023
1 parent 867d58d commit 6dafb9c
Show file tree
Hide file tree
Showing 8 changed files with 4,313 additions and 1,240 deletions.
23 changes: 21 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
# rivet key for rpc calls, you can also pass in custom rpcs to many components
VITE_RIVET_KEY=
VITE_ETHERSCAN_KEY=

# add your graph api key if using mainnet or gnosischain
VITE_GRAPH_API_KEY_MAINNET=
VITE_TARGET_KEY=

# key from wallet connect is required
VITE_WALLET_CONNECT_ID=

# optional will use rate limited if not set
VITE_OPTIMISM_ALCHEMY_KEY=
VITE_ARBITRUM_ALCHEMY_KEY=
VITE_POLYGONPOS_ALCHEMY_KEY=

# add blockexplorer api keys for any supported networks
VITE_ETHERSCAN_KEY=
VITE_ARBISCAN_KEY=
VITE_GNOSISSCAN_KEY=
VITE_POLYGONSCAN_KEY=
VITE_OPTIMISMSCAN_KEY=

# corresponds to keys in targetDao.ts if scoping app to a single dao
VITE_TARGET_KEY=
132 changes: 79 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ Vite React Starter for a DAO app scoped to a single DAO.

### 1. Project Setup

#### NPX/degit

```bash
npx degit HausDAO/dao-app-starter-vite my-daohaus-app

cd my-daohaus-app

git init

yarn
```

#### SSH

```bash
git clone [email protected]:HausDAO/moloch-v3-vite-starter.git

git remote remove origin

cd dh-moloch-v3-vite-starter

yarn
Expand All @@ -21,6 +35,8 @@ yarn
```bash
git clone https://github.com/HausDAO/dh-v3-vite-starter.git

git remote remove origin

cd dh-moloch-v3-vite-starter

yarn
Expand All @@ -32,45 +48,80 @@ yarn
cp .env.sample .env
```

Rivet is the default RPC - Get a free Rivet key [here](https://rivet.cloud/)

```yaml
VITE_RIVET_KEY
```

Get a free Rivet key [here](https://rivet.cloud/)
You can also use Alchemy API keys for Optimism, Arbitrum or Polygon

```yaml
VITE_EXPLORER_KEY
VITE_OPTIMISM_ALCHEMY_KEY
VITE_ARBITRUM_ALCHEMY_KEY
VITE_POLYGONPOS_ALCHEMY_KEY
```

Get an Etherscan API key [here](https://etherscan.io/apis)
Proposal details uses etherscan explorer APIs to fetch ABIs. Add a key for any chain you are supporting. Get an Etherscan API key [here](https://etherscan.io/apis)

```yaml
VITE_GRAPH_API_KEY_MAINNET
VITE_ETHERSCAN_KEY
VITE_ARBISCAN_KEY
VITE_GNOSISSCAN_KEY
VITE_POLYGONSCAN_KEY
VITE_OPTIMISMSCAN_KEY
```

If developing for Mainnet or Gnosis Chain you can get an API key [here](https://thegraph.com/explorer/subgraph?id=GfHFdFmiSwW1PKtnDhhcxhArwtTjVuMnXxQ5XcETF1bP&view=Overview). Ignore this one if not worried about mainnet or gnosis chain yet.

```yaml
VITE_GRAPH_API_KEY_MAINNET
```

This is the target address for the DAO you are developing the app for. You will get this value in the next step if you do not have an existing DAO. You'll need to use this if you are setting the app up for single DAO. More on this below.

```yaml
VITE_TARGET_KEY
```

This is the target address for the DAO you are developing the app for. You will get this value in the next step if you do not have an existing DAO.
### 3. Single DAO vs. Multi-DAO Setup

### 3. Target DAO Set-up
#### If your app is supporting a single DAO

[Summon](https://summon.daohaus.club) a DAO

#### Edit `src/targetDao.ts`
##### Edit `src/targetDao.ts`

Add your DAO's data to the property and values of the object

#### Edit `.env`
##### Edit `.env`

Add the DAO address in the `VITE_TARGET_KEY` variable

- You can add multiple DAOs as new objects in `targetDao.ts` and toggle with this `env` variable
- You can add other variables to `targetDao.ts` as needed

#### If your app is supporting multiple DAOs

Remove VITE_TARGET_KEY from the .env file.

You will now beable to navigate to any existing dao whenrunning the app with the following url pattern:

`/#/molochv3/:daochain/:daoid`

This is the same pattern seen in the [DAOhaus admin app](https://admin.daohaus.club/#/molochv3/0x5/0xf6538c07324f59b3ba685d86393c65dce9676c70)

##### `:daochain` is the network ID for the DAO

'0x1' - mainnet
'0x5' - goerli
'0x64' - gnosis chain
'0x89' - polygon
'0xa' - optimism
'0xa4b1' - arbitrum

##### `:daoid` is the contract address for the DAO smart contract

### 4. Run the Development Server

```bash
Expand All @@ -82,13 +133,23 @@ yarn dev
### `main.tsx`

- Sets up the `react-query` provider `@daohaus/moloch-v3-hooks` will use
- Sets up `DHConnectProvider` - that handles the Wallet Connect functionality
- Sets up `HausThemeProvider` - that provides the styling theme to the app

### `App.tsx`

- Sets up `DHConnectProvider` - that handles the Wallet Connect functionality
- Adds the router to the app

### `HomeContainer.tsx`

- Parent component wrapping all routes/pages
- Parent component wrapping all on-dao scoped routes/pages
- Sets up `DHLayout` which adds the connect button and navigation to the app
- You can update the navigation in `navLinks`
-

### `DaoContainer.tsx`

- Parent component wrapping all dao scoped routes/pages
- Sets up `DHLayout` which adds the connect button and navigation to the app
- You can update the navigation in `navLinks`
- Sets up `TXBuilder` which enables easy transaction creation
Expand All @@ -99,50 +160,21 @@ yarn dev
- See the legos it is using at `legos/forms.ts`, `legos/fields.ts`, and `legos/tx.ts`
- These are recipes for creating forms and contract function interactions

### ToDo
### Pages/

- Ad routes/pages for dao overview, vaults, settings
- proposals, members and profile coming soon
- show hook data fetch
- show macro ui addition
- `moloch-v3-fields` package
- coming soon
- Example of many current DAO Admin pages
- Dao overview
- Proposal list and Proposal details
- Member list and Member details
- Dao Settings

### Adding UI Components

- [Storybook](https://storybook.js.org/)

### Methods for Accessing `daoid` and `daochain`

These values are used in most hooks and components and you have some options:

Get them from `targetDao.ts`

```tsx
const daoChain = TARGET_DAO[import.meta.env.VITE_TARGET_KEY].CHAIN_ID;
const daoId = TARGET_DAO[import.meta.env.VITE_TARGET_KEY].ADDRESS;
```

or load them into a context from the `@daohaus/moloch-v3-hooks` library and then there is a hook you can use.

Wrap your tree in this context:

```tsx
import { CurrentDaoProvider } from "@daohaus/moloch-v3-hooks";

...

<CurrentDaoProvider
targetDao={{
daoChain: TARGET_DAO[import.meta.env.VITE_TARGET_KEY].CHAIN_ID,
daoId: TARGET_DAO[import.meta.env.VITE_TARGET_KEY].ADDRESS,
}}
>
{children}
</CurrentDaoProvider>;
```

Then access this hook:
These values are used in most hooks and components and are loaded into a context from the `@daohaus/moloch-v3-hooks` library and then there is a hook you can use.

```tsx
import { useCurrentDao } from "@daohaus/moloch-v3-hooks";
Expand All @@ -151,8 +183,6 @@ import { useCurrentDao } from "@daohaus/moloch-v3-hooks";
const { daoChain, daoId } = useCurrentDao();
```

- Future: `urlParams` in a multi DAO app

### Adding Custom Fields

tbd
Expand All @@ -161,12 +191,8 @@ tbd

tbd

### Router Example for Multi DAO App

tbd

## Resources

- [DAO Toolbox](https://toolbox.daohaus.fun/) docs
- HausDAO monorepo [libs](https://github.com/HausDAO/monorepo/tree/develop/libs)
- monorepo admin/admin-new
- monorepo apps/admin
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"preview": "vite preview"
},
"dependencies": {
"@daohaus/connect": "^0.1.24",
"@daohaus/contract-utils": "^0.1.24",
"@daohaus/form-builder": "^0.1.24",
"@daohaus/moloch-v3-fields": "^0.0.1",
"@daohaus/moloch-v3-hooks": "^0.0.9",
"@daohaus/moloch-v3-legos": "^0.0.1",
"@daohaus/moloch-v3-macro-ui": "^0.0.9",
"@daohaus/tx-builder": "^0.1.24",
"@daohaus/ui": "^0.1.24",
"@daohaus/utils": "^0.1.24",
"@daohaus/connect": "^0.3.0",
"@daohaus/contract-utils": "^0.3.0",
"@daohaus/form-builder": "^0.3.0",
"@daohaus/moloch-v3-fields": "^0.3.0",
"@daohaus/moloch-v3-hooks": "^0.3.0",
"@daohaus/moloch-v3-legos": "^0.3.0",
"@daohaus/moloch-v3-macro-ui": "^0.3.0",
"@daohaus/tx-builder": "^0.3.0",
"@daohaus/ui": "^0.3.0",
"@daohaus/utils": "^0.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-query": "^3.39.3",
Expand All @@ -29,7 +29,7 @@
"@types/react-dom": "^18.0.7",
"@types/styled-components": "^5.1.26",
"@vitejs/plugin-react": "^2.2.0",
"typescript": "^4.6.4",
"typescript": "^5.0.4",
"vite": "^3.2.0"
}
}
Binary file added src/assets/goat-skull-bauhaus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/HausAnimated.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import styled from 'styled-components';
import hausBlockAnimated from '../assets/hausBlockAnimated.svg';
import hausBlockAnimated from '../assets/goat-skull-bauhaus.png';

const ImageContainer = styled.div`
display: flex;
Expand Down
6 changes: 3 additions & 3 deletions src/components/LayoutContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TARGET_DAO } from "../targetDao";

export const LayoutContainer = () => {
const location = useLocation();
const { provider, address } = useDHConnect();
const { publicClient, address } = useDHConnect();


return (
Expand All @@ -15,10 +15,10 @@ export const LayoutContainer = () => {
navLinks={[
{ label: "Home", href: `/` },
]}
leftNav={<H4>Summon</H4>}
leftNav={<H4>DAOhaus Bare Bones</H4>}
>
<TXBuilder
provider={provider}
publicClient={publicClient}
chainId={TARGET_DAO.CHAIN_ID}
appState={{ memberAddress: address }}
>
Expand Down
26 changes: 24 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,30 @@ export default ({ mode }) => {
NX_GRAPH_API_KEY_MAINNET: process.env.VITE_GRAPH_API_KEY_MAINNET,
NX_INFURA_PROJECT_ID: process.env.VITE_INFURA_PROJECT_ID,
NX_ETHERSCAN_KEY: process.env.VITE_ETHERSCAN_KEY,
NODE_ENV: "16.6.0",
NX_ARBISCAN_KEY: process.env.VITE_ARBISCAN_KEY,
NX_GNOSISSCAN_KEY: process.env.VITE_GNOSISSCAN_KEY,
NX_POLYGONSCAN_KEY: process.env.VITE_POLYGONSCAN_KEY,
NX_OPTIMISMSCAN_KEY: process.env.VITE_OPTIMISMSCAN_KEY,
NX_WALLET_CONNECT_ID: process.env.VITE_WALLET_CONNECT_ID,
NX_OPTIMISM_ALCHEMY_KEY: process.env.VITE_OPTIMISM_ALCHEMY_KEY,
NX_ARBITRUM_ALCHEMY_KEY: process.env.VITE_ARBITRUM_ALCHEMY_KEY,
NX_POLYGONPOS_ALCHEMY_KEY: process.env.VITE_POLYGONPOS_ALCHEMY_KEY,
},
},
optimizeDeps: {
esbuildOptions: {
target: "es2020",
define: {
global: "globalThis",
},
supported: {
bigint: true,
},
},
},

build: {
target: ["es2020"],
},
});
};
};
Loading

0 comments on commit 6dafb9c

Please sign in to comment.