This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: resolving additional bugs and some refactors (#78)
**Motivation:** Small codebase changes **Modifications:** Bugs: * Vote weight adding similar to how we do `_newCastCount` in LlamaCore which has an upper bound condition. This will handle cases when someone has quantity greater than `type(uint96).max) - currentCount`. They get to vote too. (This is mostly applicable to ERC20s who can mint huge numbers). Added `test_CanCastWhenCountisMax` tests. * Due to the way solidity works, we had no way to get the mappings inside the `CastData` struct from an external contract. So added a `hasTokenHolderCast` to `TokenHolderCaster` that gets the values for votes and vetoes. Also added tests. * Cast Vote and Cast Veto should check if the ActionCaster has the defined `role` at ActionCreation time. Currently the tokenholders will be able to Vote even if the underlying TokenHolderCaster no longer has the role. It'll only fail at Submission time which can be annoying. Refactors: * Removed the `checkIf(Dis)ApprovalEnabled` check in submit functions since they're checked in the underlying `cast` functions in the Llama Framework. Also removed the tests since there is no reasonable way to test this since the `castVote` and `castVeto` functions does have the `checkIf(Dis)ApprovalEnabled` check and it would have failed there. And we know for a fact that the `cast(Dis)approval` being called in the submit functions have the `checkIf(Dis)ApprovalEnabled` check and we have tests for that in the Llama Framework. * `Note:` We also don't need an Action state check on the submit functions since they're checked in the underlying `cast` functions in the Llama Framework. There is no reasonable way to test this since the `castVote` and `castVeto` functions does have the Action state check and it would have failed there. And we know for a fact that the `cast(Dis)approval` being called in the submit functions have the Action state check and we have tests for that in the Llama Framework. * Removed the `approvalSubmitted` and `disapprovalSubmitted` bool and respective `AlreadySubmittedApproval` and `AlreadySubmittedDisapproval()` checks. This is since the underlying LlamaFramework handles it through `LlamaCore.DuplicateCast()` error in the worst case. But more likely is that it triggers the `LlamaCore.InvalidActionState` since the state has already transitioned. And we know for a fact that the `cast(Dis)approval` being called in the submit functions have the above checks and we have tests for that in the Llama Framework. * Combined `AlreadyCastVote()` and `AlreadyCastVeto()` errors into a single `DuplicateCast()` error that matches the error style in Llama Framework and reduces the number of defined errors. * Combined `ActionNotActive()` and `ActionNotQueued()` errors into a single `InvalidActionState(ActionState current)` error that matches the error style in Llama Framework and reduces the number of defined errors. Moved this into the common `_preCastAssertions` function to match Llama style. * Changed `VotingDelayNotOver()` error to `DelayPeriodNotOver()` error to match the other Period errors. * Changed `CannotSubmitYet()` error to `CastingPeriodNotOver()` error to match the other Period errors. **Result:** Better and bug free code.
- Loading branch information
Showing
3 changed files
with
359 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.