-
Notifications
You must be signed in to change notification settings - Fork 50
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
Adding polling comments & Removing votes from ballot #272
Adding polling comments & Removing votes from ballot #272
Conversation
This pull request has been linked to Shortcut Story #44: Adding comments to Polling. |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/dux-core-unit/governance-portal-v2/H61upSaR3AAVzUxYF63MQ8e6XWRX |
Codecov Report
@@ Coverage Diff @@
## develop #272 +/- ##
===========================================
- Coverage 32.89% 32.52% -0.37%
===========================================
Files 59 61 +2
Lines 1523 1534 +11
Branches 510 510
===========================================
- Hits 501 499 -2
- Misses 1015 1028 +13
Partials 7 7
Continue to review full report at Codecov.
|
…omments API call, include correct address balance , fix executive contract deposit refresh UI
…to feature/sc-44/adding-comments-to-polling
@@ -0,0 +1,48 @@ | |||
import { SupportedNetworks } from 'lib/constants'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored this from the api and moved here
@@ -0,0 +1,47 @@ | |||
import { Delegate } from '../types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored the delegate avatar + name into a component for reusing between comments and delegate cards
@@ -0,0 +1,350 @@ | |||
import { useBreakpointIndex } from '@theme-ui/match-media'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted from the gigantic vote modal + added some logic for signing the message
@@ -0,0 +1,100 @@ | |||
import { useState } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from the previous voteModal file, most of the logic is the same, i removed one useMemo and just rendered normally
const { mutate: mutateComments } = useExecutiveComments(proposal.address); | ||
|
||
const [comment, setComment] = useState(''); | ||
const [signedMessage, setSignedMessage] = useState(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is new
}, []); | ||
|
||
const [hatChecked, setHatChecked] = useState(true); | ||
const { data: currentSlate, mutate: mutateVotedProposals } = useVotedProposals(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brought the currentSlate from the hook instead of nesting it 3 levels from the previous parent props
@@ -115,6 +115,8 @@ const ModalContent = ({ address, voteProxy, close, ...props }) => { | |||
|
|||
const txId = await track(freeTxCreator, 'Withdrawing MKR', { | |||
mined: txId => { | |||
// Mutate locked amount | |||
mutateLocked(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to mutate and refresh the total locked MKR in the contract, was not working before
<Button | ||
onClick={() => { | ||
removeFromBallot(poll.pollId); | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New remove from ballot functionality
@@ -156,6 +165,8 @@ export default function PollOverviewCard({ poll, reviewPage, showVoting, ...prop | |||
)} | |||
</Flex> | |||
</Box> | |||
|
|||
{children && <Box>{children}</Box>} | |||
</Box> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Children used to add the comment form
@@ -0,0 +1,59 @@ | |||
import useBallotStore from '../stores/ballotStore'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These buttons sign and submit the ballot if there are multiple comments
@@ -130,7 +130,7 @@ function isTestnet(): boolean { | |||
return getNetwork() === SupportedNetworks.TESTNET || !!config.TESTNET; | |||
} | |||
|
|||
async function personalSign(message) { | |||
async function personalSign(message: string): Promise<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safety first 👷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Left some minor comments.
I was able to confirm two possible bugs.
-
Updating my poll vote with a new comment doesn't reflect the latest comment. It showed the previous one.
-
The comment is getting saved to the DB before the transaction is mined. I cancelled the tx before it was mined but the comment still got saved.
body: JSON.stringify(commentsRequest) | ||
}) | ||
.then(() => { | ||
console.log('comment successfully added'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this log is necessary for production
…to feature/sc-44/adding-comments-to-polling
…mment per address. Show polling comment option
Link to Shortcut ticket:
https://app.shortcut.com/dux-makerdao/story/44/adding-comments-to-polling
https://app.shortcut.com/dux-makerdao/story/810/allow-removing-poll-votes-from-ballot
What does this PR do?
Adds polling comments.
Steps for testing:
Go to a poll:
Screenshots (if relevant):
Any additional helpful information?:
To connect to the DB locally you will need the environment variables for mongoDb, kindly ask for them
Add a GIF:
![image](https://user-images.githubusercontent.com/1152768/145597696-65365a85-42d0-45ae-89ee-fc3228a0083d.png)