Skip to content

Commit

Permalink
Add isInitialized to all state-changing public functions
Browse files Browse the repository at this point in the history
Closes aragon#303.
  • Loading branch information
ßingen committed May 14, 2018
1 parent cf4eb06 commit 770eaea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
18 changes: 9 additions & 9 deletions apps/finance/contracts/Finance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ contract Finance is AragonApp {
* @dev Sends ETH to Vault. Sends all the available balance.
* @notice Allows to send ETH from this contract to Vault, to avoid locking them in contract forever.
*/
function () public payable {
function () isInitialized public payable {
_recordIncomingTransaction(
ETH,
msg.sender,
Expand Down Expand Up @@ -165,7 +165,7 @@ contract Finance is AragonApp {
* @param _operatorData Information attached to the transaction by the operator
*/
/*
function tokensReceived(address _operator, address _from, address _to, uint _amount, bytes _userData, bytes _operatorData) transitionsPeriod external {
function tokensReceived(address _operator, address _from, address _to, uint _amount, bytes _userData, bytes _operatorData) transitionsPeriod isInitialized external {
_recordIncomingTransaction(
msg.sender,
_from,
Expand Down Expand Up @@ -237,7 +237,7 @@ contract Finance is AragonApp {
* @notice Change period duration to `(_periodDuration - _periodDuration % 86400) / 86400` day`_periodDuration >= 172800 ? 's' : ''`, effective for next accounting period.
* @param _periodDuration Duration in seconds for accounting periods
*/
function setPeriodDuration(uint64 _periodDuration) authP(CHANGE_PERIOD_ROLE, arr(uint256(_periodDuration), uint256(settings.periodDuration))) transitionsPeriod external {
function setPeriodDuration(uint64 _periodDuration) authP(CHANGE_PERIOD_ROLE, arr(uint256(_periodDuration), uint256(settings.periodDuration))) transitionsPeriod isInitialized external {
require(_periodDuration >= 1 days);
settings.periodDuration = _periodDuration;
ChangePeriodDuration(_periodDuration);
Expand All @@ -248,7 +248,7 @@ contract Finance is AragonApp {
* @param _token Address for token
* @param _amount New budget amount
*/
function setBudget(address _token, uint256 _amount) authP(CHANGE_BUDGETS_ROLE, arr(_token, _amount, settings.budgets[_token])) transitionsPeriod external {
function setBudget(address _token, uint256 _amount) authP(CHANGE_BUDGETS_ROLE, arr(_token, _amount, settings.budgets[_token])) transitionsPeriod isInitialized external {
settings.budgets[_token] = _amount;
if (!settings.hasBudget[_token]) {
settings.hasBudget[_token] = true;
Expand All @@ -260,7 +260,7 @@ contract Finance is AragonApp {
* @notice Remove spending limit for `_token.symbol(): string`.
* @param _token Address for token
*/
function removeBudget(address _token) authP(CHANGE_BUDGETS_ROLE, arr(_token, uint256(0), settings.budgets[_token])) transitionsPeriod external {
function removeBudget(address _token) authP(CHANGE_BUDGETS_ROLE, arr(_token, uint256(0), settings.budgets[_token])) transitionsPeriod isInitialized external {
settings.hasBudget[_token] = false;
SetBudget(_token, 0, false);
}
Expand All @@ -270,7 +270,7 @@ contract Finance is AragonApp {
* @notice Execute pending payment #`_paymentId`
* @param _paymentId Identifier for payment
*/
function executePayment(uint256 _paymentId) authP(EXECUTE_PAYMENTS_ROLE, arr(_paymentId, payments[_paymentId].amount)) external {
function executePayment(uint256 _paymentId) authP(EXECUTE_PAYMENTS_ROLE, arr(_paymentId, payments[_paymentId].amount)) isInitialized external {
require(nextPaymentTime(_paymentId) <= getTimestamp());

_executePayment(_paymentId);
Expand All @@ -281,7 +281,7 @@ contract Finance is AragonApp {
* @notice Execute pending payment #`_paymentId`
* @param _paymentId Identifier for payment
*/
function receiverExecutePayment(uint256 _paymentId) external {
function receiverExecutePayment(uint256 _paymentId) isInitialized external {
require(nextPaymentTime(_paymentId) <= getTimestamp());
require(payments[_paymentId].receiver == msg.sender);

Expand All @@ -293,7 +293,7 @@ contract Finance is AragonApp {
* @param _paymentId Identifier for payment
* @param _disabled Whether it will be disabled or enabled
*/
function setPaymentDisabled(uint256 _paymentId, bool _disabled) authP(DISABLE_PAYMENTS_ROLE, arr(_paymentId)) external {
function setPaymentDisabled(uint256 _paymentId, bool _disabled) authP(DISABLE_PAYMENTS_ROLE, arr(_paymentId)) isInitialized external {
payments[_paymentId].disabled = _disabled;
ChangePaymentState(_paymentId, _disabled);
}
Expand Down Expand Up @@ -330,7 +330,7 @@ contract Finance is AragonApp {
* @return success Boolean indicating whether the accounting period is the correct one (if false,
* maxTransitions was surpased and another call is needed)
*/
function tryTransitionAccountingPeriod(uint256 _maxTransitions) public returns (bool success) {
function tryTransitionAccountingPeriod(uint256 _maxTransitions) isInitialized public returns (bool success) {
Period storage currentPeriod = periods[currentPeriodId()];
uint256 timestamp = getTimestamp();

Expand Down
10 changes: 5 additions & 5 deletions apps/token-manager/contracts/TokenManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ contract TokenManager is ITokenController, AragonApp { // ,IForwarder makes cove
* @param _holder Address getting vesting revoked
* @param _vestingId Numeric id of the vesting
*/
function revokeVesting(address _holder, uint256 _vestingId) authP(REVOKE_VESTINGS_ROLE, arr(_holder)) external {
function revokeVesting(address _holder, uint256 _vestingId) authP(REVOKE_VESTINGS_ROLE, arr(_holder)) isInitialized external {
TokenVesting storage v = vestings[_holder][_vestingId];
require(v.revokable);

Expand All @@ -181,7 +181,7 @@ contract TokenManager is ITokenController, AragonApp { // ,IForwarder makes cove
* @dev IForwarder interface conformance. Forwards any token holder action.
* @param _evmScript Script being executed
*/
function forward(bytes _evmScript) public {
function forward(bytes _evmScript) isInitialized public {
require(canForward(msg.sender, _evmScript));
bytes memory input = new bytes(0); // TODO: Consider input for this
address[] memory blacklist = new address[](1);
Expand Down Expand Up @@ -215,7 +215,7 @@ contract TokenManager is ITokenController, AragonApp { // ,IForwarder makes cove
* @param _amount The amount of the transfer
* @return False if the controller does not authorize the transfer
*/
function onTransfer(address _from, address _to, uint _amount) public returns (bool) {
function onTransfer(address _from, address _to, uint _amount) isInitialized public returns (bool) {
require(msg.sender == address(token));

bool includesTokenManager = _from == address(this) || _to == address(this);
Expand Down Expand Up @@ -351,7 +351,7 @@ contract TokenManager is ITokenController, AragonApp { // ,IForwarder makes cove
* @param _owner The address that sent the ether to create tokens
* @return True if the ether is accepted, false for it to throw
*/
function proxyPayment(address _owner) payable public returns (bool) {
function proxyPayment(address _owner) payable isInitialized public returns (bool) {
// Even though it is tested, solidity-coverage doesnt get it because
// MiniMeToken is not instrumented and entire tx is reverted
require(msg.sender == address(token));
Expand All @@ -365,7 +365,7 @@ contract TokenManager is ITokenController, AragonApp { // ,IForwarder makes cove
* @param _amount The amount in the `approve()` call
* @return False if the controller does not authorize the approval
*/
function onApprove(address _owner, address _spender, uint _amount) public returns (bool) {
function onApprove(address _owner, address _spender, uint _amount) isInitialized public returns (bool) {
_owner;
_spender;
_amount;
Expand Down
3 changes: 2 additions & 1 deletion apps/vault/contracts/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract Vault is VaultBase {
connectors[ETH] = ethConnector;
}

function () payable public {
function () payable isInitialized public {
address token = ETH;

// 4 (sig) + 32 (at least the token address to locate connector)
Expand All @@ -74,6 +74,7 @@ contract Vault is VaultBase {

function registerStandard(uint32 erc, uint32 interfaceDetectionERC, bytes4 interfaceID, address connector)
authP(REGISTER_TOKEN_STANDARD, arr(uint256(erc), interfaceDetectionERC))
isInitialized
public
{

Expand Down
6 changes: 3 additions & 3 deletions apps/voting/contracts/Voting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ contract Voting is IForwarder, AragonApp {
* @notice Change minimum acceptance quorum to `(_minAcceptQuorumPct - _minAcceptQuorumPct % 10^14) / 10^16`%
* @param _minAcceptQuorumPct New acceptance quorum
*/
function changeMinAcceptQuorumPct(uint256 _minAcceptQuorumPct) authP(MODIFY_QUORUM_ROLE, arr(_minAcceptQuorumPct, minAcceptQuorumPct)) external {
function changeMinAcceptQuorumPct(uint256 _minAcceptQuorumPct) authP(MODIFY_QUORUM_ROLE, arr(_minAcceptQuorumPct, minAcceptQuorumPct)) isInitialized external {
require(_minAcceptQuorumPct > 0);
require(supportRequiredPct >= _minAcceptQuorumPct);
minAcceptQuorumPct = _minAcceptQuorumPct;
Expand Down Expand Up @@ -114,7 +114,7 @@ contract Voting is IForwarder, AragonApp {
* @param _supports Whether voter supports the vote
* @param _executesIfDecided Whether the vote should execute its action if it becomes decided
*/
function vote(uint256 _voteId, bool _supports, bool _executesIfDecided) external {
function vote(uint256 _voteId, bool _supports, bool _executesIfDecided) isInitialized external {
require(canVote(_voteId, msg.sender));
_vote(
_voteId,
Expand All @@ -128,7 +128,7 @@ contract Voting is IForwarder, AragonApp {
* @notice Execute the result of vote #`_voteId`
* @param _voteId Id for vote
*/
function executeVote(uint256 _voteId) external {
function executeVote(uint256 _voteId) isInitialized external {
require(canExecute(_voteId));
_executeVote(_voteId);
}
Expand Down

0 comments on commit 770eaea

Please sign in to comment.