Skip to content

Commit

Permalink
cleanup debug and fix check voter address
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiacodes committed Oct 31, 2024
1 parent 947a905 commit f62b858
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
3 changes: 1 addition & 2 deletions server/helpers/adapters/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ export const getVoteBySender = async (
address: string,
proposalId: string
) => {
console.log('getVoteBySender', [space, address, proposalId]);
const query = `SELECT * FROM messages WHERE space = $1 AND address = $2 AND payload ->> 'proposalId' = $3 AND type = 'vote'`;
const result = await db.query(query, [space, address, proposalId]);
console.log('getVoteBySender result', result.rows.length);
console.log('check if voted result:', result.rows.length);
return result.rows;
};

Expand Down
10 changes: 2 additions & 8 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,21 +467,15 @@ router.post('/message', async (req, res) => {

if (isNotInVotingWindow) return sendError(res, 'not in voting window');

console.log('checking if already voted CURRENT', [
console.log('checking if already voted:', [
space,
body.address,
msg.payload.proposalId
]);

console.log('checking if already voted NEW', [
space,
msg.payload.metadata.memberAddress,
msg.payload.proposalId
]);

const votes = await getVoteBySender(
space,
body.address,
msg.payload.metadata.memberAddress,
msg.payload.proposalId
);
if (votes && votes.length > 0) return sendError(res, 'already voted');
Expand Down

0 comments on commit f62b858

Please sign in to comment.