Skip to content

Commit

Permalink
temp fix: resync with contracts (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaCehic95 authored Feb 21, 2023
1 parent 83d60fd commit 6e12f5d
Show file tree
Hide file tree
Showing 38 changed files with 327 additions and 756 deletions.
14 changes: 0 additions & 14 deletions apps/enterprise/src/dao/hooks/useAmICouncilMember.tsx

This file was deleted.

35 changes: 22 additions & 13 deletions apps/enterprise/src/dao/shared/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@ import { capitalizeFirstLetter } from 'lib/shared/utils/capitalizeFirstLetter';
import { DAO } from 'types';
import { enterprise } from 'types/contracts';

export const proposalVotingTypes = ['regular', 'council'] as const;
export const proposalVotingTypes = ['regular'] as const;

export type ProposalVotingType = typeof proposalVotingTypes[number];


// TODO: Remove this when contracts version is updated after audit
export type ProposalActionType =
| 'update_metadata'
| 'update_gov_config'
| 'update_asset_whitelist'
| 'update_nft_whitelist'
| 'request_funding_from_dao'
| 'upgrade_dao'
| 'execute_msgs'
| 'modify_multisig_membership';


export interface Proposal {
dao: DAO;
id: number;
Expand Down Expand Up @@ -36,7 +49,6 @@ export const sharedProposalTypes = [
'delegate',
'undelegate',
'redelegate',
'council',
] as const;

export const daoProposalsRecord = {
Expand Down Expand Up @@ -66,13 +78,11 @@ export const proposalTitle: Record<ProposalType, string> = {
delegate: 'Delegate LUNA proposal',
undelegate: 'Undelegate LUNA proposal',
redelegate: 'Redelegate LUNA proposal',
council: 'Update council',
};

export const proposalActionShortName: Record<enterprise.ProposalActionType, string> = {
export const proposalActionShortName: Record<ProposalActionType, string> = {
update_metadata: 'metadata',
update_gov_config: 'gov',
update_council: 'council',
update_asset_whitelist: 'assets',
update_nft_whitelist: 'nfts',
request_funding_from_dao: 'funding',
Expand All @@ -81,14 +91,13 @@ export const proposalActionShortName: Record<enterprise.ProposalActionType, stri
modify_multisig_membership: 'members',
};

export const getProposalActionType = (action: enterprise.ProposalAction): enterprise.ProposalActionType => {
return Object.keys(action)[0] as enterprise.ProposalActionType;
export const getProposalActionType = (action: enterprise.ProposalAction): ProposalActionType => {
return Object.keys(action)[0] as ProposalActionType;
};

export type ProposalActionMsg =
| enterprise.UpdateMetadataMsg
| enterprise.UpdateGovConfigMsg
| enterprise.UpdateCouncilMsg
| enterprise.UpdateAssetWhitelistMsg
| enterprise.UpdateNftWhitelistMsg
| enterprise.RequestFundingFromDaoMsg
Expand All @@ -97,7 +106,7 @@ export type ProposalActionMsg =
| enterprise.ModifyMultisigMembershipMsg;

export interface ProposalAction {
type: enterprise.ProposalActionType;
type: ProposalActionType;
msg: ProposalActionMsg;
}

Expand Down Expand Up @@ -148,8 +157,8 @@ export const getProposalStatusName = (proposal: Proposal, blockHeight: number):
return proposal.status === 'in_progress'
? 'Active'
: proposal.status === 'passed'
? 'Passed'
: proposal.status === 'rejected'
? 'Rejected'
: 'Executed';
? 'Passed'
: proposal.status === 'rejected'
? 'Rejected'
: 'Executed';
};
2 changes: 0 additions & 2 deletions apps/enterprise/src/pages/create-dao/DaoWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { TokenInfoStep } from './token/TokenInfoStep';
import { TokenMarketingStep } from './token/TokenMarketingStep';
import { WizardButtons, WizardButtonsProps } from './WizardButtons';
import { WizardLayout } from './WizardLayout';
import { CouncilStep } from './shared/CouncilStep';
import { useRefCallback } from '@terra-money/apps/hooks';
import { CompletedTransaction, useTransactionSubscribers } from '@terra-money/apps/libs/transactions';
import { reportError } from 'errors/errorMonitoring';
Expand Down Expand Up @@ -86,7 +85,6 @@ export const DaoWizard = () => {
info={() => <InfoStep />}
members={() => <MembersStep />}
govConfig={() => <GovConfigStep />}
council={() => <CouncilStep />}
socials={() => <SocialsStep />}
confirm={() => <ConfirmationStep pending={txResult.loading} />}
membership={() => <NftMembershipStep />}
Expand Down
32 changes: 1 addition & 31 deletions apps/enterprise/src/pages/create-dao/DaoWizardFormProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createContextHook } from '@terra-money/apps/utils/createContextHook';
import { useConnectedWallet, useWallet } from '@terra-money/wallet-provider';
import { CW20TokenInfoResponse, MultisigVoter, CW721ContractInfoResponse } from 'queries';
import { createContext, ReactNode, useCallback } from 'react';
import { enterprise, enterprise_factory } from 'types/contracts';
import { enterprise } from 'types/contracts';
import { MultisigMember } from 'types/MultisigMember';
import { fetchExistingToken } from './fetchExistingToken';
import { fetchExistingNFT } from './fetchExistingNFT';
Expand All @@ -20,7 +20,6 @@ import { validateTokenInfo } from './token/helpers/validateTokenInfo';
import { validateTokenMarketing } from './token/helpers/validateTokenMarketing';
import { fetchExistingMultisigVoters } from './fetchExistingMultisigVoters';
import { useEnv } from 'hooks';
import { validateCouncil } from './shared/helpers/validateCouncil';

export interface DaoSocialDataInput {
githubUsername?: string;
Expand All @@ -35,19 +34,11 @@ export interface DaoInfoInput {
logo?: string;
}

export interface CouncilMember {
address: string;
}

export interface DaoImportInput {
shouldImport: boolean;
daoAddress?: string;
}

export interface CouncilInput {
members: FormState<CouncilMember>[];
allowedProposalTypes: enterprise_factory.ProposalActionType[];
}

export interface DaoWizardInput {
type: enterprise.DaoType;
Expand All @@ -66,8 +57,6 @@ export interface DaoWizardInput {
initialDaoBalance: number | undefined;
tokenMarketing: FormState<TokenMarketing>;

council?: FormState<CouncilInput>;

existingTokenAddr: string;
existingToken: CW20TokenInfoResponse | undefined;
existingTokenLoading: boolean;
Expand Down Expand Up @@ -112,7 +101,6 @@ export type DaoWizardStep =
| 'type'
| 'daoImport'
| 'info'
| 'council'
| 'socials'
| 'govConfig'
| 'confirm'
Expand All @@ -136,7 +124,6 @@ export interface DaoWizardState extends DaoWizardInput {
const sharedInitialSteps: DaoWizardStep[] = ['type', 'info', 'daoImport'];
const sharedLastSteps: DaoWizardStep[] = [
'govConfig',
// 'council',
'socials',
'confirm',
];
Expand Down Expand Up @@ -190,11 +177,6 @@ const getInitialState = (timeConversionFactor: number, walletAddr: string | unde
daoAddress: undefined,
},

council: {
members: [],
allowedProposalTypes: ['upgrade_dao'],
},

members: walletAddr ? [{ ...EMPTY_MEMBER, addr: walletAddr }, EMPTY_MEMBER] : [EMPTY_MEMBER],

nftMembership: {
Expand Down Expand Up @@ -300,18 +282,6 @@ const validateCurrentStep = (state: DaoWizardState): Partial<DaoWizardState> =>
};
},

council: () => {
// TODO: remove TEMP changes
if (!state.council) return {};

const council = validateCouncil(state.council);

return {
council,
isValid: council.members.every(isFormStateValid) && isFormStateValid(council),
};
},

membership: () => {
const nftMembership = validateNftMembership(state.nftMembership);
return {
Expand Down
13 changes: 2 additions & 11 deletions apps/enterprise/src/pages/create-dao/helpers/toCreateDaoMsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { microfy } from '@terra-money/apps/libs/formatting';
import { DaoWizardInput, DaoWizardState } from '../DaoWizardFormProvider';
import { enterprise_factory } from 'types/contracts';
import { assertDefined } from '@terra-money/apps/utils';

// TODO: Revert this when audit si done
const getDaoMembership = (input: DaoWizardInput) => {
const {
type,
Expand Down Expand Up @@ -99,26 +99,17 @@ const getDaoGovConfig = ({ govConfig, type, timeConversionFactor }: DaoWizardSta

export const toCreateDaoMsg = (input: DaoWizardState): CreateDaoMsgType => {
const {
info: { name, logo, description },
info: { name, logo },
socials,
council,
} = input;

return {
create_dao: {
dao_council:
council && council.members.length > 0
? {
members: council.members.map((member) => member.address),
allowed_proposal_action_types: council.allowedProposalTypes,
}
: null,
asset_whitelist: null,
dao_membership: getDaoMembership(input),
dao_metadata: {
logo: logo ? { url: logo } : 'none',
name,
description,
socials: {
github_username: socials.githubUsername,
twitter_username: socials.twitterUsername,
Expand Down
50 changes: 0 additions & 50 deletions apps/enterprise/src/pages/create-dao/shared/CouncilStep.tsx

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { TextProposalForm } from './text/TextProposalForm';
import { UpgradeProposalForm } from './upgrade/UpgradeProposalForm';
import { ExecuteMessageProposalForm } from './execute/ExecuteMessageProposalForm';
import { MintTokensProposalForm } from './mint/MintTokensProposalForm';
import { CouncilForm } from './council/CouncilForm';
// import { CouncilForm } from './council/CouncilForm';
import { useSearchParams } from 'react-router-dom';
import { AnimatedPage } from '@terra-money/apps/components';
import styled from 'styled-components';
Expand Down Expand Up @@ -75,7 +75,7 @@ export const CreateProposalPage = () => {
<ConditionalRender
value={assertDefined(type)}
metadata={() => <MetadataProposalForm />}
council={() => <CouncilForm />}
// council={() => <CouncilForm />}
text={() => <TextProposalForm />}
config={() => <CreateConfigProposalPage />}
upgrade={() => <UpgradeProposalForm />}
Expand Down
Loading

0 comments on commit 6e12f5d

Please sign in to comment.