Skip to content

Commit

Permalink
Medium 6 additional change
Browse files Browse the repository at this point in the history
  • Loading branch information
merisman committed Oct 31, 2024
1 parent 2edc351 commit ae78cb4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/MetaVesTController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract metavestController is SafeTransferLib {
bool isPending;
bytes32 dataHash;
address[] voters;
mapping(address => bool) changeApplied;
mapping(address => uint256) appliedProposalCreatedAt;
mapping(address => uint256) voterPower;
}

Expand Down Expand Up @@ -143,7 +143,7 @@ contract metavestController is SafeTransferLib {
if (isMetavestInSet(_grant)) {
bytes32 set = getSetOfMetavest(_grant);
MajorityAmendmentProposal storage proposal = functionToSetMajorityProposal[msg.sig][set];
if(proposal.changeApplied[_grant]) revert MetaVesTController_AmendmentCanOnlyBeAppliedOnce();
if(proposal.appliedProposalCreatedAt[_grant] == proposal.time) revert MetaVesTController_AmendmentCanOnlyBeAppliedOnce();
if (_data.length>32 && _data.length<69)
{
if (!proposal.isPending || proposal.totalVotingPower>proposal.currentVotingPower*2 || keccak256(_data[_data.length - 32:]) != proposal.dataHash ) {
Expand Down Expand Up @@ -606,7 +606,6 @@ contract metavestController is SafeTransferLib {
uint256 _votingPower = BaseAllocation(sets[nameHash].at(i)).getMajorityVotingPower();
totalVotingPower += _votingPower;
proposal.voterPower[sets[nameHash].at(i)] = _votingPower;
proposal.changeApplied[sets[nameHash].at(i)] = false;
}
proposal.totalVotingPower = totalVotingPower;

Expand Down Expand Up @@ -659,7 +658,7 @@ contract metavestController is SafeTransferLib {
{
bytes32 set = getSetOfMetavest(_grant);
MajorityAmendmentProposal storage proposal = functionToSetMajorityProposal[_msgSig][set];
proposal.changeApplied[_grant] = true;
proposal.appliedProposalCreatedAt[_grant] = proposal.time;
setMajorityVoteActive[set] = false;
}
delete functionToGranteeToAmendmentPending[_msgSig][_grant];
Expand Down
40 changes: 40 additions & 0 deletions test/amendement.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,46 @@ contract MetaVestControllerTest is Test {
controller.updateMetavestTransferability(mockAllocation3, true);
}

function testProposeMajorityMetavestAmendmentReAdd() public {
address mockAllocation2 = createDummyVestingAllocation();
address mockAllocation3 = createDummyVestingAllocation();
bytes4 msgSig = bytes4(keccak256("updateMetavestTransferability(address,bool)"));
bytes memory callData = abi.encodeWithSelector(msgSig, mockAllocation2, true);

vm.prank(authority);
controller.addMetaVestToSet("testSet", mockAllocation2);
controller.addMetaVestToSet("testSet", mockAllocation3);
vm.warp(block.timestamp + 1 days);
vm.prank(authority);
controller.proposeMajorityMetavestAmendment("testSet", msgSig, callData);

vm.prank(grantee);
controller.voteOnMetavestAmendment(mockAllocation2, "testSet", msgSig, true);

vm.prank(authority);
controller.updateMetavestTransferability(mockAllocation3, true);

vm.prank(authority);
controller.removeMetaVestFromSet("testSet", mockAllocation3);
// vm.prank(authority);
// controller.updateMetavestTransferability(mockAllocation3, true);
vm.warp(block.timestamp + 90 days);
vm.prank(authority);
controller.proposeMajorityMetavestAmendment("testSet", msgSig, callData);

vm.prank(grantee);
controller.voteOnMetavestAmendment(mockAllocation2, "testSet", msgSig, true);

vm.prank(authority);
controller.updateMetavestTransferability(mockAllocation2, true);

vm.prank(authority);
controller.addMetaVestToSet("testSet", mockAllocation3);

vm.prank(authority);
controller.updateMetavestTransferability(mockAllocation3, true);
}

function testFailNoPassProposeMajorityMetavestAmendment() public {
address mockAllocation2 = createDummyVestingAllocation();
address mockAllocation3 = createDummyVestingAllocation();
Expand Down

0 comments on commit ae78cb4

Please sign in to comment.