SHARE
TWEET

Untitled

a guest Jul 30th, 2019 12 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *Submitted for verification at Etherscan.io on 2017-10-14
  3. */
  4.  
  5. pragma solidity ^0.4.15;
  6.  
  7. contract Owned {
  8.  
  9.     // The address of the account that is the current owner
  10.     address internal owner;
  11.  
  12.  
  13.     /**
  14.      * The publisher is the inital owner
  15.      */
  16.     function Owned() {
  17.         owner = msg.sender;
  18.     }
  19.  
  20.  
  21.     /**
  22.      * Access is restricted to the current owner
  23.      */
  24.     modifier only_owner() {
  25.         require(msg.sender == owner);
  26.  
  27.         _;
  28.     }
  29. }
  30.  
  31.  
  32. contract IOwnership {
  33.  
  34.     /**
  35.      * Returns true if `_account` is the current owner
  36.      *
  37.      * @param _account The address to test against
  38.      */
  39.     function isOwner(address _account) constant returns (bool);
  40.  
  41.  
  42.     /**
  43.      * Gets the current owner
  44.      *
  45.      * @return address The current owner
  46.      */
  47.     function getOwner() constant returns (address);
  48. }
  49.  
  50.  
  51. contract Ownership is IOwnership, Owned {
  52.  
  53.  
  54.     /**
  55.      * Returns true if `_account` is the current owner
  56.      *
  57.      * @param _account The address to test against
  58.      */
  59.     function isOwner(address _account) public constant returns (bool) {
  60.         return _account == owner;
  61.     }
  62.  
  63.  
  64.     /**
  65.      * Gets the current owner
  66.      *
  67.      * @return address The current owner
  68.      */
  69.     function getOwner() public constant returns (address) {
  70.         return owner;
  71.     }
  72. }
  73.  
  74.  
  75. contract ITransferableOwnership {
  76.  
  77.     /**
  78.      * Transfer ownership to `_newOwner`
  79.      *
  80.      * @param _newOwner The address of the account that will become the new owner
  81.      */
  82.     function transferOwnership(address _newOwner);
  83. }
  84.  
  85.  
  86. contract TransferableOwnership is ITransferableOwnership, Ownership {
  87.  
  88.  
  89.     /**
  90.      * Transfer ownership to `_newOwner`
  91.      *
  92.      * @param _newOwner The address of the account that will become the new owner
  93.      */
  94.     function transferOwnership(address _newOwner) public only_owner {
  95.         owner = _newOwner;
  96.     }
  97. }
  98.  
  99.  
  100. /**
  101.  * @title IWhitelist
  102.  *
  103.  * Whitelist authentication interface
  104.  *
  105.  * #created 04/10/2017
  106.  * #author Frank Bonnet
  107.  */
  108. contract IWhitelist {
  109.    
  110.  
  111.     /**
  112.      * Authenticate
  113.      *
  114.      * Returns whether `_account` is on the whitelist
  115.      *
  116.      * @param _account The account to authenticate
  117.      * @return whether `_account` is successfully authenticated
  118.      */
  119.     function authenticate(address _account) constant returns (bool);
  120. }
  121.  
  122.  
  123. /**
  124.  * @title Whitelist
  125.  *
  126.  * Whitelist authentication list
  127.  *
  128.  * #created 04/10/2017
  129.  * #author Frank Bonnet
  130.  */
  131. contract Whitelist is IWhitelist, TransferableOwnership {
  132.  
  133.     struct Entry {
  134.         uint datetime;
  135.         bool accepted;
  136.         uint index;
  137.     }
  138.  
  139.     mapping (address => Entry) internal list;
  140.     address[] internal listIndex;
  141.  
  142.  
  143.     /**
  144.      * Returns whether an entry exists for `_account`
  145.      *
  146.      * @param _account The account to check
  147.      * @return whether `_account` is has an entry in the whitelist
  148.      */
  149.     function hasEntry(address _account) public constant returns (bool) {
  150.         return listIndex.length > 0 && _account == listIndex[list[_account].index];
  151.     }
  152.  
  153.  
  154.     /**
  155.      * Add `_account` to the whitelist
  156.      *
  157.      * If an account is currently disabled, the account is reenabled. Otherwise
  158.      * a new entry is created
  159.      *
  160.      * @param _account The account to add
  161.      */
  162.     function add(address _account) public only_owner {
  163.         if (!hasEntry(_account)) {
  164.             list[_account] = Entry(
  165.                 now, true, listIndex.push(_account) - 1);
  166.         } else {
  167.             Entry storage entry = list[_account];
  168.             if (!entry.accepted) {
  169.                 entry.accepted = true;
  170.                 entry.datetime = now;
  171.             }
  172.         }
  173.     }
  174.  
  175.  
  176.     /**
  177.      * Remove `_account` from the whitelist
  178.      *
  179.      * Will not actually remove the entry but disable it by updating
  180.      * the accepted record
  181.      *
  182.      * @param _account The account to remove
  183.      */
  184.     function remove(address _account) public only_owner {
  185.         if (hasEntry(_account)) {
  186.             Entry storage entry = list[_account];
  187.             entry.accepted = false;
  188.             entry.datetime = now;
  189.         }
  190.     }
  191.  
  192.  
  193.     /**
  194.      * Authenticate
  195.      *
  196.      * Returns whether `_account` is on the whitelist
  197.      *
  198.      * @param _account The account to authenticate
  199.      * @return whether `_account` is successfully authenticated
  200.      */
  201.     function authenticate(address _account) public constant returns (bool) {
  202.         return list[_account].accepted;
  203.     }
  204. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top