-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
792 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
VITE_RIVET_KEY= | ||
VITE_EXPLORER_KEY= | ||
VITE_GRAPH_API_KEY_MAINNET= | ||
VITE_TARGET_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ dist-ssr | |
*.sw? | ||
|
||
.env | ||
dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# DAOhaus: V3 Vite Starter | ||
|
||
## Development | ||
|
||
### 1. project setup | ||
|
||
```bash | ||
git clone [email protected]:HausDAO/moloch-v3-vite-starter.git | ||
|
||
cd moloch-v3-vite-starter | ||
|
||
yarn | ||
``` | ||
|
||
### 2. env setup | ||
|
||
```bash | ||
cp .env.sample .env | ||
``` | ||
|
||
```md | ||
VITE_RIVET_KEY | ||
|
||
get a free rivet key [here](https://rivet.cloud/) | ||
|
||
VITE_EXPLORER_KEY | ||
|
||
get etherscan explorer api key [here](https://etherscan.io/apis) | ||
|
||
VITE_GRAPH_API_KEY_MAINNET | ||
|
||
if deeveloping 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. | ||
|
||
VITE_TARGET_KEY | ||
|
||
This will be the target address for your DAO you are developing the app for. | ||
``` | ||
|
||
### 3. target dao set up | ||
|
||
[Summon a DAO here](https://summon.daohaus.club) | ||
|
||
Edit src/targetDao.ts | ||
|
||
- add your DAO's data | ||
- Put the dao address in the .env variable mentioned above VITE_TARGET_KEY | ||
- You can add multiple DAOs as new object in targetDao.ts and toggle with this env variable | ||
- You can add otehr variables to targetDao.ts as needed | ||
|
||
### 4. run the development server | ||
|
||
```bash | ||
yarn dev | ||
``` | ||
|
||
## Reference | ||
|
||
### editing the theme | ||
|
||
tbd | ||
|
||
### router example for multi-dao app | ||
|
||
tbd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
import { DHLayout } from '@daohaus/connect'; | ||
import { Routes as Router, Route, useLocation } from 'react-router-dom'; | ||
import { FormTest } from './pages/FormTest'; | ||
import { Home } from './pages/Home'; | ||
import { Routes as Router, Route, useLocation } from "react-router-dom"; | ||
import { FormTest } from "./pages/FormTest"; | ||
import { Home } from "./pages/Home"; | ||
import HomeContainer from "./components/HomeContainer"; | ||
|
||
export const Routes = () => { | ||
const { pathname } = useLocation(); | ||
return ( | ||
<DHLayout | ||
pathname={pathname} | ||
navLinks={[ | ||
{ label: 'Home', href: '/' }, | ||
{ label: 'Form Test', href: '/formtest' }, | ||
]} | ||
> | ||
<Router> | ||
<Route path="/" element={<Home />} /> | ||
<Route path="/formtest" element={<FormTest />} /> | ||
</Router> | ||
</DHLayout> | ||
<Router> | ||
<Route path="/" element={<HomeContainer />}> | ||
<Route index element={<Home />} /> | ||
{/* <Route path="proposals/" element={<Proposals />} /> */} | ||
{/* <Route path="members/" element={<Members />} /> */} | ||
<Route path="form-test/" element={<FormTest />} /> | ||
</Route> | ||
</Router> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { DHLayout, useDHConnect } from "@daohaus/connect"; | ||
import { HAUS_RPC } from "@daohaus/keychain-utils"; | ||
import { TXBuilder } from "@daohaus/tx-builder"; | ||
import { H4 } from "@daohaus/ui"; | ||
import { Outlet, useLocation } from "react-router-dom"; | ||
import { TARGET_DAO } from "../targetDao"; | ||
import { useDaoData } from "@daohaus/moloch-v3-hooks"; | ||
|
||
export function HomeContainer() { | ||
const location = useLocation(); | ||
const { provider, address } = useDHConnect(); | ||
const { dao } = useDaoData({ | ||
daoId: TARGET_DAO[import.meta.env.VITE_TARGET_KEY].ADDRESS, | ||
daoChain: TARGET_DAO[import.meta.env.VITE_TARGET_KEY].CHAIN_ID, | ||
}); | ||
|
||
return ( | ||
<DHLayout | ||
pathname={location.pathname} | ||
navLinks={[{ label: "Home", href: `/` }]} | ||
leftNav={<H4>{dao?.name}</H4>} | ||
> | ||
<TXBuilder | ||
provider={provider} | ||
chainId={TARGET_DAO[import.meta.env.VITE_TARGET_KEY].CHAIN_ID} | ||
daoId={TARGET_DAO[import.meta.env.VITE_TARGET_KEY].ADDRESS} | ||
safeId={TARGET_DAO[import.meta.env.VITE_TARGET_KEY].SAFE_ADDRESS} | ||
appState={{ dao, memberAddress: address }} | ||
rpcs={{ | ||
"0x1": `https://${ | ||
import.meta.env.VITE_RIVET_KEY | ||
}.eth.rpc.rivet.cloud/`, | ||
"0x5": `https://${ | ||
import.meta.env.VITE_RIVET_KEY | ||
}.goerli.rpc.rivet.cloud/`, | ||
"0x64": HAUS_RPC["0x64"], | ||
}} | ||
explorerKeys={{ | ||
"0x1": import.meta.env.VITE_EXPLORER_KEY, | ||
"0x5": import.meta.env.VITE_EXPLORER_KEY, | ||
}} | ||
graphApiKeys={{ | ||
"0x1": import.meta.env.VITE_GRAPH_API_KEY_MAINNET, | ||
}} | ||
> | ||
<Outlet /> | ||
</TXBuilder> | ||
</DHLayout> | ||
); | ||
} | ||
|
||
export default HomeContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
import { DHConnectProvider } from '@daohaus/connect'; | ||
import { HausThemeProvider } from '@daohaus/ui'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import { HashRouter } from 'react-router-dom'; | ||
import { Routes } from './Routes'; | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import { HashRouter } from "react-router-dom"; | ||
import { QueryClient, QueryClientProvider } from "react-query"; | ||
import { DHConnectProvider } from "@daohaus/connect"; | ||
import { HausThemeProvider } from "@daohaus/ui"; | ||
|
||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( | ||
import { Routes } from "./Routes"; | ||
import { TARGET_DAO } from "./targetDao"; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( | ||
<React.StrictMode> | ||
<HashRouter> | ||
<HausThemeProvider> | ||
<DHConnectProvider> | ||
<Routes /> | ||
<QueryClientProvider client={queryClient}> | ||
<DHConnectProvider | ||
daoChainId={TARGET_DAO[import.meta.env.VITE_TARGET_KEY].CHAIN_ID} | ||
> | ||
<HausThemeProvider> | ||
<Routes /> | ||
</HausThemeProvider> | ||
</DHConnectProvider> | ||
</HausThemeProvider> | ||
</QueryClientProvider> | ||
</HashRouter> | ||
</React.StrictMode> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ValidNetwork } from "@daohaus/keychain-utils"; | ||
|
||
export const TARGET_DAO: { | ||
[key: string]: { | ||
ADDRESS: string; | ||
SAFE_ADDRESS: string; | ||
CHAIN_ID: ValidNetwork; | ||
}; | ||
} = { | ||
"0x3dea7058a19bf6854bb63384707139636efb99ea": { | ||
ADDRESS: "0x3dea7058a19bf6854bb63384707139636efb99ea", | ||
SAFE_ADDRESS: "0x47f327bdde3c92d82872d686bb6d7a994c22b4a5", | ||
CHAIN_ID: "0x5", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import { defineConfig } from 'vite'; | ||
import react from '@vitejs/plugin-react'; | ||
|
||
import { defineConfig, loadEnv } from "vite"; | ||
import react from "@vitejs/plugin-react"; | ||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
define: { | ||
'process.env': {}, | ||
}, | ||
}); | ||
export default ({ mode }) => { | ||
Object.assign(process.env, loadEnv(mode, process.cwd())); | ||
|
||
return defineConfig({ | ||
plugins: [react()], | ||
define: { | ||
"process.env": { | ||
NX_RIVET_KEY: process.env.VITE_RIVET_KEY, | ||
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", | ||
}, | ||
}, | ||
}); | ||
}; |
Oops, something went wrong.