Skip to content

Commit

Permalink
Quickfix approvals cache
Browse files Browse the repository at this point in the history
  • Loading branch information
selankon committed Oct 26, 2023
1 parent af7534d commit 030e2bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/context/proposalTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from '@aragon/sdk-client';
import {useQueryClient} from '@tanstack/react-query';
import React, {
ReactNode,
createContext,
ReactNode,
useCallback,
useContext,
useMemo,
Expand Down Expand Up @@ -341,11 +341,13 @@ const ProposalTransactionProvider: React.FC<Props> = ({children}) => {
}

if (voteToPersist) {
voteStorage.addVote(
CHAIN_METADATA[network].id,
proposalId.toString(),
voteToPersist
);
// todo(kon): quickfix to use the proposal id on the same format when we are retrieving the proposal from the
// minsdk. We should use the proposal id on the same format everywhere after refactor
const propId =
pluginType === GaselessPluginName
? '0x' + proposalId.stripPlgnAdrFromProposalId().proposal.toString()
: proposalId.toString();
voteStorage.addVote(CHAIN_METADATA[network].id, propId, voteToPersist);
}

invalidateProposalQueries();
Expand Down Expand Up @@ -392,6 +394,9 @@ const ProposalTransactionProvider: React.FC<Props> = ({children}) => {

// handles vote submission/execution
const handleVoteExecution = useCallback(async () => {
console.log('UUUUUUUUU');
onVoteSubmitted(new ProposalId(urlId!), VoteValues.YES, false);
return;
if (voteProcessState === TransactionState.SUCCESS) {
handleCloseVoteModal();
return;
Expand Down Expand Up @@ -490,6 +495,7 @@ const ProposalTransactionProvider: React.FC<Props> = ({children}) => {

// handles proposal execution
const handleProposalExecution = useCallback(async () => {
console.log('AAAAAAAA');
if (executeProcessState === TransactionState.SUCCESS) {
handleCloseExecuteModal();
return;
Expand Down
4 changes: 2 additions & 2 deletions src/services/aragon-sdk/selectors/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ function syncApprovalsOrVotes(
): void {
if (isMultisigProposal(proposal)) {
proposal.approvals = syncMultisigVotes(chainId, proposal);
} else if (isTokenBasedProposal(proposal)) {
proposal.votes = syncTokenBasedVotes(chainId, proposal);
} else if (isGaslessProposal(proposal)) {
// todo(kon): gasless vote array is not yet implemented
const {gaslessVotes, approvers} = syncGaslessVotesOrApproves(
chainId,
proposal
);
proposal.approvers = approvers;
} else if (isTokenBasedProposal(proposal)) {
proposal.votes = syncTokenBasedVotes(chainId, proposal);
}
}

Expand Down

0 comments on commit 030e2bc

Please sign in to comment.