Contract Address Details

0xBcE053b99e22158f8B62f4DBFbEdE1f936b2D4e4

Controller Last Balance Update: Block #15182892
Created by 0x284a77–f9b11d at 0x6b0be0–531bb8

Balance

0 Fuse

Fetching tokens...

Contract name:
Controller




Optimization enabled
true
Compiler version
v0.5.16+commit.9c3226ce




Optimization runs
200
EVM Version
default




Verified at
2021-10-06 10:08:02.884264Z

Constructor Arguments

000000000000000000000000f96dadc6d71113f6500e97590760c924da1ef70e

Arg [0] (address) : 0xf96dadc6d71113f6500e97590760c924da1ef70e

              

Contract source code

// File: openzeppelin-solidity/contracts/ownership/Ownable.sol
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor () internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
/**
* @return the address of the owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner());
_;
}
/**
* @return true if `msg.sender` is the owner of the contract.
*/
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: @daostack/infra/contracts/Reputation.sol
pragma solidity ^0.5.4;
/**
* @title Reputation system
* @dev A DAO has Reputation System which allows peers to rate other peers in order to build trust .
* A reputation is use to assign influence measure to a DAO'S peers.
* Reputation is similar to regular tokens but with one crucial difference: It is non-transferable.
* The Reputation contract maintain a map of address to reputation value.
* It provides an onlyOwner functions to mint and burn reputation _to (or _from) a specific address.
*/
contract Reputation is Ownable {
uint8 public decimals = 18; //Number of decimals of the smallest unit
// Event indicating minting of reputation to an address.
event Mint(address indexed _to, uint256 _amount);
// Event indicating burning of reputation for an address.
event Burn(address indexed _from, uint256 _amount);
/// @dev `Checkpoint` is the structure that attaches a block number to a
/// given value, the block number attached is the one that last changed the
/// value
struct Checkpoint {
// `fromBlock` is the block number that the value was generated from
uint128 fromBlock;
// `value` is the amount of reputation at a specific block number
uint128 value;
}
// `balances` is the map that tracks the balance of each address, in this
// contract when the balance changes the block number that the change
// occurred is also included in the map
mapping (address => Checkpoint[]) balances;
// Tracks the history of the `totalSupply` of the reputation
Checkpoint[] totalSupplyHistory;
/// @notice Constructor to create a Reputation
constructor(
) public
{
}
/// @dev This function makes it easy to get the total number of reputation
/// @return The total number of reputation
function totalSupply() public view returns (uint256) {
return totalSupplyAt(block.number);
}
////////////////
// Query balance and totalSupply in History
////////////////
/**
* @dev return the reputation amount of a given owner
* @param _owner an address of the owner which we want to get his reputation
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balanceOfAt(_owner, block.number);
}
/// @dev Queries the balance of `_owner` at a specific `_blockNumber`
/// @param _owner The address from which the balance will be retrieved
/// @param _blockNumber The block number when the balance is queried
/// @return The balance at `_blockNumber`
function balanceOfAt(address _owner, uint256 _blockNumber)
public view returns (uint256)
{
if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
return 0;
// This will return the expected balance during normal situations
} else {
return getValueAt(balances[_owner], _blockNumber);
}
}
/// @notice Total amount of reputation at a specific `_blockNumber`.
/// @param _blockNumber The block number when the totalSupply is queried
/// @return The total amount of reputation at `_blockNumber`
function totalSupplyAt(uint256 _blockNumber) public view returns(uint256) {
if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
return 0;
// This will return the expected totalSupply during normal situations
} else {
return getValueAt(totalSupplyHistory, _blockNumber);
}
}
/// @notice Generates `_amount` reputation that are assigned to `_owner`
/// @param _user The address that will be assigned the new reputation
/// @param _amount The quantity of reputation generated
/// @return True if the reputation are generated correctly
function mint(address _user, uint256 _amount) public onlyOwner returns (bool) {
uint256 curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
uint256 previousBalanceTo = balanceOf(_user);
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_user], previousBalanceTo + _amount);
emit Mint(_user, _amount);
return true;
}
/// @notice Burns `_amount` reputation from `_owner`
/// @param _user The address that will lose the reputation
/// @param _amount The quantity of reputation to burn
/// @return True if the reputation are burned correctly
function burn(address _user, uint256 _amount) public onlyOwner returns (bool) {
uint256 curTotalSupply = totalSupply();
uint256 amountBurned = _amount;
uint256 previousBalanceFrom = balanceOf(_user);
if (previousBalanceFrom < amountBurned) {
amountBurned = previousBalanceFrom;
}
updateValueAtNow(totalSupplyHistory, curTotalSupply - amountBurned);
updateValueAtNow(balances[_user], previousBalanceFrom - amountBurned);
emit Burn(_user, amountBurned);
return true;
}
////////////////
// Internal helper functions to query and set a value in a snapshot array
////////////////
/// @dev `getValueAt` retrieves the number of reputation at a given block number
/// @param checkpoints The history of values being queried
/// @param _block The block number to retrieve the value at
/// @return The number of reputation being queried
function getValueAt(Checkpoint[] storage checkpoints, uint256 _block) internal view returns (uint256) {
if (checkpoints.length == 0) {
return 0;
}
// Shortcut for the actual value
if (_block >= checkpoints[checkpoints.length-1].fromBlock) {
return checkpoints[checkpoints.length-1].value;
}
if (_block < checkpoints[0].fromBlock) {
return 0;
}
// Binary search of the value in the array
uint256 min = 0;
uint256 max = checkpoints.length-1;
while (max > min) {
uint256 mid = (max + min + 1) / 2;
if (checkpoints[mid].fromBlock<=_block) {
min = mid;
} else {
max = mid-1;
}
}
return checkpoints[min].value;
}
/// @dev `updateValueAtNow` used to update the `balances` map and the
/// `totalSupplyHistory`
/// @param checkpoints The history of data being updated
/// @param _value The new number of reputation
function updateValueAtNow(Checkpoint[] storage checkpoints, uint256 _value) internal {
require(uint128(_value) == _value); //check value is in the 128 bits bounderies
if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) {
Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
newCheckPoint.fromBlock = uint128(block.number);
newCheckPoint.value = uint128(_value);
} else {
Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
oldCheckPoint.value = uint128(_value);
}
}
}
// File: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: openzeppelin-solidity/contracts/math/SafeMath.sol
/**
* @title SafeMath
* @dev Unsigned math operations with safety checks that revert on error
*/
library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two unsigned integers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
// File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood:
* https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*
* This implementation emits additional Approval events, allowing applications to reconstruct the allowance status for
* all accounts just by listening to said events. Note that this isn't required by the specification, and other
* compliant implementations may not do it.
*/
contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(address from, address to, uint256 value) public returns (bool) {
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
emit Approval(from, msg.sender, _allowed[from][msg.sender]);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param value The amount that will be created.
*/
function _mint(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param value The amount that will be burnt.
*/
function _burn(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* Emits an Approval event (reflecting the reduced allowance).
* @param account The account whose tokens will be burnt.
* @param value The amount that will be burnt.
*/
function _burnFrom(address account, uint256 value) internal {
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
emit Approval(account, msg.sender, _allowed[account][msg.sender]);
}
}
// File: openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol
/**
* @title Burnable Token
* @dev Token that can be irreversibly burned (destroyed).
*/
contract ERC20Burnable is ERC20 {
/**
* @dev Burns a specific amount of tokens.
* @param value The amount of token to be burned.
*/
function burn(uint256 value) public {
_burn(msg.sender, value);
}
/**
* @dev Burns a specific amount of tokens from the target address and decrements allowance
* @param from address The address which you want to send tokens from
* @param value uint256 The amount of token to be burned
*/
function burnFrom(address from, uint256 value) public {
_burnFrom(from, value);
}
}
// File: @daostack/arc/contracts/controller/DAOToken.sol
/**
* @title DAOToken, base on zeppelin contract.
* @dev ERC20 compatible token. It is a mintable, burnable token.
*/
contract DAOToken is ERC20, ERC20Burnable, Ownable {
string public name;
string public symbol;
// solhint-disable-next-line const-name-snakecase
uint8 public constant decimals = 18;
uint256 public cap;
/**
* @dev Constructor
* @param _name - token name
* @param _symbol - token symbol
* @param _cap - token cap - 0 value means no cap
*/
constructor(string memory _name, string memory _symbol, uint256 _cap)
public {
name = _name;
symbol = _symbol;
cap = _cap;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
*/
function mint(address _to, uint256 _amount) public onlyOwner returns (bool) {
if (cap > 0)
require(totalSupply().add(_amount) <= cap);
_mint(_to, _amount);
return true;
}
}
// File: openzeppelin-solidity/contracts/utils/Address.sol
/**
* Utility library of inline functions on addresses
*/
library Address {
/**
* Returns whether the target address is a contract
* @dev This function will return false if invoked during the constructor of a contract,
* as the code is not actually created until after the constructor finishes.
* @param account address of the account to check
* @return whether the target address is a contract
*/
function isContract(address account) internal view returns (bool) {
uint256 size;
// XXX Currently there is no better way to check if there is a contract in an address
// than to check the size of the code at that address.
// See https://ethereum.stackexchange.com/a/14016/36603
// for more details about how this works.
// TODO Check this again before the Serenity release, because all addresses will be
// contracts then.
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
// File: @daostack/arc/contracts/libs/SafeERC20.sol
/*
SafeERC20 by daostack.
The code is based on a fix by SECBIT Team.
USE WITH CAUTION & NO WARRANTY
REFERENCE & RELATED READING
- https://github.com/ethereum/solidity/issues/4116
- https://medium.com/@chris_77367/explaining-unexpected-reverts-starting-with-solidity-0-4-22-3ada6e82308c
- https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
- https://gist.github.com/BrendanChou/88a2eeb80947ff00bcf58ffdafeaeb61
*/
library SafeERC20 {
using Address for address;
bytes4 constant private TRANSFER_SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)")));
bytes4 constant private TRANSFERFROM_SELECTOR = bytes4(keccak256(bytes("transferFrom(address,address,uint256)")));
bytes4 constant private APPROVE_SELECTOR = bytes4(keccak256(bytes("approve(address,uint256)")));
function safeTransfer(address _erc20Addr, address _to, uint256 _value) internal {
// Must be a contract addr first!
require(_erc20Addr.isContract());
(bool success, bytes memory returnValue) =
// solhint-disable-next-line avoid-low-level-calls
_erc20Addr.call(abi.encodeWithSelector(TRANSFER_SELECTOR, _to, _value));
// call return false when something wrong
require(success);
//check return value
require(returnValue.length == 0 || (returnValue.length == 32 && (returnValue[31] != 0)));
}
function safeTransferFrom(address _erc20Addr, address _from, address _to, uint256 _value) internal {
// Must be a contract addr first!
require(_erc20Addr.isContract());
(bool success, bytes memory returnValue) =
// solhint-disable-next-line avoid-low-level-calls
_erc20Addr.call(abi.encodeWithSelector(TRANSFERFROM_SELECTOR, _from, _to, _value));
// call return false when something wrong
require(success);
//check return value
require(returnValue.length == 0 || (returnValue.length == 32 && (returnValue[31] != 0)));
}
function safeApprove(address _erc20Addr, address _spender, uint256 _value) internal {
// Must be a contract addr first!
require(_erc20Addr.isContract());
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero.
require((_value == 0) || (IERC20(_erc20Addr).allowance(address(this), _spender) == 0));
(bool success, bytes memory returnValue) =
// solhint-disable-next-line avoid-low-level-calls
_erc20Addr.call(abi.encodeWithSelector(APPROVE_SELECTOR, _spender, _value));
// call return false when something wrong
require(success);
//check return value
require(returnValue.length == 0 || (returnValue.length == 32 && (returnValue[31] != 0)));
}
}
// File: @daostack/arc/contracts/controller/Avatar.sol
/**
* @title An Avatar holds tokens, reputation and ether for a controller
*/
contract Avatar is Ownable {
using SafeERC20 for address;
string public orgName;
DAOToken public nativeToken;
Reputation public nativeReputation;
event GenericCall(address indexed _contract, bytes _data, uint _value, bool _success);
event SendEther(uint256 _amountInWei, address indexed _to);
event ExternalTokenTransfer(address indexed _externalToken, address indexed _to, uint256 _value);
event ExternalTokenTransferFrom(address indexed _externalToken, address _from, address _to, uint256 _value);
event ExternalTokenApproval(address indexed _externalToken, address _spender, uint256 _value);
event ReceiveEther(address indexed _sender, uint256 _value);
event MetaData(string _metaData);
/**
* @dev the constructor takes organization name, native token and reputation system
and creates an avatar for a controller
*/
constructor(string memory _orgName, DAOToken _nativeToken, Reputation _nativeReputation) public {
orgName = _orgName;
nativeToken = _nativeToken;
nativeReputation = _nativeReputation;
}
/**
* @dev enables an avatar to receive ethers
*/
function() external payable {
emit ReceiveEther(msg.sender, msg.value);
}
/**
* @dev perform a generic call to an arbitrary contract
* @param _contract the contract's address to call
* @param _data ABI-encoded contract call to call `_contract` address.
* @param _value value (ETH) to transfer with the transaction
* @return bool success or fail
* bytes - the return bytes of the called contract's function.
*/
function genericCall(address _contract, bytes memory _data, uint256 _value)
public
onlyOwner
returns(bool success, bytes memory returnValue) {
// solhint-disable-next-line avoid-call-value
(success, returnValue) = _contract.call.value(_value)(_data);
emit GenericCall(_contract, _data, _value, success);
}
/**
* @dev send ethers from the avatar's wallet
* @param _amountInWei amount to send in Wei units
* @param _to send the ethers to this address
* @return bool which represents success
*/
function sendEther(uint256 _amountInWei, address payable _to) public onlyOwner returns(bool) {
_to.transfer(_amountInWei);
emit SendEther(_amountInWei, _to);
return true;
}
/**
* @dev external token transfer
* @param _externalToken the token contract
* @param _to the destination address
* @param _value the amount of tokens to transfer
* @return bool which represents success
*/
function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value)
public onlyOwner returns(bool)
{
address(_externalToken).safeTransfer(_to, _value);
emit ExternalTokenTransfer(address(_externalToken), _to, _value);
return true;
}
/**
* @dev external token transfer from a specific account
* @param _externalToken the token contract
* @param _from the account to spend token from
* @param _to the destination address
* @param _value the amount of tokens to transfer
* @return bool which represents success
*/
function externalTokenTransferFrom(
IERC20 _externalToken,
address _from,
address _to,
uint256 _value
)
public onlyOwner returns(bool)
{
address(_externalToken).safeTransferFrom(_from, _to, _value);
emit ExternalTokenTransferFrom(address(_externalToken), _from, _to, _value);
return true;
}
/**
* @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
* on behalf of msg.sender.
* @param _externalToken the address of the Token Contract
* @param _spender address
* @param _value the amount of ether (in Wei) which the approval is referring to.
* @return bool which represents a success
*/
function externalTokenApproval(IERC20 _externalToken, address _spender, uint256 _value)
public onlyOwner returns(bool)
{
address(_externalToken).safeApprove(_spender, _value);
emit ExternalTokenApproval(address(_externalToken), _spender, _value);
return true;
}
/**
* @dev metaData emits an event with a string, should contain the hash of some meta data.
* @param _metaData a string representing a hash of the meta data
* @return bool which represents a success
*/
function metaData(string memory _metaData) public onlyOwner returns(bool) {
emit MetaData(_metaData);
return true;
}
}
// File: @daostack/arc/contracts/globalConstraints/GlobalConstraintInterface.sol
contract GlobalConstraintInterface {
enum CallPhase { Pre, Post, PreAndPost }
function pre( address _scheme, bytes32 _params, bytes32 _method ) public returns(bool);
function post( address _scheme, bytes32 _params, bytes32 _method ) public returns(bool);
/**
* @dev when return if this globalConstraints is pre, post or both.
* @return CallPhase enum indication Pre, Post or PreAndPost.
*/
function when() public returns(CallPhase);
}
// File: @daostack/arc/contracts/controller/ControllerInterface.sol
/**
* @title Controller contract
* @dev A controller controls the organizations tokens ,reputation and avatar.
* It is subject to a set of schemes and constraints that determine its behavior.
* Each scheme has it own parameters and operation permissions.
*/
interface ControllerInterface {
/**
* @dev Mint `_amount` of reputation that are assigned to `_to` .
* @param _amount amount of reputation to mint
* @param _to beneficiary address
* @return bool which represents a success
*/
function mintReputation(uint256 _amount, address _to, address _avatar)
external
returns(bool);
/**
* @dev Burns `_amount` of reputation from `_from`
* @param _amount amount of reputation to burn
* @param _from The address that will lose the reputation
* @return bool which represents a success
*/
function burnReputation(uint256 _amount, address _from, address _avatar)
external
returns(bool);
/**
* @dev mint tokens .
* @param _amount amount of token to mint
* @param _beneficiary beneficiary address
* @param _avatar address
* @return bool which represents a success
*/
function mintTokens(uint256 _amount, address _beneficiary, address _avatar)
external
returns(bool);
/**
* @dev register or update a scheme
* @param _scheme the address of the scheme
* @param _paramsHash a hashed configuration of the usage of the scheme
* @param _permissions the permissions the new scheme will have
* @param _avatar address
* @return bool which represents a success
*/
function registerScheme(address _scheme, bytes32 _paramsHash, bytes4 _permissions, address _avatar)
external
returns(bool);
/**
* @dev unregister a scheme
* @param _avatar address
* @param _scheme the address of the scheme
* @return bool which represents a success
*/
function unregisterScheme(address _scheme, address _avatar)
external
returns(bool);
/**
* @dev unregister the caller's scheme
* @param _avatar address
* @return bool which represents a success
*/
function unregisterSelf(address _avatar) external returns(bool);
/**
* @dev add or update Global Constraint
* @param _globalConstraint the address of the global constraint to be added.
* @param _params the constraint parameters hash.
* @param _avatar the avatar of the organization
* @return bool which represents a success
*/
function addGlobalConstraint(address _globalConstraint, bytes32 _params, address _avatar)
external returns(bool);
/**
* @dev remove Global Constraint
* @param _globalConstraint the address of the global constraint to be remove.
* @param _avatar the organization avatar.
* @return bool which represents a success
*/
function removeGlobalConstraint (address _globalConstraint, address _avatar)
external returns(bool);
/**
* @dev upgrade the Controller
* The function will trigger an event 'UpgradeController'.
* @param _newController the address of the new controller.
* @param _avatar address
* @return bool which represents a success
*/
function upgradeController(address _newController, Avatar _avatar)
external returns(bool);
/**
* @dev perform a generic call to an arbitrary contract
* @param _contract the contract's address to call
* @param _data ABI-encoded contract call to call `_contract` address.
* @param _avatar the controller's avatar address
* @param _value value (ETH) to transfer with the transaction
* @return bool -success
* bytes - the return value of the called _contract's function.
*/
function genericCall(address _contract, bytes calldata _data, Avatar _avatar, uint256 _value)
external
returns(bool, bytes memory);
/**
* @dev send some ether
* @param _amountInWei the amount of ether (in Wei) to send
* @param _to address of the beneficiary
* @param _avatar address
* @return bool which represents a success
*/
function sendEther(uint256 _amountInWei, address payable _to, Avatar _avatar)
external returns(bool);
/**
* @dev send some amount of arbitrary ERC20 Tokens
* @param _externalToken the address of the Token Contract
* @param _to address of the beneficiary
* @param _value the amount of ether (in Wei) to send
* @param _avatar address
* @return bool which represents a success
*/
function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value, Avatar _avatar)
external
returns(bool);
/**
* @dev transfer token "from" address "to" address
* One must to approve the amount of tokens which can be spend from the
* "from" account.This can be done using externalTokenApprove.
* @param _externalToken the address of the Token Contract
* @param _from address of the account to send from
* @param _to address of the beneficiary
* @param _value the amount of ether (in Wei) to send
* @param _avatar address
* @return bool which represents a success
*/
function externalTokenTransferFrom(
IERC20 _externalToken,
address _from,
address _to,
uint256 _value,
Avatar _avatar)
external
returns(bool);
/**
* @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
* on behalf of msg.sender.
* @param _externalToken the address of the Token Contract
* @param _spender address
* @param _value the amount of ether (in Wei) which the approval is referring to.
* @return bool which represents a success
*/
function externalTokenApproval(IERC20 _externalToken, address _spender, uint256 _value, Avatar _avatar)
external
returns(bool);
/**
* @dev metaData emits an event with a string, should contain the hash of some meta data.
* @param _metaData a string representing a hash of the meta data
* @param _avatar Avatar
* @return bool which represents a success
*/
function metaData(string calldata _metaData, Avatar _avatar) external returns(bool);
/**
* @dev getNativeReputation
* @param _avatar the organization avatar.
* @return organization native reputation
*/
function getNativeReputation(address _avatar)
external
view
returns(address);
function isSchemeRegistered( address _scheme, address _avatar) external view returns(bool);
function getSchemeParameters(address _scheme, address _avatar) external view returns(bytes32);
function getGlobalConstraintParameters(address _globalConstraint, address _avatar) external view returns(bytes32);
function getSchemePermissions(address _scheme, address _avatar) external view returns(bytes4);
/**
* @dev globalConstraintsCount return the global constraint pre and post count
* @return uint256 globalConstraintsPre count.
* @return uint256 globalConstraintsPost count.
*/
function globalConstraintsCount(address _avatar) external view returns(uint, uint);
function isGlobalConstraintRegistered(address _globalConstraint, address _avatar) external view returns(bool);
}
// File: @daostack/arc/contracts/controller/Controller.sol
/**
* @title Controller contract
* @dev A controller controls the organizations tokens, reputation and avatar.
* It is subject to a set of schemes and constraints that determine its behavior.
* Each scheme has it own parameters and operation permissions.
*/
contract Controller is ControllerInterface {
struct Scheme {
bytes32 paramsHash; // a hash "configuration" of the scheme
bytes4 permissions; // A bitwise flags of permissions,
// All 0: Not registered,
// 1st bit: Flag if the scheme is registered,
// 2nd bit: Scheme can register other schemes
// 3rd bit: Scheme can add/remove global constraints
// 4th bit: Scheme can upgrade the controller
// 5th bit: Scheme can call genericCall on behalf of
// the organization avatar
}
struct GlobalConstraint {
address gcAddress;
bytes32 params;
}
struct GlobalConstraintRegister {
bool isRegistered; //is registered
uint256 index; //index at globalConstraints
}
mapping(address=>Scheme) public schemes;
Avatar public avatar;
DAOToken public nativeToken;
Reputation public nativeReputation;
// newController will point to the new controller after the present controller is upgraded
address public newController;
// globalConstraintsPre that determine pre conditions for all actions on the controller
GlobalConstraint[] public globalConstraintsPre;
// globalConstraintsPost that determine post conditions for all actions on the controller
GlobalConstraint[] public globalConstraintsPost;
// globalConstraintsRegisterPre indicate if a globalConstraints is registered as a pre global constraint
mapping(address=>GlobalConstraintRegister) public globalConstraintsRegisterPre;
// globalConstraintsRegisterPost indicate if a globalConstraints is registered as a post global constraint
mapping(address=>GlobalConstraintRegister) public globalConstraintsRegisterPost;
event MintReputation (address indexed _sender, address indexed _to, uint256 _amount);
event BurnReputation (address indexed _sender, address indexed _from, uint256 _amount);
event MintTokens (address indexed _sender, address indexed _beneficiary, uint256 _amount);
event RegisterScheme (address indexed _sender, address indexed _scheme);
event UnregisterScheme (address indexed _sender, address indexed _scheme);
event UpgradeController(address indexed _oldController, address _newController);
event AddGlobalConstraint(
address indexed _globalConstraint,
bytes32 _params,
GlobalConstraintInterface.CallPhase _when);
event RemoveGlobalConstraint(address indexed _globalConstraint, uint256 _index, bool _isPre);
constructor( Avatar _avatar) public {
avatar = _avatar;
nativeToken = avatar.nativeToken();
nativeReputation = avatar.nativeReputation();
schemes[msg.sender] = Scheme({paramsHash: bytes32(0), permissions: bytes4(0x0000001F)});
}
// Do not allow mistaken calls:
// solhint-disable-next-line payable-fallback
function() external {
revert();
}
// Modifiers:
modifier onlyRegisteredScheme() {
require(schemes[msg.sender].permissions&bytes4(0x00000001) == bytes4(0x00000001));
_;
}
modifier onlyRegisteringSchemes() {
require(schemes[msg.sender].permissions&bytes4(0x00000002) == bytes4(0x00000002));
_;
}
modifier onlyGlobalConstraintsScheme() {
require(schemes[msg.sender].permissions&bytes4(0x00000004) == bytes4(0x00000004));
_;
}
modifier onlyUpgradingScheme() {
require(schemes[msg.sender].permissions&bytes4(0x00000008) == bytes4(0x00000008));
_;
}
modifier onlyGenericCallScheme() {
require(schemes[msg.sender].permissions&bytes4(0x00000010) == bytes4(0x00000010));
_;
}
modifier onlyMetaDataScheme() {
require(schemes[msg.sender].permissions&bytes4(0x00000010) == bytes4(0x00000010));
_;
}
modifier onlySubjectToConstraint(bytes32 func) {
uint256 idx;
for (idx = 0; idx < globalConstraintsPre.length; idx++) {
require(
(GlobalConstraintInterface(globalConstraintsPre[idx].gcAddress))
.pre(msg.sender, globalConstraintsPre[idx].params, func));
}
_;
for (idx = 0; idx < globalConstraintsPost.length; idx++) {
require(
(GlobalConstraintInterface(globalConstraintsPost[idx].gcAddress))
.post(msg.sender, globalConstraintsPost[idx].params, func));
}
}
modifier isAvatarValid(address _avatar) {
require(_avatar == address(avatar));
_;
}
/**
* @dev Mint `_amount` of reputation that are assigned to `_to` .
* @param _amount amount of reputation to mint
* @param _to beneficiary address
* @return bool which represents a success
*/
function mintReputation(uint256 _amount, address _to, address _avatar)
external
onlyRegisteredScheme
onlySubjectToConstraint("mintReputation")
isAvatarValid(_avatar)
returns(bool)
{
emit MintReputation(msg.sender, _to, _amount);
return nativeReputation.mint(_to, _amount);
}
/**
* @dev Burns `_amount` of reputation from `_from`
* @param _amount amount of reputation to burn
* @param _from The address that will lose the reputation
* @return bool which represents a success
*/
function burnReputation(uint256 _amount, address _from, address _avatar)
external
onlyRegisteredScheme
onlySubjectToConstraint("burnReputation")
isAvatarValid(_avatar)
returns(bool)
{
emit BurnReputation(msg.sender, _from, _amount);
return nativeReputation.burn(_from, _amount);
}
/**
* @dev mint tokens .
* @param _amount amount of token to mint
* @param _beneficiary beneficiary address
* @return bool which represents a success
*/
function mintTokens(uint256 _amount, address _beneficiary, address _avatar)
external
onlyRegisteredScheme
onlySubjectToConstraint("mintTokens")
isAvatarValid(_avatar)
returns(bool)
{
emit MintTokens(msg.sender, _beneficiary, _amount);
return nativeToken.mint(_beneficiary, _amount);
}
/**
* @dev register a scheme
* @param _scheme the address of the scheme
* @param _paramsHash a hashed configuration of the usage of the scheme
* @param _permissions the permissions the new scheme will have
* @return bool which represents a success
*/
function registerScheme(address _scheme, bytes32 _paramsHash, bytes4 _permissions, address _avatar)
external
onlyRegisteringSchemes
onlySubjectToConstraint("registerScheme")
isAvatarValid(_avatar)
returns(bool)
{
Scheme memory scheme = schemes[_scheme];
// Check scheme has at least the permissions it is changing, and at least the current permissions:
// Implementation is a bit messy. One must recall logic-circuits ^^
// produces non-zero if sender does not have all of the perms that are changing between old and new
require(bytes4(0x0000001f)&(_permissions^scheme.permissions)&(~schemes[msg.sender].permissions) == bytes4(0));
// produces non-zero if sender does not have all of the perms in the old scheme
require(bytes4(0x0000001f)&(scheme.permissions&(~schemes[msg.sender].permissions)) == bytes4(0));
// Add or change the scheme:
schemes[_scheme].paramsHash = _paramsHash;
schemes[_scheme].permissions = _permissions|bytes4(0x00000001);
emit RegisterScheme(msg.sender, _scheme);
return true;
}
/**
* @dev unregister a scheme
* @param _scheme the address of the scheme
* @return bool which represents a success
*/
function unregisterScheme( address _scheme, address _avatar)
external
onlyRegisteringSchemes
onlySubjectToConstraint("unregisterScheme")
isAvatarValid(_avatar)
returns(bool)
{
//check if the scheme is registered
if (_isSchemeRegistered(_scheme) == false) {
return false;
}
// Check the unregistering scheme has enough permissions:
require(bytes4(0x0000001f)&(schemes[_scheme].permissions&(~schemes[msg.sender].permissions)) == bytes4(0));
// Unregister:
emit UnregisterScheme(msg.sender, _scheme);
delete schemes[_scheme];
return true;
}
/**
* @dev unregister the caller's scheme
* @return bool which represents a success
*/
function unregisterSelf(address _avatar) external isAvatarValid(_avatar) returns(bool) {
if (_isSchemeRegistered(msg.sender) == false) {
return false;
}
delete schemes[msg.sender];
emit UnregisterScheme(msg.sender, msg.sender);
return true;
}
/**
* @dev add or update Global Constraint
* @param _globalConstraint the address of the global constraint to be added.
* @param _params the constraint parameters hash.
* @return bool which represents a success
*/
function addGlobalConstraint(address _globalConstraint, bytes32 _params, address _avatar)
external
onlyGlobalConstraintsScheme
isAvatarValid(_avatar)
returns(bool)
{
GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(_globalConstraint).when();
if ((when == GlobalConstraintInterface.CallPhase.Pre)||
(when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
if (!globalConstraintsRegisterPre[_globalConstraint].isRegistered) {
globalConstraintsPre.push(GlobalConstraint(_globalConstraint, _params));
globalConstraintsRegisterPre[_globalConstraint] =
GlobalConstraintRegister(true, globalConstraintsPre.length-1);
}else {
globalConstraintsPre[globalConstraintsRegisterPre[_globalConstraint].index].params = _params;
}
}
if ((when == GlobalConstraintInterface.CallPhase.Post)||
(when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
if (!globalConstraintsRegisterPost[_globalConstraint].isRegistered) {
globalConstraintsPost.push(GlobalConstraint(_globalConstraint, _params));
globalConstraintsRegisterPost[_globalConstraint] =
GlobalConstraintRegister(true, globalConstraintsPost.length-1);
}else {
globalConstraintsPost[globalConstraintsRegisterPost[_globalConstraint].index].params = _params;
}
}
emit AddGlobalConstraint(_globalConstraint, _params, when);
return true;
}
/**
* @dev remove Global Constraint
* @param _globalConstraint the address of the global constraint to be remove.
* @return bool which represents a success
*/
// solhint-disable-next-line code-complexity
function removeGlobalConstraint (address _globalConstraint, address _avatar)
external
onlyGlobalConstraintsScheme
isAvatarValid(_avatar)
returns(bool)
{
GlobalConstraintRegister memory globalConstraintRegister;
GlobalConstraint memory globalConstraint;
GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(_globalConstraint).when();
bool retVal = false;
if ((when == GlobalConstraintInterface.CallPhase.Pre)||
(when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
globalConstraintRegister = globalConstraintsRegisterPre[_globalConstraint];
if (globalConstraintRegister.isRegistered) {
if (globalConstraintRegister.index < globalConstraintsPre.length-1) {
globalConstraint = globalConstraintsPre[globalConstraintsPre.length-1];
globalConstraintsPre[globalConstraintRegister.index] = globalConstraint;
globalConstraintsRegisterPre[globalConstraint.gcAddress].index = globalConstraintRegister.index;
}
globalConstraintsPre.length--;
delete globalConstraintsRegisterPre[_globalConstraint];
retVal = true;
}
}
if ((when == GlobalConstraintInterface.CallPhase.Post)||
(when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
globalConstraintRegister = globalConstraintsRegisterPost[_globalConstraint];
if (globalConstraintRegister.isRegistered) {
if (globalConstraintRegister.index < globalConstraintsPost.length-1) {
globalConstraint = globalConstraintsPost[globalConstraintsPost.length-1];
globalConstraintsPost[globalConstraintRegister.index] = globalConstraint;
globalConstraintsRegisterPost[globalConstraint.gcAddress].index = globalConstraintRegister.index;
}
globalConstraintsPost.length--;
delete globalConstraintsRegisterPost[_globalConstraint];
retVal = true;
}
}
if (retVal) {
emit RemoveGlobalConstraint(
_globalConstraint,
globalConstraintRegister.index,
when == GlobalConstraintInterface.CallPhase.Pre
);
}
return retVal;
}
/**
* @dev upgrade the Controller
* The function will trigger an event 'UpgradeController'.
* @param _newController the address of the new controller.
* @return bool which represents a success
*/
function upgradeController(address _newController, Avatar _avatar)
external
onlyUpgradingScheme
isAvatarValid(address(_avatar))
returns(bool)
{
require(newController == address(0)); // so the upgrade could be done once for a contract.
require(_newController != address(0));
newController = _newController;
avatar.transferOwnership(_newController);
require(avatar.owner() == _newController);
if (nativeToken.owner() == address(this)) {
nativeToken.transferOwnership(_newController);
require(nativeToken.owner() == _newController);
}
if (nativeReputation.owner() == address(this)) {
nativeReputation.transferOwnership(_newController);
require(nativeReputation.owner() == _newController);
}
emit UpgradeController(address(this), newController);
return true;
}
/**
* @dev perform a generic call to an arbitrary contract
* @param _contract the contract's address to call
* @param _data ABI-encoded contract call to call `_contract` address.
* @param _avatar the controller's avatar address
* @param _value value (ETH) to transfer with the transaction
* @return bool -success
* bytes - the return value of the called _contract's function.
*/
function genericCall(address _contract, bytes calldata _data, Avatar _avatar, uint256 _value)
external
onlyGenericCallScheme
onlySubjectToConstraint("genericCall")
isAvatarValid(address(_avatar))
returns (bool, bytes memory)
{
return avatar.genericCall(_contract, _data, _value);
}
/**
* @dev send some ether
* @param _amountInWei the amount of ether (in Wei) to send
* @param _to address of the beneficiary
* @return bool which represents a success
*/
function sendEther(uint256 _amountInWei, address payable _to, Avatar _avatar)
external
onlyRegisteredScheme
onlySubjectToConstraint("sendEther")
isAvatarValid(address(_avatar))
returns(bool)
{
return avatar.sendEther(_amountInWei, _to);
}
/**
* @dev send some amount of arbitrary ERC20 Tokens
* @param _externalToken the address of the Token Contract
* @param _to address of the beneficiary
* @param _value the amount of ether (in Wei) to send
* @return bool which represents a success
*/
function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value, Avatar _avatar)
external
onlyRegisteredScheme
onlySubjectToConstraint("externalTokenTransfer")
isAvatarValid(address(_avatar))
returns(bool)
{
return avatar.externalTokenTransfer(_externalToken, _to, _value);
}
/**
* @dev transfer token "from" address "to" address
* One must to approve the amount of tokens which can be spend from the
* "from" account.This can be done using externalTokenApprove.
* @param _externalToken the address of the Token Contract
* @param _from address of the account to send from
* @param _to address of the beneficiary
* @param _value the amount of ether (in Wei) to send
* @return bool which represents a success
*/
function externalTokenTransferFrom(
IERC20 _externalToken,
address _from,
address _to,
uint256 _value,
Avatar _avatar)
external
onlyRegisteredScheme
onlySubjectToConstraint("externalTokenTransferFrom")
isAvatarValid(address(_avatar))
returns(bool)
{
return avatar.externalTokenTransferFrom(_externalToken, _from, _to, _value);
}
/**
* @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
* on behalf of msg.sender.
* @param _externalToken the address of the Token Contract
* @param _spender address
* @param _value the amount of ether (in Wei) which the approval is referring to.
* @return bool which represents a success
*/
function externalTokenApproval(IERC20 _externalToken, address _spender, uint256 _value, Avatar _avatar)
external
onlyRegisteredScheme
onlySubjectToConstraint("externalTokenIncreaseApproval")
isAvatarValid(address(_avatar))
returns(bool)
{
return avatar.externalTokenApproval(_externalToken, _spender, _value);
}
/**
* @dev metaData emits an event with a string, should contain the hash of some meta data.
* @param _metaData a string representing a hash of the meta data
* @param _avatar Avatar
* @return bool which represents a success
*/
function metaData(string calldata _metaData, Avatar _avatar)
external
onlyMetaDataScheme
isAvatarValid(address(_avatar))
returns(bool)
{
return avatar.metaData(_metaData);
}
/**
* @dev getNativeReputation
* @param _avatar the organization avatar.
* @return organization native reputation
*/
function getNativeReputation(address _avatar) external isAvatarValid(_avatar) view returns(address) {
return address(nativeReputation);
}
function isSchemeRegistered(address _scheme, address _avatar) external isAvatarValid(_avatar) view returns(bool) {
return _isSchemeRegistered(_scheme);
}
function getSchemeParameters(address _scheme, address _avatar)
external
isAvatarValid(_avatar)
view
returns(bytes32)
{
return schemes[_scheme].paramsHash;
}
function getSchemePermissions(address _scheme, address _avatar)
external
isAvatarValid(_avatar)
view
returns(bytes4)
{
return schemes[_scheme].permissions;
}
function getGlobalConstraintParameters(address _globalConstraint, address) external view returns(bytes32) {
GlobalConstraintRegister memory register = globalConstraintsRegisterPre[_globalConstraint];
if (register.isRegistered) {
return globalConstraintsPre[register.index].params;
}
register = globalConstraintsRegisterPost[_globalConstraint];
if (register.isRegistered) {
return globalConstraintsPost[register.index].params;
}
}
/**
* @dev globalConstraintsCount return the global constraint pre and post count
* @return uint256 globalConstraintsPre count.
* @return uint256 globalConstraintsPost count.
*/
function globalConstraintsCount(address _avatar)
external
isAvatarValid(_avatar)
view
returns(uint, uint)
{
return (globalConstraintsPre.length, globalConstraintsPost.length);
}
function isGlobalConstraintRegistered(address _globalConstraint, address _avatar)
external
isAvatarValid(_avatar)
view
returns(bool)
{
return (globalConstraintsRegisterPre[_globalConstraint].isRegistered ||
globalConstraintsRegisterPost[_globalConstraint].isRegistered);
}
function _isSchemeRegistered(address _scheme) private view returns(bool) {
return (schemes[_scheme].permissions&bytes4(0x00000001) != bytes4(0));
}
}

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"address","name":"_avatar","internalType":"contract Avatar"}]},{"type":"event","name":"AddGlobalConstraint","inputs":[{"type":"address","name":"_globalConstraint","internalType":"address","indexed":true},{"type":"bytes32","name":"_params","internalType":"bytes32","indexed":false},{"type":"uint8","name":"_when","internalType":"enum GlobalConstraintInterface.CallPhase","indexed":false}],"anonymous":false},{"type":"event","name":"BurnReputation","inputs":[{"type":"address","name":"_sender","internalType":"address","indexed":true},{"type":"address","name":"_from","internalType":"address","indexed":true},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MintReputation","inputs":[{"type":"address","name":"_sender","internalType":"address","indexed":true},{"type":"address","name":"_to","internalType":"address","indexed":true},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MintTokens","inputs":[{"type":"address","name":"_sender","internalType":"address","indexed":true},{"type":"address","name":"_beneficiary","internalType":"address","indexed":true},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RegisterScheme","inputs":[{"type":"address","name":"_sender","internalType":"address","indexed":true},{"type":"address","name":"_scheme","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RemoveGlobalConstraint","inputs":[{"type":"address","name":"_globalConstraint","internalType":"address","indexed":true},{"type":"uint256","name":"_index","internalType":"uint256","indexed":false},{"type":"bool","name":"_isPre","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"UnregisterScheme","inputs":[{"type":"address","name":"_sender","internalType":"address","indexed":true},{"type":"address","name":"_scheme","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"UpgradeController","inputs":[{"type":"address","name":"_oldController","internalType":"address","indexed":true},{"type":"address","name":"_newController","internalType":"address","indexed":false}],"anonymous":false},{"type":"fallback","stateMutability":"nonpayable","payable":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"addGlobalConstraint","inputs":[{"type":"address","name":"_globalConstraint","internalType":"address"},{"type":"bytes32","name":"_params","internalType":"bytes32"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract Avatar"}],"name":"avatar","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"burnReputation","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_from","internalType":"address"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"externalTokenApproval","inputs":[{"type":"address","name":"_externalToken","internalType":"contract IERC20"},{"type":"address","name":"_spender","internalType":"address"},{"type":"uint256","name":"_value","internalType":"uint256"},{"type":"address","name":"_avatar","internalType":"contract Avatar"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"externalTokenTransfer","inputs":[{"type":"address","name":"_externalToken","internalType":"contract IERC20"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_value","internalType":"uint256"},{"type":"address","name":"_avatar","internalType":"contract Avatar"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"externalTokenTransferFrom","inputs":[{"type":"address","name":"_externalToken","internalType":"contract IERC20"},{"type":"address","name":"_from","internalType":"address"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_value","internalType":"uint256"},{"type":"address","name":"_avatar","internalType":"contract Avatar"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"},{"type":"bytes","name":"","internalType":"bytes"}],"name":"genericCall","inputs":[{"type":"address","name":"_contract","internalType":"address"},{"type":"bytes","name":"_data","internalType":"bytes"},{"type":"address","name":"_avatar","internalType":"contract Avatar"},{"type":"uint256","name":"_value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getGlobalConstraintParameters","inputs":[{"type":"address","name":"_globalConstraint","internalType":"address"},{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getNativeReputation","inputs":[{"type":"address","name":"_avatar","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getSchemeParameters","inputs":[{"type":"address","name":"_scheme","internalType":"address"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"getSchemePermissions","inputs":[{"type":"address","name":"_scheme","internalType":"address"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"globalConstraintsCount","inputs":[{"type":"address","name":"_avatar","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"gcAddress","internalType":"address"},{"type":"bytes32","name":"params","internalType":"bytes32"}],"name":"globalConstraintsPost","inputs":[{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"gcAddress","internalType":"address"},{"type":"bytes32","name":"params","internalType":"bytes32"}],"name":"globalConstraintsPre","inputs":[{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"isRegistered","internalType":"bool"},{"type":"uint256","name":"index","internalType":"uint256"}],"name":"globalConstraintsRegisterPost","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"isRegistered","internalType":"bool"},{"type":"uint256","name":"index","internalType":"uint256"}],"name":"globalConstraintsRegisterPre","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isGlobalConstraintRegistered","inputs":[{"type":"address","name":"_globalConstraint","internalType":"address"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isSchemeRegistered","inputs":[{"type":"address","name":"_scheme","internalType":"address"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"metaData","inputs":[{"type":"string","name":"_metaData","internalType":"string"},{"type":"address","name":"_avatar","internalType":"contract Avatar"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"mintReputation","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_to","internalType":"address"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"mintTokens","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_beneficiary","internalType":"address"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract Reputation"}],"name":"nativeReputation","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract DAOToken"}],"name":"nativeToken","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"newController","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"registerScheme","inputs":[{"type":"address","name":"_scheme","internalType":"address"},{"type":"bytes32","name":"_paramsHash","internalType":"bytes32"},{"type":"bytes4","name":"_permissions","internalType":"bytes4"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"removeGlobalConstraint","inputs":[{"type":"address","name":"_globalConstraint","internalType":"address"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"paramsHash","internalType":"bytes32"},{"type":"bytes4","name":"permissions","internalType":"bytes4"}],"name":"schemes","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"sendEther","inputs":[{"type":"uint256","name":"_amountInWei","internalType":"uint256"},{"type":"address","name":"_to","internalType":"address payable"},{"type":"address","name":"_avatar","internalType":"contract Avatar"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"unregisterScheme","inputs":[{"type":"address","name":"_scheme","internalType":"address"},{"type":"address","name":"_avatar","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"unregisterSelf","inputs":[{"type":"address","name":"_avatar","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"upgradeController","inputs":[{"type":"address","name":"_newController","internalType":"address"},{"type":"address","name":"_avatar","internalType":"contract Avatar"}],"constant":false}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101e55760003560e01c806389ae1c901161010f578063e08738da116100a2578063e8c98b2211610071578063e8c98b221461083e578063eaf994b21461085b578063f76488be1461088f578063fb4856a2146108bd576101e5565b8063e08738da1461078e578063e1758bd8146107bc578063e4537a74146107c4578063e869d45f146107fa576101e5565b8063b9a04cdd116100de578063b9a04cdd1461057f578063c9b62eb1146105bb578063d1b7089a14610634578063db6149ce14610746576101e5565b806389ae1c90146104d85780638da03997146104e05780639b51e35a146105065780639be2faed14610551576101e5565b806351803cd8116101875780636c525b13116101565780636c525b13146104195780636e94d2781461043f578063814784f614610473578063824f2f1f14610499576101e5565b806351803cd81461036d5780635aef7de6146103a9578063634965da146103b15780636407e432146103e5576101e5565b80633a02263c116101c35780633a02263c146102ad57806342427bf8146102d15780634422d372146102ff5780634f52b5be1461033f576101e5565b8063039de01d146101ea578063177eebb01461022c5780631c4d56081461026d575b600080fd5b6102186004803603604081101561020057600080fd5b506001600160a01b0381358116916020013516610903565b604080519115158252519081900360200190f35b6102526004803603602081101561024257600080fd5b50356001600160a01b0316610c09565b60408051921515835260208301919091528051918290030190f35b61029b6004803603604081101561028357600080fd5b506001600160a01b0381358116916020013516610c28565b60408051918252519081900360200190f35b6102b5610c6a565b604080516001600160a01b039092168252519081900360200190f35b610218600480360360408110156102e757600080fd5b506001600160a01b0381358116916020013516610c79565b61031c6004803603602081101561031557600080fd5b503561113b565b604080516001600160a01b03909316835260208301919091528051918290030190f35b6102186004803603604081101561035557600080fd5b506001600160a01b0381358116916020013516611170565b6102186004803603608081101561038357600080fd5b506001600160a01b0381358116916020810135821691604082013591606001351661156b565b6102b561184f565b610218600480360360608110156103c757600080fd5b508035906001600160a01b036020820135811691604001351661185e565b610218600480360360608110156103fb57600080fd5b508035906001600160a01b0360208201358116916040013516611b25565b6102186004803603602081101561042f57600080fd5b50356001600160a01b0316611e24565b6102186004803603606081101561045557600080fd5b508035906001600160a01b0360208201358116916040013516611eab565b6102526004803603602081101561048957600080fd5b50356001600160a01b03166121ae565b6104bf600480360360208110156104af57600080fd5b50356001600160a01b03166121cd565b6040805192835260208301919091528051918290030190f35b6102b56121ff565b6102b5600480360360208110156104f657600080fd5b50356001600160a01b031661220e565b6105346004803603604081101561051c57600080fd5b506001600160a01b0381358116916020013516612240565b604080516001600160e01b03199092168252519081900360200190f35b6102186004803603604081101561056757600080fd5b506001600160a01b0381358116916020013516612283565b6102186004803603608081101561059557600080fd5b506001600160a01b038135811691602081013582169160408201359160600135166122b3565b610218600480360360408110156105d157600080fd5b8101906020810181356401000000008111156105ec57600080fd5b8201836020820111156105fe57600080fd5b8035906020019184600183028401116401000000008311171561062057600080fd5b9193509150356001600160a01b0316612585565b6106c36004803603608081101561064a57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561067557600080fd5b82018360208201111561068757600080fd5b803590602001918460018302840111640100000000831117156106a957600080fd5b91935091506001600160a01b038135169060200135612675565b604051808315151515815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561070a5781810151838201526020016106f2565b50505050905090810190601f1680156107375780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b61076c6004803603602081101561075c57600080fd5b50356001600160a01b0316612a46565b604080519283526001600160e01b031990911660208301528051918290030190f35b61029b600480360360408110156107a457600080fd5b506001600160a01b0381358116916020013516612a62565b6102b5612b2e565b610218600480360360608110156107da57600080fd5b506001600160a01b03813581169160208101359160409091013516612b3d565b6102186004803603608081101561081057600080fd5b506001600160a01b0381358116916020810135916001600160e01b0319604083013516916060013516612f09565b61031c6004803603602081101561085457600080fd5b5035613246565b6102186004803603606081101561087157600080fd5b508035906001600160a01b0360208201358116916040013516613253565b610218600480360360408110156108a557600080fd5b506001600160a01b0381358116916020013516613556565b610218600480360360a08110156108d357600080fd5b506001600160a01b03813581169160208101358216916040820135811691606081013591608090910135166135b8565b3360009081526020819052604081206001015460e01b600160e11b9081161461092b57600080fd5b6f756e7265676973746572536368656d6560801b60005b600554811015610a32576005818154811061095957fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab29133918590811061098c57fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b1580156109f557600080fd5b505af1158015610a09573d6000803e3d6000fd5b505050506040513d6020811015610a1f57600080fd5b5051610a2a57600080fd5b600101610942565b60015484906001600160a01b03808316911614610a4e57600080fd5b610a57866138a5565b610a645760009350610b0b565b336000908152602081905260408082206001908101546001600160a01b038a168452919092209091015460e091821b19911b16601f60e01b1615610aa757600080fd5b6040516001600160a01b0387169033907f10bb2cf04cb8b902a8e736d494f1a51003be6d4b16ef6fb95ce62c38445023bf90600090a36001600160a01b03861660009081526020819052604081209081556001908101805463ffffffff1916905593505b50600090505b600654811015610c015760068181548110610b2857fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d91339185908110610b5b57fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b158015610bc457600080fd5b505af1158015610bd8573d6000803e3d6000fd5b505050506040513d6020811015610bee57600080fd5b5051610bf957600080fd5b600101610b11565b505092915050565b6007602052600090815260409020805460019091015460ff9091169082565b60015460009082906001600160a01b03808316911614610c4757600080fd5b6001600160a01b03841660009081526020819052604090205491505b5092915050565b6004546001600160a01b031681565b3360009081526020819052604081206001015460e01b600160e31b90811614610ca157600080fd5b60015482906001600160a01b03808316911614610cbd57600080fd5b6004546001600160a01b031615610cd357600080fd5b6001600160a01b038416610ce657600080fd5b600480546001600160a01b0319166001600160a01b0386811691821783556001546040805163f2fde38b60e01b815294850193909352915191169163f2fde38b91602480830192600092919082900301818387803b158015610d4757600080fd5b505af1158015610d5b573d6000803e3d6000fd5b50505050836001600160a01b0316600160009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610db757600080fd5b505afa158015610dcb573d6000803e3d6000fd5b505050506040513d6020811015610de157600080fd5b50516001600160a01b031614610df657600080fd5b60025460408051638da5cb5b60e01b8152905130926001600160a01b031691638da5cb5b916004808301926020929190829003018186803b158015610e3a57600080fd5b505afa158015610e4e573d6000803e3d6000fd5b505050506040513d6020811015610e6457600080fd5b50516001600160a01b03161415610f72576002546040805163f2fde38b60e01b81526001600160a01b0387811660048301529151919092169163f2fde38b91602480830192600092919082900301818387803b158015610ec357600080fd5b505af1158015610ed7573d6000803e3d6000fd5b50505050836001600160a01b0316600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f3357600080fd5b505afa158015610f47573d6000803e3d6000fd5b505050506040513d6020811015610f5d57600080fd5b50516001600160a01b031614610f7257600080fd5b60035460408051638da5cb5b60e01b8152905130926001600160a01b031691638da5cb5b916004808301926020929190829003018186803b158015610fb657600080fd5b505afa158015610fca573d6000803e3d6000fd5b505050506040513d6020811015610fe057600080fd5b50516001600160a01b031614156110ee576003546040805163f2fde38b60e01b81526001600160a01b0387811660048301529151919092169163f2fde38b91602480830192600092919082900301818387803b15801561103f57600080fd5b505af1158015611053573d6000803e3d6000fd5b50505050836001600160a01b0316600360009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110af57600080fd5b505afa1580156110c3573d6000803e3d6000fd5b505050506040513d60208110156110d957600080fd5b50516001600160a01b0316146110ee57600080fd5b600454604080516001600160a01b039290921682525130917fdb7cbacf8df312d794506c0cc9af07f64d29ca075796ea2e950a3832cc9a63dd919081900360200190a25060019392505050565b6005818154811061114857fe5b6000918252602090912060029091020180546001909101546001600160a01b03909116915082565b3360009081526020819052604081206001015460e01b600160e21b9081161461119857600080fd5b60015482906001600160a01b038083169116146111b457600080fd5b6111bc6138d1565b6111c46138d1565b6000866001600160a01b031663e2b0caef6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561120157600080fd5b505af1158015611215573d6000803e3d6000fd5b505050506040513d602081101561122b57600080fd5b5051905060008082600281111561123e57fe5b14806112555750600282600281111561125357fe5b145b15611399576001600160a01b0388166000908152600760209081526040918290208251808401909352805460ff16158015845260019091015491830191909152909450611399576001600580549050038460200151101561135a576005805460001981019081106112c257fe5b60009182526020918290206040805180820190915260029092020180546001600160a01b03168252600101548183015290850151600580549295508592909190811061130a57fe5b6000918252602080832084516002939093020180546001600160a01b0319166001600160a01b03938416178155938101516001948501558781015187519092168352600790526040909120909101555b600580549061136d9060001983016138e8565b50506001600160a01b0387166000908152600760205260408120805460ff191681556001908101919091555b60018260028111156113a757fe5b14806113be575060028260028111156113bc57fe5b145b15611502576001600160a01b0388166000908152600860209081526040918290208251808401909352805460ff1615801584526001909101549183019190915290945061150257600160068054905003846020015110156114c35760068054600019810190811061142b57fe5b60009182526020918290206040805180820190915260029092020180546001600160a01b03168252600101548183015290850151600680549295508592909190811061147357fe5b6000918252602080832084516002939093020180546001600160a01b0319166001600160a01b03938416178155938101516001948501558781015187519092168352600890526040909120909101555b60068054906114d69060001983016138e8565b50506001600160a01b0387166000908152600860205260408120805460ff191681556001908101919091555b80156115605760208401516001600160a01b038916907fcdf1a50ea6b7de555bd409f8a4a53ea43c6dc6b4caa961889da9e005f21bbaa990600085600281111561154857fe5b60408051938452911460208301528051918290030190a25b979650505050505050565b3360009081526020819052604081206001015460e01b600160e01b9081161461159357600080fd5b7f65787465726e616c546f6b656e496e637265617365417070726f76616c00000060005b6005548110156116a757600581815481106115ce57fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab29133918590811061160157fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561166a57600080fd5b505af115801561167e573d6000803e3d6000fd5b505050506040513d602081101561169457600080fd5b505161169f57600080fd5b6001016115b7565b60015484906001600160a01b038083169116146116c357600080fd5b6001546040805163ab751f7160e01b81526001600160a01b038b811660048301528a81166024830152604482018a90529151919092169163ab751f719160648083019260209291908290030181600087803b15801561172157600080fd5b505af1158015611735573d6000803e3d6000fd5b505050506040513d602081101561174b57600080fd5b5051935050600090505b600654811015611845576006818154811061176c57fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d9133918590811061179f57fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561180857600080fd5b505af115801561181c573d6000803e3d6000fd5b505050506040513d602081101561183257600080fd5b505161183d57600080fd5b600101611755565b5050949350505050565b6001546001600160a01b031681565b3360009081526020819052604081206001015460e01b600160e01b9081161461188657600080fd5b6839b2b73222ba3432b960b91b60005b60055481101561198657600581815481106118ad57fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab2913391859081106118e057fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561194957600080fd5b505af115801561195d573d6000803e3d6000fd5b505050506040513d602081101561197357600080fd5b505161197e57600080fd5b600101611896565b60015484906001600160a01b038083169116146119a257600080fd5b6001546040805163658b6a5160e11b8152600481018a90526001600160a01b0389811660248301529151919092169163cb16d4a29160448083019260209291908290030181600087803b1580156119f857600080fd5b505af1158015611a0c573d6000803e3d6000fd5b505050506040513d6020811015611a2257600080fd5b5051935050600090505b600654811015611b1c5760068181548110611a4357fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d91339185908110611a7657fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b158015611adf57600080fd5b505af1158015611af3573d6000803e3d6000fd5b505050506040513d6020811015611b0957600080fd5b5051611b1457600080fd5b600101611a2c565b50509392505050565b3360009081526020819052604081206001015460e01b600160e01b90811614611b4d57600080fd5b696d696e74546f6b656e7360b01b60005b600554811015611c4e5760058181548110611b7557fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab291339185908110611ba857fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b158015611c1157600080fd5b505af1158015611c25573d6000803e3d6000fd5b505050506040513d6020811015611c3b57600080fd5b5051611c4657600080fd5b600101611b5e565b60015484906001600160a01b03808316911614611c6a57600080fd5b6040805188815290516001600160a01b0388169133917f21f9c9a1a1f9a311a50f15fec5c1faa9e21fc9edf964f0fdecba5bd490484c5e9181900360200190a3600254604080516340c10f1960e01b81526001600160a01b038981166004830152602482018b9052915191909216916340c10f199160448083019260209291908290030181600087803b158015611d0057600080fd5b505af1158015611d14573d6000803e3d6000fd5b505050506040513d6020811015611d2a57600080fd5b5051935050600090505b600654811015611b1c5760068181548110611d4b57fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d91339185908110611d7e57fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b158015611de757600080fd5b505af1158015611dfb573d6000803e3d6000fd5b505050506040513d6020811015611e1157600080fd5b5051611e1c57600080fd5b600101611d34565b60015460009082906001600160a01b03808316911614611e4357600080fd5b611e4c336138a5565b611e595760009150611ea5565b33600081815260208190526040808220828155600101805463ffffffff191690555182917f10bb2cf04cb8b902a8e736d494f1a51003be6d4b16ef6fb95ce62c38445023bf91a3600191505b50919050565b3360009081526020819052604081206001015460e01b600160e01b90811614611ed357600080fd5b6d313ab9372932b83aba30ba34b7b760911b60005b600554811015611fd85760058181548110611eff57fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab291339185908110611f3257fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b158015611f9b57600080fd5b505af1158015611faf573d6000803e3d6000fd5b505050506040513d6020811015611fc557600080fd5b5051611fd057600080fd5b600101611ee8565b60015484906001600160a01b03808316911614611ff457600080fd5b6040805188815290516001600160a01b0388169133917f186d8887e1b22f9d9b16849c36baa748950d09d9c9b67a4a6ea140eaad00c21c9181900360200190a360035460408051632770a7eb60e21b81526001600160a01b038981166004830152602482018b905291519190921691639dc29fac9160448083019260209291908290030181600087803b15801561208a57600080fd5b505af115801561209e573d6000803e3d6000fd5b505050506040513d60208110156120b457600080fd5b5051935050600090505b600654811015611b1c57600681815481106120d557fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d9133918590811061210857fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561217157600080fd5b505af1158015612185573d6000803e3d6000fd5b505050506040513d602081101561219b57600080fd5b50516121a657600080fd5b6001016120be565b6008602052600090815260409020805460019091015460ff9091169082565b600154600090819083906001600160a01b038083169116146121ee57600080fd5b600554600654909350915050915091565b6003546001600160a01b031681565b60015460009082906001600160a01b0380831691161461222d57600080fd5b50506003546001600160a01b0316919050565b60015460009082906001600160a01b0380831691161461225f57600080fd5b5050506001600160a01b031660009081526020819052604090206001015460e01b90565b60015460009082906001600160a01b038083169116146122a257600080fd5b6122ab846138a5565b949350505050565b3360009081526020819052604081206001015460e01b600160e01b908116146122db57600080fd5b7432bc3a32b93730b62a37b5b2b72a3930b739b332b960591b60005b6005548110156123e7576005818154811061230e57fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab29133918590811061234157fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b1580156123aa57600080fd5b505af11580156123be573d6000803e3d6000fd5b505050506040513d60208110156123d457600080fd5b50516123df57600080fd5b6001016122f7565b60015484906001600160a01b0380831691161461240357600080fd5b6001546040805163dab0efff60e01b81526001600160a01b038b811660048301528a81166024830152604482018a90529151919092169163dab0efff9160648083019260209291908290030181600087803b15801561246157600080fd5b505af1158015612475573d6000803e3d6000fd5b505050506040513d602081101561248b57600080fd5b5051935050600090505b60065481101561184557600681815481106124ac57fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d913391859081106124df57fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561254857600080fd5b505af115801561255c573d6000803e3d6000fd5b505050506040513d602081101561257257600080fd5b505161257d57600080fd5b600101612495565b3360009081526020819052604081206001015460e01b600160e41b908116146125ad57600080fd5b60015482906001600160a01b038083169116146125c957600080fd5b600154604051632242b11b60e21b8152602060048201908152602482018790526001600160a01b039092169163890ac46c91889188918190604401848480828437600081840152601f19601f8201169050808301925050509350505050602060405180830381600087803b15801561264057600080fd5b505af1158015612654573d6000803e3d6000fd5b505050506040513d602081101561266a57600080fd5b505195945050505050565b3360009081526020819052604081206001015460609060e01b600160e41b908116146126a057600080fd5b6a19d95b995c9a58d0d85b1b60aa1b60005b6005548110156127a257600581815481106126c957fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab2913391859081106126fc57fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561276557600080fd5b505af1158015612779573d6000803e3d6000fd5b505050506040513d602081101561278f57600080fd5b505161279a57600080fd5b6001016126b2565b60015486906001600160a01b038083169116146127be57600080fd5b60015460405163057e2c8b60e31b81526001600160a01b038c811660048301908152604483018a9052606060248401908152606484018d90529190931692632bf16458928e928e928e928d9290608401858580828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b15801561284c57600080fd5b505af1158015612860573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561288957600080fd5b8151602083018051604051929492938301929190846401000000008211156128b057600080fd5b9083019060208201858111156128c557600080fd5b82516401000000008111828201881017156128df57600080fd5b82525081516020918201929091019080838360005b8381101561290c5781810151838201526020016128f4565b50505050905090810190601f1680156129395780820380516001836020036101000a031916815260200191505b506040525050509450945050600090505b600654811015612a3a576006818154811061296157fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d9133918590811061299457fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b1580156129fd57600080fd5b505af1158015612a11573d6000803e3d6000fd5b505050506040513d6020811015612a2757600080fd5b5051612a3257600080fd5b60010161294a565b50509550959350505050565b6000602081905290815260409020805460019091015460e01b82565b6000612a6c6138d1565b506001600160a01b0383166000908152600760209081526040918290208251808401909352805460ff16158015845260019091015491830191909152612ad7576005816020015181548110612abd57fe5b906000526020600020906002020160010154915050612b28565b506001600160a01b0383166000908152600860209081526040918290208251808401909352805460ff16158015845260019091015491830191909152610c63576006816020015181548110612abd57fe5b92915050565b6002546001600160a01b031681565b3360009081526020819052604081206001015460e01b600160e21b90811614612b6557600080fd5b60015482906001600160a01b03808316911614612b8157600080fd5b6000856001600160a01b031663e2b0caef6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015612bbe57600080fd5b505af1158015612bd2573d6000803e3d6000fd5b505050506040513d6020811015612be857600080fd5b505190506000816002811115612bfa57fe5b1480612c1157506002816002811115612c0f57fe5b145b15612d49576001600160a01b03861660009081526007602052604090205460ff16612d08576040805180820182526001600160a01b0388811680835260208084018a81526005805460018082018355600083815297517f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0600290930292830180546001600160a01b031916919098161790965591517f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db190920191909155855180870187528481529054600019018183019081529285526007909152939092209251835460ff19169015151783559051910155612d49565b6001600160a01b038616600090815260076020526040902060010154600580548792908110612d3357fe5b9060005260206000209060020201600101819055505b6001816002811115612d5757fe5b1480612d6e57506002816002811115612d6c57fe5b145b15612ea6576001600160a01b03861660009081526008602052604090205460ff16612e65576040805180820182526001600160a01b0388811680835260208084018a81526006805460018082018355600083815297517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f600290930292830180546001600160a01b031916919098161790965591517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d4090920191909155855180870187528481529054600019018183019081529285526008909152939092209251835460ff19169015151783559051910155612ea6565b6001600160a01b038616600090815260086020526040902060010154600680548792908110612e9057fe5b9060005260206000209060020201600101819055505b856001600160a01b03167f78800d7333b8d0174a0845569e3913b7ce4a3c03ca444dd9904172fc14f2fdad868360405180838152602001826002811115612ee957fe5b60ff1681526020019250505060405180910390a250600195945050505050565b3360009081526020819052604081206001015460e01b600160e11b90811614612f3157600080fd5b6d7265676973746572536368656d6560901b60005b6005548110156130365760058181548110612f5d57fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab291339185908110612f9057fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b158015612ff957600080fd5b505af115801561300d573d6000803e3d6000fd5b505050506040513d602081101561302357600080fd5b505161302e57600080fd5b600101612f46565b60015484906001600160a01b0380831691161461305257600080fd5b61305a6138d1565b506001600160a01b03881660009081526020818152604080832081518083018352815481526001918201546001600160e01b031960e091821b16828601908152338752948690529290942001549151891891901b1916601f60e01b16156130c057600080fd5b336000908152602081815260409091206001015490820151601f60e01b60e09290921b191616156130f057600080fd5b6001600160a01b0389166000818152602081905260408082208b8155600101805463ffffffff1916600160e01b8c1760e01c1790555133917f546816e99403df442acb68ef69562682a50762c20a3fb6b472f7af9923736cfc91a3600194505050600090505b600654811015611845576006818154811061316d57fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d913391859081106131a057fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561320957600080fd5b505af115801561321d573d6000803e3d6000fd5b505050506040513d602081101561323357600080fd5b505161323e57600080fd5b600101613156565b6006818154811061114857fe5b3360009081526020819052604081206001015460e01b600160e01b9081161461327b57600080fd5b6d36b4b73a2932b83aba30ba34b7b760911b60005b60055481101561338057600581815481106132a757fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab2913391859081106132da57fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561334357600080fd5b505af1158015613357573d6000803e3d6000fd5b505050506040513d602081101561336d57600080fd5b505161337857600080fd5b600101613290565b60015484906001600160a01b0380831691161461339c57600080fd5b6040805188815290516001600160a01b0388169133917f837f2931e3df0592458212be4e470025f197feb7a8e39deb5b7f1f1d42e6f2629181900360200190a3600354604080516340c10f1960e01b81526001600160a01b038981166004830152602482018b9052915191909216916340c10f199160448083019260209291908290030181600087803b15801561343257600080fd5b505af1158015613446573d6000803e3d6000fd5b505050506040513d602081101561345c57600080fd5b5051935050600090505b600654811015611b1c576006818154811061347d57fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d913391859081106134b057fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561351957600080fd5b505af115801561352d573d6000803e3d6000fd5b505050506040513d602081101561354357600080fd5b505161354e57600080fd5b600101613466565b60015460009082906001600160a01b0380831691161461357557600080fd5b6001600160a01b03841660009081526007602052604090205460ff16806122ab57505050506001600160a01b031660009081526008602052604090205460ff1690565b3360009081526020819052604081206001015460e01b600160e01b908116146135e057600080fd5b7f65787465726e616c546f6b656e5472616e7366657246726f6d0000000000000060005b6005548110156136f4576005818154811061361b57fe5b6000918252602090912060029091020154600580546001600160a01b039092169163c1786ab29133918590811061364e57fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b1580156136b757600080fd5b505af11580156136cb573d6000803e3d6000fd5b505050506040513d60208110156136e157600080fd5b50516136ec57600080fd5b600101613604565b60015484906001600160a01b0380831691161461371057600080fd5b60015460408051635bab6ad160e11b81526001600160a01b038c811660048301528b811660248301528a81166044830152606482018a90529151919092169163b756d5a29160848083019260209291908290030181600087803b15801561377657600080fd5b505af115801561378a573d6000803e3d6000fd5b505050506040513d60208110156137a057600080fd5b5051935050600090505b60065481101561389a57600681815481106137c157fe5b6000918252602090912060029091020154600680546001600160a01b0390921691638043154d913391859081106137f457fe5b906000526020600020906002020160010154856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b15801561385d57600080fd5b505af1158015613871573d6000803e3d6000fd5b505050506040513d602081101561388757600080fd5b505161389257600080fd5b6001016137aa565b505095945050505050565b6001600160a01b03811660009081526020819052604090206001015460e01b600160e01b161515919050565b604080518082019091526000808252602082015290565b815481835581811115613914576002028160020283600052602060002091820191016139149190613919565b505050565b61394891905b808211156139445780546001600160a01b03191681556000600182015560020161391f565b5090565b9056fea265627a7a72315820a3c13011e9290449e52fc4816400e8b331ad03e97218d4ae7a54ba286ec7251564736f6c63430005100032