/** * Copyright 2017–2019, LaborX PTY * Licensed under the AGPL Version 3 license. */ pragma solidity ^0.4.25; import "./Object.sol"; import "./access/roles/WhitelistedRole.sol"; contract Relayed is Object, WhitelistedRole { uint private whitelistedCount; event RelayTransferred(address indexed previousRelay, address indexed newRelay); /// @dev Throws if called by any account other than the relay. modifier onlyRelay() { require(!isActivatedRelay() || isWhitelisted(msg.sender), "RELAY_ONLY"); _; } function isActivatedRelay() public view returns (bool) { return whitelistedCount != 0; } function _addWhitelisted(address account) internal { super._addWhitelisted(account); whitelistedCount = whitelistedCount + 1; } function _removeWhitelisted(address account) internal { super._removeWhitelisted(account); whitelistedCount = whitelistedCount - 1; } }