aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol
blob: ff4660a3173bfecd1e05973d76db6a37b93d1d38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*

  Copyright 2018 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity 0.4.24;

import "../../utils/Ownable/Ownable.sol";
import "./mixins/MAuthorizable.sol";


contract MixinAuthorizable is
    Ownable,
    MAuthorizable
{

    /// @dev Only authorized addresses can invoke functions with this modifier.
    modifier onlyAuthorized {
        require(
            authorized[msg.sender],
            "SENDER_NOT_AUTHORIZED"
        );
        _;
    }

    mapping (address => bool) public authorized;
    address[] public authorities;

    /// @dev Authorizes an address.
    /// @param target Address to authorize.
    function addAuthorizedAddress(address target)
        external
        onlyOwner
    {
        require(
            !authorized[target],
            "TARGET_ALREADY_AUTHORIZED"
        );

        authorized[target] = true;
        authorities.push(target);
        emit AuthorizedAddressAdded(target, msg.sender);
    }

    /// @dev Removes authorizion of an address.
    /// @param target Address to remove authorization from.
    function removeAuthorizedAddress(address target)
        external
        onlyOwner
    {
        require(
            authorized[target],
            "TARGET_NOT_AUTHORIZED"
        );

        delete authorized[target];
        for (uint256 i = 0; i < authorities.length; i++) {
            if (authorities[i] == target) {
                authorities[i] = authorities[authorities.length - 1];
                authorities.length -= 1;
                break;
            }
        }
        emit AuthorizedAddressRemoved(target, msg.sender);
    }

    /// @dev Removes authorizion of an address.
    /// @param target Address to remove authorization from.
    /// @param index Index of target in authorities array.
    function removeAuthorizedAddressAtIndex(
        address target,
        uint256 index
    )
        external
        onlyOwner
    {
        require(
            authorized[target],
            "TARGET_NOT_AUTHORIZED"
        );
        require(
            index < authorities.length,
            "INDEX_OUT_OF_BOUNDS"
        );
        require(
            authorities[index] == target,
            "AUTHORIZED_ADDRESS_MISMATCH"
        );

        delete authorized[target];
        authorities[index] = authorities[authorities.length - 1];
        authorities.length -= 1;
        emit AuthorizedAddressRemoved(target, msg.sender);
    }

    /// @dev Gets all authorized addresses.
    /// @return Array of authorized addresses.
    function getAuthorizedAddresses()
        external
        view
        returns (address[] memory)
    {
        return authorities;
    }
}
'>-1/+1 * Upgrade OpenEXR and ilmbase to 2.2.0.Matthias Andree2014-08-161-0/+1 * KDE/FreeBSD team presents KDE SC 4.12.5 and KDE Workspace 4.11.9!Max Brazhnikov2014-05-111-2/+2 * KDE/FreeBSD team presents KDE SC 4.12.4 and KDE Workspace 4.11.8!Max Brazhnikov2014-04-032-4/+3 * KDE/FreeBSD team presents KDE SC 4.12.3 and KDE Workspace 4.11.7!Max Brazhnikov2014-03-051-2/+2 * KDE/FreeBSD team presents KDE SC 4.12.2 and KDE Workspace 4.11.6!Max Brazhnikov2014-02-182-9/+5 * Add NO_STAGE all over the place in preparation for the staging support (cat: ...Baptiste Daroussin2013-09-211-0/+1 * - Remove MAKE_JOBS_SAFE variableAlex Kozlov2013-08-151-1/+0 * Update the KDE Software Compilation to 4.10.5.Raphael Kubo da Costa2013-07-051-2/+2 * Update to KDE SC 4.10.4, proudly presented by the KDE on FreeBSD team.Raphael Kubo da Costa2013-07-031-2/+2 * KDE/FreeBSD team presents KDE SC 4.10.3 ports!Max Brazhnikov2013-05-191-2/+2 * KDE/FreeBSD team presents KDE SC 4.10.1 ports!Max Brazhnikov2013-03-274-7/+27 * Mk/bsd.kde4.mk:Max Brazhnikov2013-03-221-1/+1 * KDE/FreeBSD team presents KDE SC 4.9.5 ports!Max Brazhnikov2013-02-042-6/+3 * KDE/FreeBSD team presents KDE SC 4.8.4, probably the last release in 4.8.x se...Max Brazhnikov2012-06-151-2/+2 * - Convert USE_QT_VER=4 and QT_COMPONETS to USE_QT4Martin Wilke2012-06-061-2/+1 * KDE/FreeBSD team presents long awaited KDE SC 4.8.3!Max Brazhnikov2012-05-254-395/+15 * - Chase libarchive shlib bumpPav Lucistnik2012-03-031-2/+2 * - Bump PORTREVISION to chase the update of multimedia/libvpxAshish SHUKLA2012-02-161-0/+1 * The KDE/FreeBSD team is pleased to announce KDE SC 4.7.4, whichAlberto Villa2012-01-252-3/+3 * The KDE on FreeBSD team is pleased to update the KDE4 ports to 4.7.3.Raphael Kubo da Costa2011-11-14