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

Hotfix/v0.2.10 #2246

Merged
merged 27 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fa2ec0d
use `getMultisigTransaction` instead of `getAllTransactions`
Da-Colon Aug 8, 2024
efc8cea
remove transfers logic from transaction parsing
Da-Colon Aug 8, 2024
13ff1a8
typing update and cleanup
Da-Colon Aug 8, 2024
272d42b
remove ActivityTreasury components
Da-Colon Aug 8, 2024
893ad8e
update treasury to use `getIncomingTransaction` and `getToken` to get…
Da-Colon Aug 8, 2024
2760dc6
add override and cache tokenData
Da-Colon Aug 8, 2024
c199191
type return
Da-Colon Aug 8, 2024
1e6dca6
directly format when data is first pulled
Da-Colon Aug 9, 2024
8368953
implements adding and getting token data into state one at a time
Da-Colon Aug 9, 2024
f47857b
comment feedback - various
Da-Colon Aug 9, 2024
bda0c6b
refactor: Remove unused imports and simplify code in TxActions.tsx an…
Da-Colon Aug 9, 2024
9d8d229
remove activity eventType property
Da-Colon Aug 9, 2024
a708649
refactor to create a unique set of tokenData before making request
Da-Colon Aug 9, 2024
2e1a548
fix bad build due to inferred typing
Da-Colon Aug 10, 2024
e7ee544
refactor: Improve handling of transfers in Transactions component
Da-Colon Aug 12, 2024
5d97765
comments feedback
Da-Colon Aug 13, 2024
7a5d8dc
redeploy ~empty commit~
Da-Colon Aug 13, 2024
8b539ff
Try a thing for myself
adamgall Aug 13, 2024
da92b67
Sometimes they're null
adamgall Aug 13, 2024
953d7f9
Better code
adamgall Aug 14, 2024
3078e90
Add commented code for an alternative implementation
adamgall Aug 14, 2024
e8ffed0
Merge pull request #2223 from decentdao/issue/2218-bugfix-transfers
adamgall Aug 14, 2024
0eb5293
Bump version to 0.2.10
adamgall Aug 14, 2024
cd3b9d9
When calculating voting power per proposal, query the strategy contra…
adamgall Aug 14, 2024
212599b
toLocaleString
adamgall Aug 14, 2024
60b2621
use formatCoin
adamgall Aug 14, 2024
856e51e
Merge pull request #2245 from decentdao/fix-wrong-voting-power
adamgall Aug 14, 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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "decent-interface",
"version": "0.2.9",
"version": "0.2.10",
"private": true,
"dependencies": {
"@apollo/client": "^3.7.10",
Expand Down
4 changes: 0 additions & 4 deletions src/components/Activity/ActivityDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useGetMetadata } from '../../hooks/DAO/proposal/useGetMetadata';
import { Activity, FractalProposal, SnapshotProposal } from '../../types';
import Markdown from '../ui/proposal/Markdown';
import { ProposalTitle } from './ActivityDescriptionGovernance';
import { ActivityDescriptionTreasury } from './ActivityDescriptionTreasury';

interface IActivityDescription {
activity: Activity;
Expand Down Expand Up @@ -44,9 +43,6 @@ export function ActivityDescription({
/>
</Box>
)}
<Box mt={2}>
{!!activity.transaction && <ActivityDescriptionTreasury activity={activity} />}
</Box>
</Box>
);
}
5 changes: 0 additions & 5 deletions src/components/Activity/ActivityDescriptionGovernance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Activity,
GovernanceActivity,
MultisigProposal,
ActivityEventType,
SnapshotProposal,
FractalProposal,
AzoriusProposal,
Expand Down Expand Up @@ -85,10 +84,6 @@ export function ProposalTitle({
}) {
const metaData = useGetMetadata(activity as FractalProposal);

if (activity.eventType !== ActivityEventType.Governance) {
return null;
}

// Check if it's a SnapshotProposal and set variables accordingly
const isSnapshotProposal = (activity as SnapshotProposal).snapshotProposalId !== undefined;
const proposalIdText = isSnapshotProposal
Expand Down
57 changes: 0 additions & 57 deletions src/components/Activity/ActivityDescriptionTreasury.tsx

This file was deleted.

57 changes: 0 additions & 57 deletions src/components/Activity/ActivityTreasury.tsx

This file was deleted.

58 changes: 29 additions & 29 deletions src/components/Proposals/MultisigProposalDetails/TxActions.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Box, Button, Text, Flex, Tooltip } from '@chakra-ui/react';
import { TypedDataSigner } from '@ethersproject/abstract-signer';
import { SafeMultisigTransactionWithTransfersResponse } from '@safe-global/api-kit';
import { Signer } from 'ethers';
import { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Hex, getAddress, isHex } from 'viem';
import { getAddress, isHex } from 'viem';
import { Check } from '../../../assets/theme/custom/icons/Check';
import { GnosisSafeL2__factory } from '../../../assets/typechain-types/usul/factories/@gnosis.pm/safe-contracts/contracts';
import { BACKGROUND_SEMI_TRANSPARENT } from '../../../constants/common';
Expand Down Expand Up @@ -51,28 +50,27 @@ export function TxActions({ proposal }: { proposal: MultisigProposal }) {
const [contractCall, contractCallPending] = useTransaction();
const { loadSafeMultisigProposals } = useSafeMultisigProposals();
const baseContracts = useSafeContracts();
if (user.votingWeight === 0n) return <></>;
if (user.votingWeight === 0n) return null;

const multisigTx = proposal.transaction as SafeMultisigTransactionWithTransfersResponse;

if (!multisigTx) return null;
if (!proposal.transaction) return null;

const signTransaction = async () => {
if (
!signerOrProvider ||
!safe?.address ||
(multisigTx.data && !isHex(multisigTx.data)) ||
!proposal.transaction ||
!isHex(proposal.transaction.data) ||
!safeAPI
) {
return;
}
try {
const safeTx = buildSafeTransaction({
...multisigTx,
to: getAddress(multisigTx.to),
value: BigInt(multisigTx.value),
data: multisigTx.data as Hex | undefined,
operation: multisigTx.operation as 0 | 1,
...proposal.transaction,
to: getAddress(proposal.transaction.to),
value: BigInt(proposal.transaction.value),
data: proposal.transaction.data,
operation: proposal.transaction.operation as 0 | 1,
});

asyncRequest({
Expand All @@ -98,22 +96,23 @@ export function TxActions({ proposal }: { proposal: MultisigProposal }) {
const timelockTransaction = async () => {
try {
if (
!multisigTx.confirmations ||
!proposal.transaction ||
!proposal.transaction.confirmations ||
!baseContracts ||
!freezeGuardContractAddress ||
(multisigTx.data && !isHex(multisigTx.data))
!isHex(proposal.transaction.data)
) {
return;
}
const safeTx = buildSafeTransaction({
...multisigTx,
to: getAddress(multisigTx.to),
value: BigInt(multisigTx.value),
data: multisigTx.data as Hex | undefined,
operation: multisigTx.operation as 0 | 1,
...proposal.transaction,
to: getAddress(proposal.transaction.to),
value: BigInt(proposal.transaction.value),
data: proposal.transaction.data,
operation: proposal.transaction.operation as 0 | 1,
});
const signatures = buildSignatureBytes(
multisigTx.confirmations.map(confirmation => {
proposal.transaction.confirmations.map(confirmation => {
if (!isHex(confirmation.signature)) {
throw new Error('Confirmation signature is malfunctioned');
}
Expand Down Expand Up @@ -158,24 +157,25 @@ export function TxActions({ proposal }: { proposal: MultisigProposal }) {
try {
if (
!signerOrProvider ||
!proposal.transaction ||
!safe?.address ||
!multisigTx.confirmations ||
(multisigTx.data && !isHex(multisigTx.data))
!proposal.transaction.confirmations ||
!isHex(proposal.transaction.data)
) {
return;
}
const safeContract = GnosisSafeL2__factory.connect(safe.address, signerOrProvider);

const safeTx = buildSafeTransaction({
...multisigTx,
to: getAddress(multisigTx.to),
value: BigInt(multisigTx.value),
data: multisigTx.data as Hex | undefined,
operation: multisigTx.operation as 0 | 1,
...proposal.transaction,
to: getAddress(proposal.transaction.to),
value: BigInt(proposal.transaction.value),
data: proposal.transaction.data,
operation: proposal.transaction.operation as 0 | 1,
});

const signatures = buildSignatureBytes(
multisigTx.confirmations.map(confirmation => {
proposal.transaction.confirmations.map(confirmation => {
if (!isHex(confirmation.signature)) {
throw new Error('Confirmation signature is malfunctioned');
}
Expand Down Expand Up @@ -257,7 +257,7 @@ export function TxActions({ proposal }: { proposal: MultisigProposal }) {
pageTitle: 'executeTitle',
},
};
const isActiveNonce = !!safe && multisigTx.nonce === safe.nonce;
const isActiveNonce = !!safe && proposal.transaction.nonce === safe.nonce;
const isButtonDisabled =
isSubmitDisabled ||
isPending ||
Expand Down
17 changes: 2 additions & 15 deletions src/components/Proposals/ProposalCard/ProposalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import { Link } from 'react-router-dom';
import { DAO_ROUTES } from '../../../constants/routes';
import { useFractal } from '../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider';
import {
ActivityEventType,
AzoriusProposal,
FractalProposal,
SnapshotProposal,
} from '../../../types';
import { AzoriusProposal, FractalProposal, SnapshotProposal } from '../../../types';
import { DEFAULT_DATE_FORMAT } from '../../../utils';
import { ActivityDescription } from '../../Activity/ActivityDescription';
import { Badge } from '../../ui/badges/Badge';
Expand All @@ -25,14 +20,6 @@ function ProposalCard({ proposal }: { proposal: FractalProposal }) {
const { addressPrefix } = useNetworkConfig();
const { t } = useTranslation('common');

const eventDateLabel = t(
proposal.eventType === ActivityEventType.Treasury
? proposal.transaction?.to === daoAddress
? 'received'
: 'sent'
: 'created',
);

const isSnapshotProposal = !!(proposal as SnapshotProposal).snapshotProposalId;
const isAzoriusProposal = !!(proposal as AzoriusProposal).votesSummary;

Expand Down Expand Up @@ -87,7 +74,7 @@ function ProposalCard({ proposal }: { proposal: FractalProposal }) {
textStyle="helper-text-base"
color="neutral-6"
>
{eventDateLabel} {format(proposal.eventDate, DEFAULT_DATE_FORMAT)}
{t('created')} {format(proposal.eventDate, DEFAULT_DATE_FORMAT)}
</Text>
)}
</Box>
Expand Down
27 changes: 20 additions & 7 deletions src/components/Proposals/ProposalSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import useBlockTimestamp from '../../hooks/utils/useBlockTimestamp';
import { useFractal } from '../../providers/App/AppProvider';
import { AzoriusGovernance, AzoriusProposal, GovernanceType } from '../../types';
import { DEFAULT_DATE_TIME_FORMAT } from '../../utils/numberFormats';
import { DEFAULT_DATE_TIME_FORMAT, formatCoin } from '../../utils/numberFormats';
import ContentBox from '../ui/containers/ContentBox';
import DisplayTransaction from '../ui/links/DisplayTransaction';
import EtherscanLink from '../ui/links/EtherscanLink';
Expand All @@ -32,6 +32,7 @@
} = proposal;
const {
governance,
governanceContracts,
readOnly: {
user: { votingWeight, address },
},
Expand Down Expand Up @@ -61,19 +62,31 @@

useEffect(() => {
async function loadProposalVotingWeight() {
if (address && baseContracts && votesToken) {
const tokenContract = baseContracts.votesTokenMasterCopyContract.asProvider.attach(
votesToken.address,
if (
address &&
baseContracts &&
governanceContracts.ozLinearVotingContractAddress !== undefined
) {
const strategyContract = baseContracts.linearVotingMasterCopyContract.asProvider.attach(
governanceContracts.ozLinearVotingContractAddress,
);
const pastVotingWeight = (await tokenContract.getPastVotes(address, startBlock)).toBigInt();
const pastVotingWeight = (
await strategyContract.getVotingWeight(address, proposal.proposalId)
).toBigInt();

setProposalsERC20VotingWeight(
(pastVotingWeight / votesTokenDecimalsDenominator).toString(),
formatCoin(pastVotingWeight, true, votesToken?.decimals, undefined, false),
);
}
}

loadProposalVotingWeight();
}, [address, startBlock, votesTokenDecimalsDenominator, baseContracts, votesToken]);
}, [

Check warning on line 84 in src/components/Proposals/ProposalSummary.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'votesToken?.decimals'. Either include it or remove the dependency array
address,
baseContracts,
governanceContracts.ozLinearVotingContractAddress,
proposal.proposalId,
]);

const isERC20 = type === GovernanceType.AZORIUS_ERC20;
const isERC721 = type === GovernanceType.AZORIUS_ERC721;
Expand Down
Loading