-
Notifications
You must be signed in to change notification settings - Fork 7
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
[ENG-210]
ERC-721 Whitelisting; Voting section not showing
#2722
Conversation
…ieval and enhance user voting token data handling
… improved token retrieval and code clarity
…n linearVotingErc721Address in useEffect
…rieval and improve token data handling
Deploying decent-interface with
|
Latest commit: |
2c858c9
|
Status: | ✅ Deploy successful! |
Preview URL: | https://4b4fb0c4.decent-interface.pages.dev |
Branch Preview URL: | https://eng-210-erc-721-whitelist-no.decent-interface.pages.dev |
governanceContracts: { | ||
linearVotingErc721Address, | ||
linearVotingErc721WithHatsWhitelistingAddress, | ||
}, |
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.
Main thing was we weren't account for the second type of contract
|
||
const globalContextSafeAddress = safe?.address; | ||
// Means getting these for any safe, primary use case - calculating user voting weight for freeze voting | ||
const getUserVotingTokenData = useCallback( |
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 out some code for readability into own callback
}), | ||
const globalContextSafeAddress = safe?.address; | ||
|
||
const getUserERC721VotingTokens = useCallback( |
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.
main function is a little easier to follow
if (_safeAddress && globalContextSafeAddress !== _safeAddress) { | ||
const userVotingTokenData = await getUserVotingTokenData(_safeAddress); | ||
if (userVotingTokenData) { | ||
governanceTokens = userVotingTokenData.governanceTokens; | ||
votingType = userVotingTokenData.votingType; | ||
linearVotingAddress = userVotingTokenData.linear721VotingAddress; | ||
} | ||
} |
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.
IF being used outside the context of viewing safe these variables are updated.
const tokenDataPromises = Array.from(userERC721Tokens.entries()).flatMap( | ||
([tokenAddress, tokenIdsSet]) => { | ||
return Array.from(tokenIdsSet).map(async tokenId => { | ||
let hasVoted = false; | ||
if (_proposalId !== null) { | ||
hasVoted = await votingContract.read.hasVoted([ | ||
_proposalId, | ||
tokenAddress, | ||
BigInt(tokenId), | ||
]); | ||
} | ||
return { tokenAddress, tokenId, hasVoted }; | ||
}); | ||
}, | ||
); |
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 replaces the nested promises to a flatmap of promises to optimise this section
if (loadOnMount && linearVotingErc721Address) { | ||
if (loadOnMount) { | ||
loadUserERC721VotingTokens(); | ||
} | ||
}, [loadUserERC721VotingTokens, loadOnMount, linearVotingErc721Address]); | ||
}, [loadUserERC721VotingTokens, loadOnMount]); |
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.
Don't believe we need to hold this one back. if there is no contract it will just set defaults
Close ENG-210
Changes
linearVotingErc721WithHatsWhitelistingAddress
contract address is checked for loading erc721 tokens