-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix compilation errors, upgrade Solidity #210
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity ^0.8.10; | ||
pragma experimental ABIEncoderV2; | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pragma solidity ^0.5.16; | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity ^0.8.10; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import "./GovernorBravoInterfaces.sol"; | ||
|
@@ -39,7 +40,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE | |
bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,uint8 support)"); | ||
|
||
/** | ||
* @notice Used to initialize the contract during delegator contructor | ||
* @notice Used to initialize the contract during delegator constructor | ||
* @param timelock_ The address of the Timelock | ||
* @param comp_ The address of the COMP token | ||
* @param votingPeriod_ The initial voting period | ||
|
@@ -91,24 +92,24 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE | |
uint endBlock = add256(startBlock, votingPeriod); | ||
|
||
proposalCount++; | ||
Proposal memory newProposal = Proposal({ | ||
id: proposalCount, | ||
proposer: msg.sender, | ||
eta: 0, | ||
targets: targets, | ||
values: values, | ||
signatures: signatures, | ||
calldatas: calldatas, | ||
startBlock: startBlock, | ||
endBlock: endBlock, | ||
forVotes: 0, | ||
againstVotes: 0, | ||
abstainVotes: 0, | ||
canceled: false, | ||
executed: false | ||
}); | ||
|
||
proposals[newProposal.id] = newProposal; | ||
Proposal storage newProposal = proposals[proposalCount]; | ||
// This should never happen but add a check in case. | ||
require(newProposal.id == 0, "GovernorBravo::propose: ProposalID collsion"); | ||
newProposal.id = proposalCount; | ||
newProposal.proposer = msg.sender; | ||
newProposal.eta = 0; | ||
newProposal.targets = targets; | ||
newProposal.values = values; | ||
newProposal.signatures = signatures; | ||
newProposal.calldatas = calldatas; | ||
newProposal.startBlock = startBlock; | ||
newProposal.endBlock = endBlock; | ||
newProposal.forVotes = 0; | ||
newProposal.againstVotes = 0; | ||
newProposal.abstainVotes = 0; | ||
newProposal.canceled = false; | ||
newProposal.executed = false; | ||
|
||
latestProposalIds[newProposal.proposer] = newProposal.id; | ||
|
||
emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description); | ||
|
@@ -144,7 +145,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE | |
Proposal storage proposal = proposals[proposalId]; | ||
proposal.executed = true; | ||
for (uint i = 0; i < proposal.targets.length; i++) { | ||
timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); | ||
timelock.executeTransaction{value:proposal.values[i]}(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); | ||
} | ||
emit ProposalExecuted(proposalId); | ||
} | ||
|
@@ -180,7 +181,10 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE | |
/** | ||
* @notice Gets actions of a proposal | ||
* @param proposalId the id of the proposal | ||
* @return Targets, values, signatures, and calldatas of the proposal actions | ||
* @return targets of the proposal actions | ||
* @return values of the proposal actions | ||
* @return signatures of the proposal actions | ||
* @return calldatas of the proposal actions | ||
*/ | ||
function getActions(uint proposalId) external view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) { | ||
Proposal storage p = proposals[proposalId]; | ||
|
@@ -292,7 +296,15 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE | |
* @return If the account is whitelisted | ||
*/ | ||
function isWhitelisted(address account) public view returns (bool) { | ||
return (whitelistAccountExpirations[account] > now); | ||
uint currentBlockTimestamp = getBlockTimestamp(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange idea, it would change nothing only making deployment gas cost increase. |
||
return (whitelistAccountExpirations[account] > currentBlockTimestamp); | ||
} | ||
|
||
/** | ||
* @dev Function to simply retrieve block timestamp | ||
*/ | ||
function getBlockTimestamp() internal view returns (uint) { | ||
return block.timestamp; | ||
} | ||
|
||
/** | ||
|
@@ -424,7 +436,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE | |
return a - b; | ||
} | ||
|
||
function getChainIdInternal() internal pure returns (uint) { | ||
function getChainIdInternal() internal view returns (uint) { | ||
uint chainId; | ||
assembly { chainId := chainid() } | ||
return chainId; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 incorrect since it doesn't create a new proprosal, but only creates link to a previous one.
You can test this
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.
Your test is using
memory
structs while this is usingstorage
. This is effectively creating a pointer to the struct at the array index in storage and modifying the fields there, not copying anything.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.
Okay, nvm
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.
.