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

F/gasless non wrapped tokens bis #1

Open
wants to merge 66 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
e9aef10
Fixes bug during DAO creation, not allowing
emmdim Nov 24, 2023
25d9852
Minor renaming
emmdim Nov 27, 2023
5ccc3ac
Upgrades vocdoni dependencies
emmdim Nov 27, 2023
07dcbc0
Fixes bug caused in Gasless Proposal creation
emmdim Nov 28, 2023
29c5a6b
enable gasless plugin on staging and development
Fabricevladimir Nov 29, 2023
042aab4
Updates vocdoni dependencies to the latest
emmdim Nov 29, 2023
a046c65
Removes buggy line in endDate calculation of
emmdim Nov 30, 2023
9df6db5
Fix approval button label
selankon Dec 1, 2023
f68b7c9
Fix duplicated approvals
selankon Dec 1, 2023
48c8732
Fix address comparasion bug
selankon Dec 1, 2023
3547baf
Fix gasless memberCount
selankon Dec 1, 2023
1182b92
Lint fixes
selankon Dec 1, 2023
d479d47
Fix missing import
selankon Dec 1, 2023
a479263
Bumps gasless-voting and adds yarn.lock
emmdim Dec 1, 2023
9233e7e
Fix gasless voting terminal status message
selankon Dec 5, 2023
e02e334
Implement approval step
selankon Dec 5, 2023
dc0317b
Revert "Implement approval step"
selankon Dec 11, 2023
319ba81
Fixes account creation bug during gasless proposal
emmdim Dec 12, 2023
1348d21
Updates dependencies
emmdim Dec 12, 2023
a6f8135
Temporarily sets resolutions for sdk-client-common
emmdim Dec 12, 2023
6dff837
Updates census3 tags to ['aragon','dao']
emmdim Dec 13, 2023
c202270
Hide settings parameters
selankon Dec 13, 2023
8a5012b
Fix voting terminal info for approvals
selankon Dec 13, 2023
d804219
Disable vote now if cannot vote
selankon Dec 14, 2023
3cfada3
Disable unnecessary call
selankon Dec 14, 2023
2f3d276
Fix approval button
selankon Dec 14, 2023
3753a8a
* Fixes proposal status regarding approval
emmdim Dec 14, 2023
07f0152
Bumps gasless voting sdk to fix types issues
emmdim Dec 14, 2023
09f5d6d
Temporarily fixes liniting issues coming from develop
emmdim Dec 14, 2023
3aba9f5
Bumps gasless voting sdk to fix issue with
emmdim Dec 14, 2023
7402f97
Fix proposal dates
selankon Dec 18, 2023
b959805
Fix expiration time can be set to 0
selankon Dec 22, 2023
6195501
Print better election finished error
selankon Dec 22, 2023
318e3c8
Fixes linitng issues
emmdim Dec 22, 2023
9d2396f
Implement propose settings (#1148)
selankon Dec 22, 2023
ea95e05
Fixes linting issue
emmdim Dec 22, 2023
0e96a72
Set vocdoni election interruptible to false
selankon Jan 8, 2024
84448e3
Create census3 token
selankon Jan 8, 2024
2589453
Add missing dep
selankon Jan 8, 2024
9687e3b
Fix census3 token creation
selankon Jan 9, 2024
432db49
Improve cannot retrieve faucet tokens
selankon Jan 10, 2024
29cbd3c
Fix `isGaslessProposal` function
selankon Jan 10, 2024
da73aba
Split ExecutionCommitteeMinimumApproval component
selankon Jan 11, 2024
da16f2a
Minor bug fixes
selankon Jan 11, 2024
012f2db
Lintfix
selankon Jan 11, 2024
289619a
Bump sdk versions
selankon Jan 12, 2024
12599c4
Use vocdoni SDK errors
selankon Jan 12, 2024
33f6813
Implement gasless voting approve and execute (#1193)
selankon Jan 17, 2024
a1993cf
Improve useGaslessCommiteVotes
selankon Jan 17, 2024
c2ea5ee
Use endDate when DEFEATED before gasless election
selankon Jan 17, 2024
2b204da
Simplify useGaslessCommiteVotes
selankon Jan 18, 2024
2246eaa
Bump vocdoni gasless voting
selankon Jan 19, 2024
0c7318c
Show supported token if gasless and erc20
selankon Jan 26, 2024
f56fa6d
Implement hasGovernanceEnabled
selankon Jan 30, 2024
1707248
Update GaslessPluginName
selankon Jan 30, 2024
1e0f86b
Fix getDelegatee
selankon Jan 31, 2024
0db9c4a
Implement useGaslessGovernanceEnabled
selankon Jan 31, 2024
9933093
Use approve instead of setTally
selankon Jan 31, 2024
8b40e6b
Lintfix
selankon Jan 31, 2024
b80f1f1
Bump "@vocdoni/gasless-voting": "^0.0.1-rc20"
selankon Jan 31, 2024
7a5b374
Fix query params undefined
selankon Feb 1, 2024
ce998d9
Add use-creator-proposal gasless version
emmdim Feb 1, 2024
dad748d
Lint fixes :-(
emmdim Feb 1, 2024
26c79c3
Reduce creation proposal time
emmdim Feb 1, 2024
2ea9ecc
Hide delegation column if not governance
selankon Feb 2, 2024
f05f1ab
Test ai reviewer
emmdim Feb 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ VITE_FEATURE_FLAG_OSX_UPDATES=true
VITE_FEATURE_FLAG_CONNECT_ANY_DAPP=true

# Enable gasless plugin on DAO creation
VITE_FEATURE_FLAG_GASLESS_PLUGIN=false
VITE_FEATURE_FLAG_GASLESS_PLUGIN=true

VITE_VOCDONI_ENV='stg'

Expand Down
2 changes: 1 addition & 1 deletion .env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ VITE_FEATURE_FLAG_OSX_UPDATES=true
VITE_FEATURE_FLAG_CONNECT_ANY_DAPP=true

# Enable gasless plugin on DAO creation
VITE_FEATURE_FLAG_GASLESS_PLUGIN=false
VITE_FEATURE_FLAG_GASLESS_PLUGIN=true

VITE_VOCDONI_ENV='stg'

Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/ai-pr-reviewer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Code Review

permissions:
contents: read
pull-requests: write

on:
pull_request:
pull_request_review_comment:
types: [created]

concurrency:
group:
${{ github.repository }}-${{ github.event.number || github.head_ref ||
github.sha }}-${{ github.workflow }}-${{ github.event_name ==
'pull_request_review_comment' && 'pr_comment' || 'pr' }}
cancel-in-progress: ${{ github.event_name != 'pull_request_review_comment' }}

jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: coderabbitai/ai-pr-reviewer@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
debug: false
review_simple_changes: true
review_comment_lgtm: true
openai_heavy_model: gpt-4
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@
"@tiptap/pm": "^2.0.3",
"@tiptap/react": "^2.0.3",
"@tiptap/starter-kit": "^2.0.3",
"@vocdoni/gasless-voting": "0.0.1-rc2",
"@vocdoni/gasless-voting-ethers": "0.0.1-rc1",
"@vocdoni/react-providers": "0.1.14",
"@vocdoni/sdk": "0.5.0",
"@vocdoni/gasless-voting": "0.0.1-rc21",
"@vocdoni/react-providers": "0.3.1",
"@vocdoni/sdk": "0.7.1",
"@walletconnect/core": "^2.8.3",
"@walletconnect/utils": "^2.8.3",
"@walletconnect/web3wallet": "^1.8.2",
Expand Down Expand Up @@ -117,7 +116,6 @@
"vite-tsconfig-paths": "^4.2.0"
},
"resolutions": {
"@vocdoni/sdk": "0.5.0",
"@types/react": "^18.2.23"
},
"engines": {
Expand Down
6 changes: 5 additions & 1 deletion src/components/executionExpirationTime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ const ExecutionExpirationTime: React.FC = () => {
);
setValue('executionExpirationHours', '0');
setValue('executionExpirationMinutes', '0');
} else if (value === 0 && executionExpirationHours === '0') {
} else if (
value === 0 &&
(executionExpirationHours === undefined ||
executionExpirationHours === '0')
) {
setValue(
'executionExpirationHours',
COMMITTEE_EXECUTION_MIN_DURATION_HOURS.toString()
Expand Down
87 changes: 87 additions & 0 deletions src/components/executionMultisigMinimumApproval/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import {
Controller,
useFormContext,
useWatch,
ValidateResult,
} from 'react-hook-form';
import MinimumApproval from '../multisigMinimumApproval/minimumApproval';
import React, {useCallback, useEffect} from 'react';
import {generateAlert} from '../multisigMinimumApproval';
import {useTranslation} from 'react-i18next';

const MIN_REQUIRED_APPROVALS = 1;

export const ExecutionMultisigMinimumApproval = () => {
const {t} = useTranslation();
const {control, setValue, trigger} = useFormContext();
const [committee, committeeMinimumApproval] = useWatch({
name: ['committee', 'committeeMinimumApproval'],
});

const committeeCount = committee?.length ?? 0;

const validateMinimumApproval = (value: number): ValidateResult => {
if (value > committeeCount) {
return t('errors.minimumApproval.exceedMaxThreshold');
} else if (value <= 0) {
return t('errors.required.minApproval');
}
return true;
};

const minApprovalChanged = useCallback(
(
e: React.ChangeEvent<HTMLInputElement>,
onChange: React.ChangeEventHandler
) => {
const value = Number(e.target.value);
if (value > committeeCount) {
setValue('committeeMinimumApproval', committeeCount.toString());
e.target.value = committeeCount;
}
trigger(['committeeMinimumApproval']);
onChange(e);
},
[committeeCount, setValue, trigger]
);

// This is used to update the committeeMinimumApproval when a wallet is deleted
useEffect(() => {
if (Number(committeeMinimumApproval) === 0 && committeeCount === 1) {
setValue('committeeMinimumApproval', committeeCount.toString());
} else if (Number(committeeMinimumApproval) > committeeCount) {
setValue('committeeMinimumApproval', committeeCount.toString());
}
}, [committeeCount, committeeMinimumApproval, setValue]);

return (
<>
<Controller
name="committeeMinimumApproval"
control={control}
defaultValue="1"
rules={{
validate: value => validateMinimumApproval(value),
}}
render={({
field: {onBlur, onChange, value, name},
fieldState: {error},
}) => (
<>
<MinimumApproval
name={name}
value={value}
min={MIN_REQUIRED_APPROVALS}
max={committeeCount}
onBlur={onBlur}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
minApprovalChanged(e, onChange)
}
error={generateAlert(value, committee.length, t, error)}
/>
</>
)}
/>
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React, {useMemo} from 'react';
import {useTranslation} from 'react-i18next';

import {AccordionMethod} from 'components/accordionMethod';
import {ActionCardDlContainer, Dd, Dl, Dt} from 'components/descriptionList';
import {ActionUpdateGaslessSettings} from 'utils/types';
import {getDHMFromSeconds} from '../../../utils/date';
import {getErc20MinParticipation} from '../../../utils/proposals';
import {formatUnits} from 'ethers/lib/utils';

export const ModifyGaslessSettingsCard: React.FC<{
action: ActionUpdateGaslessSettings;
}> = ({action: {inputs}}) => {
const {t} = useTranslation();
const {days, hours, minutes} = getDHMFromSeconds(inputs.minDuration);
const {
days: tallyDays,
hours: tallyHours,
minutes: tallyMinutes,
} = getDHMFromSeconds(inputs.minTallyDuration);

const minParticipation = useMemo(
() => `≥ ${Math.round(inputs.minParticipation * 100)}% (≥
${getErc20MinParticipation(
inputs.minParticipation,
inputs.totalVotingWeight,
inputs.token?.decimals || 18
)}
${inputs.token?.symbol})`,
[
inputs.minParticipation,
inputs.token?.decimals,
inputs.token?.symbol,
inputs.totalVotingWeight,
]
);

const minProposalThreshold = inputs.minProposerVotingPower
? t('labels.review.tokenHoldersWithTkns', {
tokenAmount: formatUnits(
inputs.minProposerVotingPower,
inputs.token?.decimals
),
tokenSymbol: inputs.token?.symbol,
})
: t('createDAO.step3.eligibility.anyWallet.title');

return (
<AccordionMethod
type="execution-widget"
methodName={t('labels.updateExecutionMultisigAction')}
smartContractName={t('labels.aragonOSx')}
methodDescription={t('labels.updateExecutionMultisigActionDescription')}
verified
>
<ActionCardDlContainer>
<Dl>
<Dt>{t('labels.minimumParticipation')}</Dt>
<Dd>{minParticipation}</Dd>
</Dl>
<Dl>
<Dt>{t('labels.review.proposalThreshold')}</Dt>
<Dd>{minProposalThreshold}</Dd>
</Dl>
<Dl>
<Dt>{t('labels.minimumDuration')}</Dt>
<Dd>
<div className="space-x-3">
<span>{t('createDAO.review.days', {days})}</span>
<span>{t('createDAO.review.hours', {hours})}</span>
<span>{t('createDAO.review.minutes', {minutes})}</span>
</div>
</Dd>
</Dl>
<Dl>
<Dt>{t('labels.minimumApproval')}</Dt>
<Dd>
{inputs.minTallyApprovals}&nbsp;
{t('labels.review.multisigMinimumApprovals', {
count: inputs.executionMultisigMembers?.length || 0,
})}
</Dd>
</Dl>
<Dl>
<Dt>{t('createDao.executionMultisig.executionTitle')}</Dt>
<Dd>
<div className="space-x-3">
<span>{t('createDAO.review.days', {days: tallyDays})}</span>
<span>{t('createDAO.review.hours', {hours: tallyHours})}</span>
<span>
{t('createDAO.review.minutes', {minutes: tallyMinutes})}
</span>
</div>
</Dd>
</Dl>
</ActionCardDlContainer>
</AccordionMethod>
);
};
3 changes: 3 additions & 0 deletions src/components/executionWidget/actionsFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {SCCExecutionCard} from './actions/sccExecutionWidget';
import {WCActionCard} from './actions/walletConnectActionCard';
import {WithdrawCard} from './actions/withdrawCard';
import {toDisplayEns} from 'utils/library';
import {ModifyGaslessSettingsCard} from './actions/modifyGaslessSettingsCard';

type ActionsFilterProps = {
action: Action;
Expand Down Expand Up @@ -52,6 +53,8 @@ export const ActionsFilter: React.FC<ActionsFilterProps> = ({
return (
<WCActionCard action={action} type="execution-widget" status={status} />
);
case 'modify_gasless_voting_settings':
return <ModifyGaslessSettingsCard action={action} />;
case 'plugin_update':
default:
return <></>;
Expand Down
9 changes: 8 additions & 1 deletion src/components/membersList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import styled from 'styled-components';
import {useScreen} from '@aragon/ods-old';
import {useTranslation} from 'react-i18next';
import {featureFlags} from 'utils/featureFlags';
import {useGaslessGovernanceEnabled} from '../../hooks/useGaslessGovernanceEnabled';
import {useDaoDetailsQuery} from '../../hooks/useDaoDetails';

type MembersListProps = {
members: DaoMember[];
Expand All @@ -32,6 +34,11 @@ export const MembersList: React.FC<MembersListProps> = ({
const {isDesktop} = useScreen();
const {t} = useTranslation();

// Gasless voting plugin support non wrapped tokens
// Used to hide delegation column in case of gasless voting plugin
const {data: daoDetails} = useDaoDetailsQuery();
const {isGovernanceEnabled} = useGaslessGovernanceEnabled(daoDetails);

const isTokenBasedDao = token != null;
const useCompactMode = isCompactMode ?? !isDesktop;
const enableDelegation =
Expand Down Expand Up @@ -94,7 +101,7 @@ export const MembersList: React.FC<MembersListProps> = ({
{t('community.listHeader.votingPower')}
</TableCellHead>
)}
{showDelegationHeaders && (
{showDelegationHeaders && isGovernanceEnabled && (
<TableCellHead>
{t('community.listHeader.delegations')}
</TableCellHead>
Expand Down
6 changes: 3 additions & 3 deletions src/components/proposalList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ export function proposal2CardProps(
alertMessage: translateProposalDate(
proposal.status,
proposal.startDate,
proposal.endDate
proposal.tallyEndDate
),
title: proposal.vochain.metadata.title.default,
description: proposal.vochain.metadata.questions[0].title.default,
title: proposal.metadata.title,
description: proposal.metadata.description,
};
return {...props, ...specificProps};
} else if (isErc20VotingProposal(proposal)) {
Expand Down
17 changes: 16 additions & 1 deletion src/components/verificationCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ const VerificationCard: React.FC<TransferListProps> = ({tokenAddress}) => {
tokenTotalSupply,
tokenTotalHolders,
tokenType,
votingType,
] = useWatch({
name: [
'tokenName',
'tokenSymbol',
'tokenTotalSupply',
'tokenTotalHolders',
'tokenType',
'votingType',
],
control: control,
});
Expand All @@ -52,6 +54,19 @@ const VerificationCard: React.FC<TransferListProps> = ({tokenAddress}) => {
const Alert = useMemo(() => {
switch (tokenType) {
case 'ERC-20':
if (votingType === 'gasless') {
return (
<AlertCard
mode="success"
title={t(
'createDAO.step3.existingToken.verificationAlertSuccessTitle'
)}
helpText={
'DEV The ERC20 token selected is compatible for voting on the Vocdoni system'
}
/>
);
}
return (
<AlertCard
mode="warning"
Expand Down Expand Up @@ -107,7 +122,7 @@ const VerificationCard: React.FC<TransferListProps> = ({tokenAddress}) => {
default:
return null;
}
}, [t, tokenSymbol, tokenType]);
}, [t, tokenSymbol, tokenType, votingType]);

const formattedTokenTotalSupply = useMemo(() => {
if (tokenTotalSupply < 100) {
Expand Down
Loading
Loading