Skip to content

Commit f21afb0

Browse files
authored
[P1-L04] Update require messages (#1259)
* Updated require messages Signed-off-by: Christopher Maree <christopher.maree@gmail.com> * Updated spacing Signed-off-by: Christopher Maree <christopher.maree@gmail.com> * Reverted lint change Signed-off-by: Christopher Maree <christopher.maree@gmail.com> * reverted nit Signed-off-by: Christopher Maree <christopher.maree@gmail.com> * nits Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
1 parent ee52c97 commit f21afb0

File tree

7 files changed

+21
-22
lines changed

7 files changed

+21
-22
lines changed

core/contracts/oracle/implementation/Finder.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ contract Finder is FinderInterface, Ownable {
2525
// TODO(#969) Remove once prettier-plugin-solidity can handle the "override" keyword
2626
// prettier-ignore
2727
function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external override onlyOwner {
28-
require(implementationAddress.isContract(),"Can only change implementation to a contract");
28+
require(implementationAddress.isContract(),"New address must be a contract");
2929
interfacesImplemented[interfaceName] = implementationAddress;
3030

3131
emit InterfaceImplementationChanged(interfaceName, implementationAddress);
@@ -40,7 +40,7 @@ contract Finder is FinderInterface, Ownable {
4040
// prettier-ignore
4141
function getImplementationAddress(bytes32 interfaceName) external override view returns (address) {
4242
address implementationAddress = interfacesImplemented[interfaceName];
43-
require(implementationAddress != address(0x0), "No implementation for interface found");
43+
require(implementationAddress != address(0x0), "Implementation not found");
4444
return implementationAddress;
4545
}
4646
}

core/contracts/oracle/implementation/Governor.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ contract Governor is MultiRole, Testable {
9797

9898
// Initialize the transaction array.
9999
for (uint256 i = 0; i < transactions.length; i++) {
100-
require(transactions[i].to != address(0), "The to address cannot be 0x0");
100+
require(transactions[i].to != address(0), "The `to` address cannot be 0x0");
101101
// If the transaction has any data with it the recipient must be a contract, not an EOA.
102102
if (transactions[i].data.length > 0) {
103-
require(transactions[i].to.isContract(), "Only propose transactions on a contract");
103+
require(transactions[i].to.isContract(), "EOA can't accept tx with data");
104104
}
105105
proposal.transactions.push(transactions[i]);
106106
}
@@ -132,16 +132,16 @@ contract Governor is MultiRole, Testable {
132132

133133
require(
134134
transactionIndex == 0 || proposal.transactions[transactionIndex.sub(1)].to == address(0),
135-
"Previous transaction has not been executed"
135+
"Previous tx not yet executed"
136136
);
137-
require(transaction.to != address(0), "Transaction has already been executed");
138-
require(price != 0, "Cannot execute, proposal was voted down");
139-
require(msg.value == transaction.value, "Must send the exact amount of ETH to execute transaction");
137+
require(transaction.to != address(0), "Tx already executed");
138+
require(price != 0, "Proposal was rejected");
139+
require(msg.value == transaction.value, "Must send exact amount of ETH");
140140

141141
// Delete the transaction before execution to avoid any potential re-entrancy issues.
142142
delete proposal.transactions[transactionIndex];
143143

144-
require(_executeCall(transaction.to, transaction.value, transaction.data), "Transaction execution failed");
144+
require(_executeCall(transaction.to, transaction.value, transaction.data), "Tx execution failed");
145145

146146
emit ProposalExecuted(id, transactionIndex);
147147
}

core/contracts/oracle/implementation/Registry.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ contract Registry is RegistryInterface, MultiRole {
109109
// prettier-ignore
110110
function addPartyToContract(address party) external override {
111111
address contractAddress = msg.sender;
112-
113112
require(contractMap[contractAddress].valid == Validity.Valid, "Can only add to valid contract");
114113

115114
_addPartyToContract(party, contractAddress);
@@ -126,10 +125,10 @@ contract Registry is RegistryInterface, MultiRole {
126125
address contractAddress = msg.sender;
127126
Party storage party = partyMap[partyAddress];
128127
uint256 numberOfContracts = party.contracts.length;
129-
130-
require(numberOfContracts != 0, "Can't remove if party has no contracts");
128+
129+
require(numberOfContracts != 0, "Party has no contracts");
131130
require(contractMap[contractAddress].valid == Validity.Valid, "Remove only from valid contract");
132-
require(isPartyMemberOfContract(partyAddress, contractAddress), "Can only remove an existing party");
131+
require(isPartyMemberOfContract(partyAddress, contractAddress), "Can only remove existing party");
133132

134133
// Index of the current location of the contract to remove.
135134
uint256 deleteIndex = party.contractIndex[contractAddress];

core/contracts/oracle/implementation/Store.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ contract Store is StoreInterface, Withdrawable, Testable {
5959
// TODO(#969) Remove once prettier-plugin-solidity can handle the "override" keyword
6060
// prettier-ignore
6161
function payOracleFees() external override payable {
62-
require(msg.value > 0);
62+
require(msg.value > 0, "Value sent can't be zero");
6363
}
6464

6565
/**
@@ -72,7 +72,7 @@ contract Store is StoreInterface, Withdrawable, Testable {
7272
// prettier-ignore
7373
function payOracleFeesErc20(address erc20Address, FixedPoint.Unsigned calldata amount) external override {
7474
IERC20 erc20 = IERC20(erc20Address);
75-
require(amount.isGreaterThan(0));
75+
require(amount.isGreaterThan(0), "Amount sent can't be zero");
7676
erc20.safeTransferFrom(msg.sender, address(this), amount.rawValue);
7777
}
7878

@@ -140,7 +140,7 @@ contract Store is StoreInterface, Withdrawable, Testable {
140140
onlyRoleHolder(uint(Roles.Owner))
141141
{
142142
// Oracle fees at or over 100% don't make sense.
143-
require(newFixedOracleFeePerSecondPerPfc.isLessThan(1));
143+
require(newFixedOracleFeePerSecondPerPfc.isLessThan(1), "Fee must be < 100% per second.");
144144
fixedOracleFeePerSecondPerPfc = newFixedOracleFeePerSecondPerPfc;
145145
emit NewFixedOracleFeePerSecondPerPfc(newFixedOracleFeePerSecondPerPfc);
146146
}

core/contracts/oracle/implementation/TokenMigrator.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ contract TokenMigrator {
3636
constructor(FixedPoint.Unsigned memory _rate, address _oldToken, address _newToken) public {
3737
// Prevents division by 0 in migrateTokens().
3838
// Also it doesn’t make sense to have “0 old tokens equate to 1 new token”.
39-
require(_rate.isGreaterThan(0));
39+
require(_rate.isGreaterThan(0), "Rate can't be 0");
4040
rate = _rate;
4141
newToken = ExpandedIERC20(_newToken);
4242
oldToken = VotingToken(_oldToken);

core/contracts/oracle/implementation/Voting.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,16 @@ contract Voting is Testable, Ownable, OracleInterface, VotingInterface {
195195

196196
modifier onlyRegisteredContract() {
197197
if (migratedAddress != address(0)) {
198-
require(msg.sender == migratedAddress);
198+
require(msg.sender == migratedAddress, "Caller must be migrated address");
199199
} else {
200200
Registry registry = Registry(finder.getImplementationAddress(OracleInterfaces.Registry));
201-
require(registry.isContractRegistered(msg.sender));
201+
require(registry.isContractRegistered(msg.sender), "Called must be registered");
202202
}
203203
_;
204204
}
205205

206206
modifier onlyIfNotMigrated() {
207-
require(migratedAddress == address(0));
207+
require(migratedAddress == address(0), "Only call this if not migrated");
208208
_;
209209
}
210210

@@ -348,7 +348,7 @@ contract Voting is Testable, Ownable, OracleInterface, VotingInterface {
348348
// prettier-ignore
349349
function snapshotCurrentRound() external override onlyIfNotMigrated() {
350350
uint blockTime = getCurrentTime();
351-
require(voteTiming.computeCurrentPhase(blockTime) == Phase.Reveal, "Can only snapshot in reveal phase");
351+
require(voteTiming.computeCurrentPhase(blockTime) == Phase.Reveal, "Only snapshot in reveal phase");
352352

353353
uint roundId = voteTiming.computeCurrentRoundId(blockTime);
354354
_freezeRoundVariables(roundId);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"husky": "^4.2.3",
2323
"lint-staged": "^10.1.3",
2424
"prettier": "1.19.1",
25-
"prettier-plugin-solidity": "^1.0.0-alpha.46",
25+
"prettier-plugin-solidity": "1.0.0-alpha.46",
2626
"pretty-quick": "^2.0.1",
2727
"solidity-coverage": "^0.7.2",
2828
"truffle-deploy-registry": "^0.5.1"

0 commit comments

Comments
 (0)