Addresses a bug causing token voting plugins created with pre-existing governance tokens to record inaccurate initial state. Full details of the issue are here, but the code changes in this PR:
Add functionality in getOrCreateMember to conditionally instantiate new TokenVotingMembers with the existing Voting Power, Delegation and ERC20 Balance of the governance token. The conditional incurs the performance hits from eth_call during instantiation, but after the entity is created, we use simple diffs to keep the subgraph performant.
If the user is instantiated for the first time, do not add/subtract the balance as this causes a double counting issue.
If the user belongs to an existing entity, ensure that the usual behaviour occurs (current balance +/- transfer value)
Address a related issue in several places, where the composite key memberId (${pluginAddress}_${userAddress}) would often have the userAddress and pluginAddress swapped. This is not an exhaustive fix and we should check this across the codebase.
Add matchstick tests as needed.
Grab the contract address from the event and use it to fetch the initial balance and delegation status.
I also added a declaration file to provide some missing typings for assemblyScript.
[x] Bug fix (non-breaking change which fixes an issue)
Checklist:
[x] I have selected the correct base branch.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] My changes generate no new warnings.
[x] Any dependent changes have been merged and published in downstream modules.
[x] I ran all tests with success and extended them if necessary.
[x] I have updated the CHANGELOG.md file in the root folder.
[ ] I have updated the DEPLOYMENT_CHECKLIST file in the root folder.
[ ] I have updated the UPDATE_CHECKLIST file in the root folder.
Description
Task ID: OS-1075
Preview Subgraph can be found here
Type of change
Addresses a bug causing token voting plugins created with pre-existing governance tokens to record inaccurate initial state. Full details of the issue are here, but the code changes in this PR:
getOrCreateMember
to conditionally instantiate new TokenVotingMembers with the existing Voting Power, Delegation and ERC20 Balance of the governance token. The conditional incurs the performance hits frometh_call
during instantiation, but after the entity is created, we use simple diffs to keep the subgraph performant.memberId
(${pluginAddress}_${userAddress}
) would often have the userAddress and pluginAddress swapped. This is not an exhaustive fix and we should check this across the codebase.I also added a declaration file to provide some missing typings for assemblyScript.
Checklist:
CHANGELOG.md
file in the root folder.DEPLOYMENT_CHECKLIST
file in the root folder.UPDATE_CHECKLIST
file in the root folder.