Skip to content

Commit 2dddd3a

Browse files
authored
Merge pull request #93 from HausDAO/feat/ui-updates
update frontent logic + ui
2 parents 9ae9184 + f9d18b4 commit 2dddd3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5481
-1881
lines changed

.env.sample

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ VITE_WALLET_CONNECT_ID=
1313
VITE_ETHERSCAN_KEY=
1414
# The Graph: https://thegraph.com/docs/en/querying/managing-api-keys/
1515
VITE_GRAPH_API_KEY_MAINNET=
16-
# DAO TARGET
16+
# Either TEST or PRODUCTION
1717
VITE_TARGET_KEY=

README.md

+20-15
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ git clone https://github.com/HausDAO/protocol-guild-contracts.git
123123
### Deploy a Home Registry
124124

125125
#### 1. Collect addresses for at least 2 initial members
126-
- [ ] addr 1
127-
- [ ] addr 2
126+
127+
Output
128+
129+
- `Addr_1`
130+
- `Addr_2`
128131

129132

130133
#### 2. Deploy initial DAO
@@ -137,43 +140,45 @@ Output:
137140

138141
#### 3. Setup initial Split contract through the 0xSplits dApp
139142

140-
- Go to this [link](https://app.0xsplits.xyz/) to create new Split with initial members, split amounts can be equal as these will be updated in the first split proposals. You can either set the DAO Safe address or an EOA as the split controller (you must transfer ownership later). You can freely set the distribution threshold and sponsorship fee.
143+
- Go to the [0xSplit dApp](https://app.0xsplits.xyz/) to create new Split with initial members (at least two), split amounts can be equal as these will be updated in the first split proposals. You can either set the DAO Safe address or an EOA as the split controller (you must transfer ownership later). You can freely set the distribution threshold and sponsorship fee.
141144

142145
Output:
143146
- `split` address (`SPLIT_ADDRESS`)
144147

145-
#### 4. Deploy a NetworkRegistry contract in the home network
148+
#### 4. Deploy a NetworkRegistry contract in the Home network
146149

147-
- Before running the deployment script in the `protocol-guild-contract` repository you download locally, go to the `constants/config.ts` directory, find the `home network` you plan to work with and set the `moloch` `safe` & `split` addresses to the contract addresses you deployed in the previous steps.
150+
- Before running the deployment script in the `protocol-guild-contract` repository you download locally, go to the `constants/config.ts` directory, find the chainID of the `home network` you plan to work with and set the `moloch`, `safe` & `split` addresses to the contract addresses you deployed in the previous steps.
148151
- Open a terminal, go to the directory where `protocol-guild-contract` is located and run the following command line (example uses Goerli):
149152

150153
```bash
151154
pnpm hardhat --network goerli deploy --tags PGNetworkRegistry
152155
```
153156

154157
- Confirm the DAO Safe has ownership over the registry contract
155-
- Finally, set the new `registry` address within the `home network` in the `constants/config.ts` file.
158+
- Finally, set the new `pgRegistry` address within the `home network` in the `constants/config.ts` file.
156159

157160
Output:
158161

159162
- `registry` address (`REGISTRY_ADDRESS`)
160163

161164
#### 5. Transfer control of the 0xSplit to NetworkRegistry
162165

163-
- If you set the 0xSplit controller to an EOA, you can both `transferControl` to the `registry` contract through 0xSplits dApp. Alternatively, you can run the following script in the `protocol-guild-contract` repo:
166+
- If you set the 0xSplit controller to an EOA, you can `transferControl` to the `registry` contract through 0xSplits dApp. Alternatively, you can run the following script in the `protocol-guild-contract` repo:
164167

165168
```bash
166169
pnpm hardhat --network goerli registry:ownSplit
167170
```
168171

169-
If you initially set the 0xSplit controller to the DAO's Safe, you'll need to submit a DAO proposal using the DAOHaus `Multicall Proposal Builder`. For this, you need the `splitMain` address to craft a tx to call the `transferControl(<split>, <new_controller>)`
172+
If you initially set the 0xSplit controller to the DAO's Safe, you'll need to submit a DAO proposal using the DAOHaus `Multicall Proposal Builder`. For this, you need the `splitMain` address to craft a tx that calls `transferControl(<split>, <new_controller>)`
170173
- If you set the 0xSplit controller to an external smart contract wallet, try using wallet connect or a vendor tx builder dApp.
171174

172-
- Make sure the `registry` address is set as the new potential controller.
175+
- Make sure the `registry` address is set as the new potential 0xSplit controller.
173176

174177
#### 6. NetworkRegistry accepts control of the 0xSplit
175178

176-
- Now the new controller must accept the role for the 0xSplit contract. If the replica `registry` has an EOA as a fallback owner, you just need to call `acceptSplitControl()`. Otherview, you'll need to submit a DAO proposal using the DAOHaus `Multicall Proposal Builder` to craft a cross-chain tx by calling the `acceptNetworkSplitControl([<chainId>], [<relayerFee>])`.
179+
- Now the new controller must accept the role for the 0xSplit contract, so you need to submit a DAO proposal using the DAOHaus `Multicall Proposal Builder` to craft a tx that calls `acceptSplitControl()` in the `registry` contract.
180+
181+
- Make sure the `registry` address is set as the 0xSplit controller: you verify that in the 0xSplit dApp or by opening the `splitMain` contract in the block explorer and look for the `getController(split)` function.
177182

178183
### Deploy a Foreign Registry
179184

@@ -210,17 +215,17 @@ Output:
210215

211216
#### 3. Transfer + Accept control of the 0xSplit to Replica NetworkRegistry
212217

213-
- You can follow the same instructions in Steps 5 & 6 from above but for the replica network. Remember that you might set your deployer address (EOA) as the 0xSplit controller.
218+
- You can follow the same instructions in Steps 5 & 6 from above but for the replica network. Remember that you might set your deployer address (EOA) as the 0xSplit controller, so you might just need to call `acceptSplitControl()`. Otherwise, you'll to craft a cross-chain tx by calling the `acceptNetworkSplitControl([<chainId>], [<relayerFee>])` through the main `registry` contract.
214219

215-
- You can also use the UI to batch the two actions required to add a new replica in the main registry (`updateNetworkRegistry` + `acceptNetworkSplitControl`). See the next section for instructions.
220+
- However,you can also use the UI to batch the two actions required to add a new replica in the main registry (`updateNetworkRegistry` + `acceptNetworkSplitControl`). See the next section for instructions.
216221

217222
- In the end, make sure the replica `registry` address is set as the new controller.
218223

219-
#### 4. Enable a foreign registry + acept 0xSplit control in the frontend
224+
#### 4. Enable a foreign registry + accept 0xSplit control in the frontend
220225

221-
1. Open the [targetDao.ts](./src/targetDao.ts) config file and add a new record under `REPLICA_CHAIN_ADDRESSES` in the `TARGETS` object.
226+
1. Open the [targetDao.ts](./src/targetDao.ts) config file and add a new record (if not exists) under `REPLICA_CHAINS` in the `TARGETS` object.
222227
2. Make sure the [keychain.ts](./src/utils/keychain.ts) config file supports the network where you deployed the new registry.
223-
2. Navigate to the `Registries` page, open the menu for the new network registry and click on `Register`. This proposal form will batch the two actions required to enable a new replica in the main registry (`updateNetworkRegistry` + `acceptNetworkSplitControl`).
228+
2. In the frontend, navigate to the `Registries` page, open the menu for the new network registry and click on `Register`. This proposal form will batch the two actions required to enable a new replica in the main registry (`updateNetworkRegistry` + `acceptNetworkSplitControl`).
224229

225230

226231
### Notes of deployed Foreign Registries

package.json

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "daohaus-vite-starter",
2+
"name": "protocol-guild-app",
33
"private": true,
44
"version": "0.1.0",
55
"type": "module",
@@ -10,20 +10,28 @@
1010
},
1111
"dependencies": {
1212
"@connext/sdk": "^2.1.1",
13-
"@daohaus/connect": "^0.2.1",
14-
"@daohaus/contract-utils": "^0.2.1",
15-
"@daohaus/form-builder": "^0.2.1",
16-
"@daohaus/keychain-utils": "^0.2.1",
17-
"@daohaus/moloch-v3-fields": "^0.2.1",
18-
"@daohaus/moloch-v3-hooks": "^0.2.1",
19-
"@daohaus/moloch-v3-legos": "^0.2.1",
20-
"@daohaus/moloch-v3-macro-ui": "^0.2.1",
21-
"@daohaus/tx-builder": "^0.2.1",
22-
"@daohaus/ui": "^0.2.1",
23-
"@daohaus/utils": "^0.2.1",
13+
"@daohaus/abis": "^0.3.3",
14+
"@daohaus/connect": "^0.3.3",
15+
"@daohaus/connect-context": "^0.3.3",
16+
"@daohaus/contract-utils": "^0.3.3",
17+
"@daohaus/form-builder": "^0.3.3",
18+
"@daohaus/form-builder-base": "^0.3.3",
19+
"@daohaus/keychain-utils": "^0.3.3",
20+
"@daohaus/moloch-v3-data": "^0.3.3",
21+
"@daohaus/moloch-v3-fields": "^0.3.3",
22+
"@daohaus/moloch-v3-hooks": "^0.3.3",
23+
"@daohaus/moloch-v3-legos": "^0.3.3",
24+
"@daohaus/moloch-v3-macro-ui": "^0.3.3",
25+
"@daohaus/profile-data": "^0.3.3",
26+
"@daohaus/tx-builder": "^0.3.3",
27+
"@daohaus/ui": "^0.3.3",
28+
"@daohaus/utils": "^0.3.3",
2429
"@radix-ui/colors": "^2.1.0",
2530
"@tanstack/react-table": "^8.7.9",
31+
"abitype": "^0.9.9",
2632
"cross-env": "^7.0.3",
33+
"dexie": "^3.2.4",
34+
"dexie-react-hooks": "^1.1.6",
2735
"moment": "^2.29.4",
2836
"react": "^18.2.0",
2937
"react-dom": "^18.2.0",

src/App.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { useState } from 'react';
2+
import { DHConnectProvider } from '@daohaus/connect';
3+
4+
import { Routes } from './Routes';
5+
import { CurrentRegistryProvider } from './hooks/context/RegistryContext';
6+
import { useTargets } from './hooks/useTargets';
7+
8+
export const App = () => {
9+
const [daoChainId, setDaoChainId] = useState<string | undefined>();
10+
const target = useTargets();
11+
return (
12+
<DHConnectProvider daoChainId={daoChainId}>
13+
<CurrentRegistryProvider targetRegistry={target}>
14+
<Routes setDaoChainId={setDaoChainId} />
15+
</CurrentRegistryProvider>
16+
</DHConnectProvider>
17+
);
18+
};

src/Routes.tsx

+41-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
1-
import { Routes as Router, Route } from "react-router-dom";
1+
import { useEffect } from "react";
2+
import {
3+
Routes as Router,
4+
Route,
5+
useLocation,
6+
matchPath,
7+
} from "react-router-dom";
28

3-
import { Home } from "./pages/Home";
4-
import { LayoutContainer } from "./components/LayoutContainer";
5-
6-
import { NewMember } from "./pages/NewMember";
7-
import { EditMember } from "./pages/EditMember";
9+
import { ReactSetter } from "@daohaus/utils";
810

11+
import { LayoutContainer } from "./components/layout/LayoutContainer";
12+
import { useCurrentRegistry } from "./hooks/context/RegistryContext";
13+
import { BulkUpload } from "./pages/BulkUpload";
914
import { ControllerConfig } from "./pages/ControllerConfig";
15+
import { EditMember } from "./pages/EditMember";
16+
import { Home } from "./pages/Home";
17+
import { HistoryLogs } from "./pages/HistoryLogs";
18+
import { NewMember } from "./pages/NewMember";
1019
import { ReplicaConfig } from "./pages/ReplicaConfig";
11-
import { CsvUpload } from "./pages/CsvUpload";
1220
import { Registries } from "./pages/Registries";
21+
import { Settings } from "./pages/Settings";
22+
23+
24+
export const Routes = ({
25+
setDaoChainId,
26+
}: {
27+
setDaoChainId: ReactSetter<string | undefined>;
28+
}) => {
29+
const location = useLocation();
30+
const pathMatch = matchPath("molochv3/:daochain/:daoid/*", location.pathname);
31+
const { daoChain, registryAddress } = useCurrentRegistry();
32+
useEffect(() => {
33+
if (daoChain) {
34+
setDaoChainId(daoChain);
35+
}
36+
if (pathMatch?.params?.daochain) {
37+
setDaoChainId(pathMatch?.params?.daochain);
38+
}
39+
if (!pathMatch?.params?.daochain) {
40+
setDaoChainId(undefined);
41+
}
42+
}, [pathMatch?.params?.daochain, setDaoChainId]);
1343

14-
export const Routes = () => {
1544
return (
1645
<Router>
1746
<Route path="/" element={<LayoutContainer />}>
@@ -20,8 +49,10 @@ export const Routes = () => {
2049
<Route path={`editmember`} element={<EditMember />} />
2150
<Route path={`controller/:chainID`} element={<ControllerConfig />} />
2251
<Route path={`replica/:chainID`} element={<ReplicaConfig />} />
23-
<Route path={`registries/`} element={<Registries />} />
24-
<Route path={`membership/`} element={<CsvUpload />} />
52+
<Route path={`registries/`} element={<Registries />} />
53+
<Route path={`membership/`} element={<BulkUpload />} />
54+
<Route path={`settings/`} element={<Settings />} />
55+
<Route path={`history`} element={<HistoryLogs />} />
2556
</Route>
2657
</Router>
2758
);

0 commit comments

Comments
 (0)