Skip to content

Commit

Permalink
basic crude starter app
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanlesich committed Nov 2, 2022
0 parents commit 8dfc127
Show file tree
Hide file tree
Showing 21 changed files with 8,437 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DAOhaus React Vite Starter</title>
</head>
<body>
<div id="root"></div>
<script>
window.global = window;
</script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "daohaus-vite-starter",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@daohaus/ui": "0.0.25",
"@daohaus/moloch-v3-data": "0.0.2",
"@daohaus/moloch-v3-context": "0.0.1",
"@daohaus/connect": "0.0.4",
"@daohaus/tx-builder": "0.0.2",
"@daohaus/form-builder": "0.0.2"

},
"devDependencies": {
"@types/react": "^18.0.22",
"@types/react-dom": "^18.0.7",
"@vitejs/plugin-react": "^2.2.0",
"typescript": "^4.6.4",
"vite": "^3.2.0"
}
}
1 change: 1 addition & 0 deletions public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}
7 changes: 7 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useState } from 'react';

function App() {
return <div>shit</div>;
}

export default App;
30 changes: 30 additions & 0 deletions src/Routes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Link } from '@daohaus/ui';
import {
Routes as RoutesDom,
Route,
Outlet,
useLocation,
useParams,
useNavigate,
matchPath,
} from 'react-router-dom';
import { DaoContainer } from './components/DaoContainer';
import { DaoScopedPage } from './pages/DaoScopedPage';

export const Routes = () => {
return (
<RoutesDom>
<Route
path="/"
element={
<Link href="molochv3/0x5/0x643e8e197de8760a23c64cf78bef7047084d5408">
DAO
</Link>
}
/>
<Route path="molochv3/:daochain/:daoid" element={<DaoContainer />}>
<Route index element={<DaoScopedPage />} />
</Route>
</RoutesDom>
);
};
Empty file added src/assets/.gitkeep
Empty file.
51 changes: 51 additions & 0 deletions src/assets/contract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { LOCAL_ABI } from '@daohaus/abis';
import { ContractLego, CONTRACTS } from '@daohaus/utils';

export const CONTRACT: Record<string, ContractLego> = {
POSTER: {
type: 'static',
contractName: 'Poster',
abi: LOCAL_ABI.POSTER,
targetAddress: {
'0x1': '0x000000000000cd17345801aa8147b8d3950260ff',
'0x5': '0x000000000000cd17345801aa8147b8d3950260ff',
'0x64': '0x000000000000cd17345801aa8147b8d3950260ff',
},
},
ERC_20: {
type: 'static',
contractName: 'ERC20',
abi: LOCAL_ABI.ERC20,
targetAddress: '.tokenAddress',
},
ERC_20_FUNDING: {
type: 'static',
contractName: 'ERC20',
abi: LOCAL_ABI.ERC20,
targetAddress: '.formValues.paymentTokenAddress',
},
CURRENT_DAO: {
type: 'static',
contractName: 'Current DAO (Baal)',
abi: LOCAL_ABI.BAAL,
targetAddress: '.daoId',
},
TRIBUTE_MINION: {
type: 'static',
contractName: 'Tribute Minion',
abi: LOCAL_ABI.TRIBUTE_MINION,
targetAddress: CONTRACTS.TRIBUTE_MINION,
},
SHARES_ERC20: {
type: 'static',
contractName: 'SHARES_ERC20',
abi: LOCAL_ABI.SHARES,
targetAddress: '.dao.sharesAddress',
},
LOOT_ERC20: {
type: 'static',
contractName: 'LOOT_ERC20',
abi: LOCAL_ABI.LOOT,
targetAddress: '.dao.sharesAddress',
},
};
23 changes: 23 additions & 0 deletions src/assets/fields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { FieldLego } from '@daohaus/form-builder';

export const FIELD: Record<string, FieldLego> = {
TITLE: {
id: 'title',
type: 'input',
label: 'Proposal Title',
placeholder: 'Enter title',
},
DESCRIPTION: {
id: 'description',
type: 'textarea',
label: 'Description',
placeholder: 'Enter description',
},
LINK: {
id: 'link',
type: 'input',
label: 'Link',
placeholder: 'http://',
expectType: 'url',
},
};
21 changes: 21 additions & 0 deletions src/assets/forms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { FormLego } from '@daohaus/form-builder';
import { FIELD } from './fields';
import { TX } from './tx';

export const FORM: Record<string, FormLego> = {
SIGNAL: {
id: 'SIGNAL',
title: 'Signal Form',
subtitle: 'Signal Proposal',
description: 'Ratify on-chain using a DAO proposal.',
requiredFields: { title: true, description: true },
log: true,
tx: TX.POST_SIGNAL,
fields: [
FIELD.TITLE,
FIELD.DESCRIPTION,
FIELD.LINK,
// ...PROPOSAL_SETTINGS_FIELDS,
],
},
};
51 changes: 51 additions & 0 deletions src/assets/tx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { POSTER_TAGS } from '@daohaus/utils';
import { buildMultiCallTX } from '@daohaus/tx-builder';
import { CONTRACT } from './contract';

export enum ProposalTypeIds {
Signal = 'SIGNAL',
IssueSharesLoot = 'ISSUE',
AddShaman = 'ADD_SHAMAN',
TransferErc20 = 'TRANSFER_ERC20',
TransferNetworkToken = 'TRANSFER_NETWORK_TOKEN',
UpdateGovSettings = 'UPDATE_GOV_SETTINGS',
UpdateTokenSettings = 'TOKEN_SETTINGS',
TokensForShares = 'TOKENS_FOR_SHARES',
GuildKick = 'GUILDKICK',
WalletConnect = 'WALLETCONNECT',
}

export const TX = {
POST_SIGNAL: buildMultiCallTX({
id: 'POST_SIGNAL',
JSONDetails: {
type: 'JSONDetails',
jsonSchema: {
title: `.formValues.title`,
description: `.formValues.description`,
contentURI: `.formValues.link`,
contentURIType: { type: 'static', value: 'url' },
proposalType: { type: 'static', value: ProposalTypeIds.Signal },
},
},
actions: [
{
contract: CONTRACT.POSTER,
method: 'post',
args: [
{
type: 'JSONDetails',
jsonSchema: {
title: `.formValues.title`,
description: `.formValues.description`,
contentURI: `.formValues.link`,
contentURIType: { type: 'static', value: 'url' },
proposalType: { type: 'static', value: ProposalTypeIds.Signal },
},
},
{ type: 'static', value: POSTER_TAGS.signalProposal },
],
},
],
}),
};
63 changes: 63 additions & 0 deletions src/components/DaoContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
Routes as RoutesDom,
Route,
Outlet,
useLocation,
useParams,
useNavigate,
matchPath,
} from 'react-router-dom';

import {
HausConnectProvider,
HausLayout,
useHausConnect,
} from '@daohaus/connect';
import { useEffect, useLayoutEffect, useState } from 'react';
import { TXBuilder } from '@daohaus/tx-builder';
import { DaoContextProvider, useDao } from '@daohaus/moloch-v3-context';

export const DaoContainer = () => {
const { daochain, daoid } = useParams();
const { address } = useHausConnect();

return (
<DaoContextProvider
address={address}
daoid={daoid}
daochain={daochain}
graphApiKeys={{ '0x1': import.meta.env['VITE_GRAPH_API_KEY_MAINNET'] }}
>
<Dao />
</DaoContextProvider>
);
};

export const Dao = () => {
const location = useLocation();
const { provider } = useHausConnect();
const { dao } = useDao();
const { daochain, daoid } = useParams();

console.log('dao', dao);

return (
<TXBuilder
chainId={daochain}
provider={provider}
safeId={dao?.safeAddress}
daoId={daoid}
appState={{ dao }}
>
<HausLayout
pathname={location.pathname}
navLinks={[
{ label: 'Home', href: `/` },
{ label: 'DAO-Scoped', href: `/${daochain}/${daoid}` },
]}
>
<Outlet />
</HausLayout>
</TXBuilder>
);
};
Loading

0 comments on commit 8dfc127

Please sign in to comment.