Skip to content

Commit

Permalink
remove env and current dao
Browse files Browse the repository at this point in the history
  • Loading branch information
dekanbro committed May 6, 2023
1 parent f1ff168 commit 867d58d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 64 deletions.
8 changes: 0 additions & 8 deletions src/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import { Routes as Router, Route } from "react-router-dom";
import { FormTest } from "./pages/FormTest";
import { Home } from "./pages/Home";
import { LayoutContainer } from "./components/LayoutContainer";
import Dao from "./pages/Dao";
import { TARGET_DAO } from "./targetDao";

const routePath = `molochv3/${
TARGET_DAO[import.meta.env.VITE_TARGET_KEY].CHAIN_ID
}/${TARGET_DAO[import.meta.env.VITE_TARGET_KEY].ADDRESS}`;

export const Routes = () => {
return (
<Router>
<Route path="/" element={<LayoutContainer />}>
<Route index element={<Home />} />
<Route path={`${routePath}/formtest`} element={<FormTest />} />
<Route path={`${routePath}/dao`} element={<Dao />} />
</Route>
</Router>
);
Expand Down
37 changes: 5 additions & 32 deletions src/components/LayoutContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,28 @@ import { TXBuilder } from "@daohaus/tx-builder";
import { H4 } from "@daohaus/ui";
import { Outlet, useLocation, useParams } from "react-router-dom";
import { TARGET_DAO } from "../targetDao";
import { CurrentDaoProvider, useDaoData } from "@daohaus/moloch-v3-hooks";

const routePath = `molochv3/${
TARGET_DAO[import.meta.env.VITE_TARGET_KEY].CHAIN_ID
}/${TARGET_DAO[import.meta.env.VITE_TARGET_KEY].ADDRESS}`;

export const LayoutContainer = () => {
const location = useLocation();
const { proposalId, memberAddress } = useParams<{
proposalId: string;
memberAddress: string;
}>();
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: `/` },
{ label: "DAO Overview", href: `${routePath}/dao` },
{ label: "Safes", href: `${routePath}/safes` },
{ label: "Proposals", href: `${routePath}/proposals` },
{ label: "Members", href: `${routePath}/members` },
{ label: "Settings", href: `${routePath}/settings` },
]}
leftNav={<H4>{dao?.name}</H4>}
leftNav={<H4>Summon</H4>}
>
<CurrentDaoProvider
targetDao={{
daoChain: TARGET_DAO[import.meta.env.VITE_TARGET_KEY].CHAIN_ID,
daoId: TARGET_DAO[import.meta.env.VITE_TARGET_KEY].ADDRESS,
proposalId,
memberAddress,
}}
>
<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 }}
chainId={TARGET_DAO.CHAIN_ID}
appState={{ memberAddress: address }}
>
<Outlet />
</TXBuilder>
</CurrentDaoProvider>

</DHLayout>
);
};
12 changes: 2 additions & 10 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
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";
import { Buffer } from "buffer";

import { Routes } from "./Routes";
import { TARGET_DAO } from "./targetDao";

// This solves an issue when using WalletConnect and intercept Txs to create dao proposals
// Related open issue: https://github.com/WalletConnect/walletconnect-monorepo/issues/748
window.Buffer = window.Buffer || Buffer;

const queryClient = new QueryClient();

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<HashRouter>
<QueryClientProvider client={queryClient}>
<DHConnectProvider
daoChainId={TARGET_DAO[import.meta.env.VITE_TARGET_KEY].CHAIN_ID}
>

<HausThemeProvider>
<Routes />
</HausThemeProvider>
</DHConnectProvider>
</QueryClientProvider>

</HashRouter>
</React.StrictMode>
);
20 changes: 6 additions & 14 deletions src/targetDao.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import { ValidNetwork } from "@daohaus/keychain-utils";

export const TARGET_DAO: {
[key: string]: {
ADDRESS: string;
SAFE_ADDRESS: string;


CHAIN_ID: ValidNetwork;
};

} = {
"0xf6538c07324f59b3ba685d86393c65dce9676c70": {
ADDRESS: "0xf6538c07324f59b3ba685d86393c65dce9676c70",
SAFE_ADDRESS: "0xb64b12c4e68310fc222580dea1c86d202310f343",
CHAIN_ID: "0x5",
},
"0xf844b98df9ccdfbe5d460d0d7bdca232cf9da923": {
ADDRESS: "0xf844b98df9ccdfbe5d460d0d7bdca232cf9da923",
SAFE_ADDRESS: "0xeb0dc703b854791914f30b5a73dd04d8d22a9aff",
CHAIN_ID: "0x1",
},

CHAIN_ID: "0xa4b1",

};

0 comments on commit 867d58d

Please sign in to comment.