Skip to content

Commit

Permalink
fix(APP-3842): Store correct user address on votes-caching process (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cgero-eth authored Dec 18, 2024
1 parent f11a1d6 commit 84e684c
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {GaslessVotingProposal} from '@vocdoni/gasless-voting';
import {ProposalStatus} from '@aragon/sdk-client-common';
import {useDaoDetailsQuery} from 'hooks/useDaoDetails';
import {useDaoToken} from 'hooks/useDaoToken';
import {TransactionReceipt} from 'viem';

export interface IUseSendVoteOrApprovalTransaction {
/**
Expand Down Expand Up @@ -90,17 +91,21 @@ export const useSendVoteOrApprovalTransaction = (
}
);

const handleVoteOrApprovalSuccess = () => {
const handleVoteOrApprovalSuccess = (txReceipt: TransactionReceipt) => {
// Use address from transaction receipt for caching the vote as user can
// switch address after approving the transaction
const userAddress = txReceipt.from.toLowerCase();

setVoteOrApprovalSubmitted(true);

switch (pluginType) {
case 'token-voting.plugin.dao.eth': {
// cache token-voting vote
if (address != null && votingPower && vote) {
if (votingPower && vote) {
// fetch token user balance, ie vote weight
try {
const voteToPersist = {
address: address.toLowerCase(),
address: userAddress,
vote: vote,
weight: votingPower.toBigInt(),
voteReplaced: !!replacingVote,
Expand All @@ -119,13 +124,11 @@ export const useSendVoteOrApprovalTransaction = (
break;
}
case 'multisig.plugin.dao.eth': {
if (address) {
voteStorage.addVote(
CHAIN_METADATA[network].id,
proposalId,
address.toLowerCase()
);
}
voteStorage.addVote(
CHAIN_METADATA[network].id,
proposalId,
userAddress
);
break;
}
case 'vocdoni-gasless-voting-poc-vanilla-erc20.plugin.dao.eth': {
Expand Down

0 comments on commit 84e684c

Please sign in to comment.