Skip to content
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

Add isInitialized to all state-changing public functions #307

Merged
merged 2 commits into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 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
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