Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/may2023 custom build updates #304

Merged
merged 11 commits into from
May 22, 2023
2 changes: 2 additions & 0 deletions apps/admin-new/src/layout/DaoContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Outlet, useLocation, useParams } from 'react-router-dom';
import { CurrentDaoProvider, useDaoData } from '@daohaus/moloch-v3-hooks';
import { ValidNetwork } from '@daohaus/keychain-utils';
import { TXBuilder } from '@daohaus/tx-builder';
import { Footer } from '@daohaus/ui';

export const DaoContainer = () => {
const { address, provider } = useDHConnect();
Expand Down Expand Up @@ -48,6 +49,7 @@ export const DaoContainer = () => {
pathname={location.pathname}
navLinks={navLinks}
dropdownLinks={moreLinks}
footer={<Footer />}
>
<CurrentDaoProvider
userAddress={address}
Expand Down
2 changes: 2 additions & 0 deletions apps/admin-new/src/layout/HomeContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DHLayout } from '@daohaus/connect';
import { Footer } from '@daohaus/ui';
import { Outlet, useLocation } from 'react-router-dom';

export const HomeContainer = () => {
Expand All @@ -19,6 +20,7 @@ export const HomeContainer = () => {
// }
pathname={location.pathname}
navLinks={[{ label: 'Hub', href: `/` }]}
footer={<Footer />}
>
<Outlet />
</DHLayout>
Expand Down
4 changes: 2 additions & 2 deletions apps/admin-new/src/pages/FormTest.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FormBuilder } from '@daohaus/form-builder';
import { useCurrentDao } from '@daohaus/moloch-v3-hooks';
import { COMMON_FORMS } from '@daohaus/moloch-v3-legos';
import { PROPOSAL_FORMS } from '@daohaus/moloch-v3-legos';
import { MolochFields } from '@daohaus/moloch-v3-fields';

export const FormTest = () => {
const { daoChain } = useCurrentDao();
return (
<FormBuilder
form={COMMON_FORMS.ADD_SAFE}
form={PROPOSAL_FORMS.SIGNAL}
targetNetwork={daoChain}
customFields={MolochFields}
/>
Expand Down
5 changes: 5 additions & 0 deletions apps/admin-new/src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export const Settings = () => {
daoId={dao.id}
includeLinks={true}
/>
// <GovernanceSettings
// daoChain={daoChain as keyof Keychain}
// dao={dao}
// includeLinks={true}
// />
)}
</SingleColumnLayout>
);
Expand Down
2 changes: 2 additions & 0 deletions apps/admin/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import RageQuit from './pages/RageQuit';
import { DHLayout, useDHConnect } from '@daohaus/connect';
import { HeaderAvatar } from './components/HeaderAvatar';
import { ReactSetter } from '@daohaus/utils';
import { Footer } from '@daohaus/ui';

const Routes = ({
setDaoChainId,
Expand Down Expand Up @@ -83,6 +84,7 @@ const HomeContainer = () => {
}
pathname={location.pathname}
navLinks={[{ label: 'Hub', href: `/` }]}
footer={<Footer />}
>
<Outlet />
</DHLayout>
Expand Down
2 changes: 2 additions & 0 deletions apps/admin/src/pages/Dao.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useConnectedMember, useDao } from '@daohaus/moloch-v3-context';
import { TXBuilder } from '@daohaus/tx-builder';
import { useMemo } from 'react';
import { HeaderAvatar } from '../components/HeaderAvatar';
import { Footer } from '@daohaus/ui';

export function Dao() {
const { daochain, daoid } = useParams();
Expand Down Expand Up @@ -72,6 +73,7 @@ export function Dao() {
},
]}
dropdownLinks={moreLinks}
footer={<Footer />}
>
<Outlet />
</DHLayout>
Expand Down
10 changes: 6 additions & 4 deletions apps/moloch-v3-subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ type Proposal @entity {
currentlyPassing: Boolean!
"highest share+loot count during any individual yes vote"
maxTotalSharesAndLootAtYesVote: BigInt!
"Snapshot of the quorum precent for the DAO when the proposal was executed"
quorumPercentAtExecution: BigInt
"Snapshot of the total shares for the DAO when the proposal was executed"
totalSharesAtExecution: BigInt
"highest share count during any individual yes vote"
maxTotalSharesAtYesVote: BigInt!
"Snapshot of the quorum precent for the DAO when the proposal was sponsored"
quorumPercentAtSponsor: BigInt
"the block number when the proposal was executed"
blockNumberAtExecution: BigInt
"The following tribute fields will only have values if the proposal was submitted through the trbute minion contract. \n token address in tribute proposals."
tributeToken: Bytes
"amount of tribute token offered"
Expand Down
9 changes: 7 additions & 2 deletions apps/moloch-v3-subgraph/src/baal-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export function handleSubmitProposal(event: SubmitProposal): void {
proposal.currentlyPassing = false;
proposal.proposalOffering = event.transaction.value;
proposal.maxTotalSharesAndLootAtYesVote = constants.BIGINT_ZERO;
proposal.maxTotalSharesAtYesVote = constants.BIGINT_ZERO;
proposal.sponsored = event.params.selfSponsor;
proposal.selfSponsor = event.params.selfSponsor;
proposal.sponsorTxHash = event.params.selfSponsor
Expand All @@ -202,6 +203,9 @@ export function handleSubmitProposal(event: SubmitProposal): void {
: null;
proposal.sponsor = event.params.selfSponsor ? event.transaction.from : null;
proposal.sponsorMembership = event.params.selfSponsor ? proposerId : null;
proposal.quorumPercentAtSponsor = event.params.selfSponsor
? dao.totalShares
: null;
proposal.prevProposalId = event.params.selfSponsor
? dao.latestSponsoredProposalId
: constants.BIGINT_ZERO;
Expand Down Expand Up @@ -299,6 +303,7 @@ export function handleSponsorProposal(event: SponsorProposal): void {
proposal.prevProposalId = dao.latestSponsoredProposalId;
proposal.sponsorTxHash = event.transaction.hash;
proposal.sponsorTxAt = event.block.timestamp;
proposal.quorumPercentAtSponsor = dao.totalShares;

dao.latestSponsoredProposalId = event.params.proposal;

Expand Down Expand Up @@ -330,8 +335,7 @@ export function handleProcessProposal(event: ProcessProposal): void {
proposal.processed = true;
proposal.passed = event.params.passed;
proposal.actionFailed = event.params.actionFailed;
proposal.quorumPercentAtExecution = dao.quorumPercent;
proposal.totalSharesAtExecution = dao.totalShares;
proposal.blockNumberAtExecution = event.block.number;

proposal.save();

Expand Down Expand Up @@ -403,6 +407,7 @@ export function handleSubmitVote(event: SubmitVote): void {
proposal.maxTotalSharesAndLootAtYesVote = dao.totalShares.plus(
dao.totalLoot
);
proposal.maxTotalSharesAtYesVote = dao.totalShares;
} else {
proposal.noVotes = proposal.noVotes.plus(constants.BIGINT_ONE);
proposal.noBalance = proposal.noBalance.plus(event.params.balance);
Expand Down
6 changes: 4 additions & 2 deletions libs/connect/src/components/DHLayout/DHLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentProps, ReactNode } from 'react';

import { DaoHausNav, DaoHausNavMenu } from '../DaoHausNav/DaoHausNav';
import { AppSwitcher, Footer, MainLayout, widthQuery } from '@daohaus/ui';
import { AppSwitcher, MainLayout, widthQuery } from '@daohaus/ui';
import { OuterLayout } from '@daohaus/ui';
import styled from 'styled-components';
import { DaoHausNavProps } from '../DaoHausNav/DaoHausNav.types';
Expand Down Expand Up @@ -29,11 +29,13 @@ export const DHLayout = ({
appNavLinks,
leftNav,
pathname,
footer,
}: DaoHausNavProps & {
children: ReactNode;
leftNav?: ReactNode;
appNavLinks?: ComponentProps<typeof AppSwitcher>;
pathname: string;
footer?: ReactNode;
}) => {
return (
<OuterLayout>
Expand All @@ -50,7 +52,7 @@ export const DHLayout = ({
pathname={pathname}
/>
<MainLayout>{children}</MainLayout>
<Footer />
{footer}
</OuterLayout>
);
};
23 changes: 19 additions & 4 deletions libs/form-builder-base/src/components/FormBuilderFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ export const FormBuilderFactory = ({ field }: { field: FieldLego }) => {
formState: { errors },
} = useFormContext();
const formState = errors;
const { formDisabled, requiredFields, fieldObj, fieldSpacing, applyToEach } =
useFormBuilder();
const {
formDisabled,
requiredFields,
fieldObj,
fieldSpacing,
applyToEach,
submitDisabled,
} = useFormBuilder();

const GeneratedField = useMemo(
() => {
Expand All @@ -24,11 +30,12 @@ export const FormBuilderFactory = ({ field }: { field: FieldLego }) => {
field: field,
requiredFields: requiredFields || {},
});

return (
<Field
{...field}
rules={newRules}
disabled={formDisabled || field.disabled}
disabled={formDisabled || field.disabled || submitDisabled}
{...applyToEach}
/>
);
Expand All @@ -37,7 +44,15 @@ export const FormBuilderFactory = ({ field }: { field: FieldLego }) => {
// formState change

// eslint-disable-next-line react-hooks/exhaustive-deps
[type, formDisabled, field, requiredFields, fieldObj, formState]
[
type,
formDisabled,
field,
requiredFields,
fieldObj,
formState,
submitDisabled,
]
);

return <Spacer fieldSpacing={fieldSpacing}>{GeneratedField}</Spacer>;
Expand Down
1 change: 1 addition & 0 deletions libs/form-builder/src/FormBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const FormBuilder = ({
error,
fallback: 'Could not decode error message',
});

setIsLoading(false);
lifeCycleFns?.onTxError?.(error);
errorToast({ title: StatusMsg.TxErr, description: errMsg });
Expand Down
5 changes: 4 additions & 1 deletion libs/moloch-v3-fields/src/fields/ProposalOffering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export const ProposalOffering = (props: Buildable<{ id?: string }>) => {
useEffect(() => {
if (!dao || !id) return;

if (!connectedMember || Number(dao.sponsorThreshold) > Number(connectedMember.shares)) {
if (
!connectedMember ||
Number(dao.sponsorThreshold) > Number(connectedMember.shares)
) {
setRequiresOffering(true);
setValue(id, dao.proposalOffering);
return;
Expand Down
1 change: 0 additions & 1 deletion libs/moloch-v3-fields/src/fields/RequestERC20.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export const RequestERC20 = (
<WrappedInputSelect
{...props}
id={amtId}
label="Request ERC-20"
defaultValue="0"
selectId={addressId}
selectPlaceholder="--"
Expand Down
4 changes: 2 additions & 2 deletions libs/moloch-v3-fields/src/fields/TributeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const TributeInput = (
<FieldSpacer>
<WrappedInput
full
label="Token Address"
label="Tribute Token Address"
id={addressId}
helperText={fetchState}
success={tokenName}
Expand All @@ -212,7 +212,7 @@ export const TributeInput = (
<FieldSpacer>
<WrappedInput
full
label="Token Amount"
label="Tribute Token Amount"
id={amtId}
disabled={needsApproval}
rules={tokenAmtRules}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
import { Keychain, ValidNetwork } from '@daohaus/keychain-utils';
import { MolochV3Dao } from '@daohaus/moloch-v3-data';

import { MetaCardHeader, MetaContent } from './DaoSettings.styles';
import {
MetaCardHeader,
MetaContent,
SettingsContainer,
} from './DaoSettings.styles';

type ContractSettingsProps = {
dao: MolochV3Dao;
Expand All @@ -19,7 +23,7 @@ export const ContractSettings = ({ dao, daoChain }: ContractSettingsProps) => {
const isMobile = useBreakpoint(widthQuery.sm);

return (
<>
<SettingsContainer>
<MetaCardHeader>
<H3>Contracts</H3>
</MetaCardHeader>
Expand Down Expand Up @@ -61,6 +65,6 @@ export const ContractSettings = ({ dao, daoChain }: ContractSettingsProps) => {
/>
</div>
</MetaContent>
</>
</SettingsContainer>
);
};
54 changes: 26 additions & 28 deletions libs/moloch-v3-macro-ui/src/components/DaoSettings/DaoSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ContractSettings } from './ContractSettings';
import { GovernanceSettings } from './GovernanceSettings';
import { ShamanSettings } from './ShamanSettings';

import { SettingsContainer } from './DaoSettings.styles';
import { TokenSettings } from './TokenSettings';

type DaoSettingsProps = {
daoChain: ValidNetwork;
Expand All @@ -31,33 +31,31 @@ export const DaoSettings = ({

return (
<>
<SettingsContainer>
<MetadataSettings
dao={dao}
daoChain={daoChain}
includeLinks={includeLinks}
/>
</SettingsContainer>

<SettingsContainer>
<ContractSettings dao={dao} daoChain={daoChain} />
</SettingsContainer>

<SettingsContainer>
<GovernanceSettings
dao={dao}
daoChain={daoChain}
includeLinks={includeLinks}
/>
</SettingsContainer>

<SettingsContainer>
<ShamanSettings
dao={dao}
daoChain={daoChain}
includeLinks={includeLinks}
/>
</SettingsContainer>
<MetadataSettings
dao={dao}
daoChain={daoChain}
includeLinks={includeLinks}
/>

<ContractSettings dao={dao} daoChain={daoChain} />

<GovernanceSettings
dao={dao}
daoChain={daoChain}
includeLinks={includeLinks}
/>

<TokenSettings
dao={dao}
daoChain={daoChain}
includeLinks={includeLinks}
/>

<ShamanSettings
dao={dao}
daoChain={daoChain}
includeLinks={includeLinks}
/>
</>
);
};
Loading