Contract 0x3dFA93D0d80C9985c9c78cE3620bd0803767a95C

 
Ad
Ad
Txn Hash Method
Block
From
To
Value
0x2910e7f17089f410cf679aaa8f66e5e1aae36b093e2a77b017faa0844f11489e0x6060604050145922018-02-02 1:39:291332 days 23 hrs agoBlockbits: Deployer IN  Create: GatewayInterface0 Ether0.0060194810
[ Download CSV Export 
View more zero value Internal Transactions in Advanced View mode
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
GatewayInterface

Compiler Version
v0.4.17+commit.bdeb9e52

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2018-02-02
*/

pragma solidity ^0.4.17;

/*

 * source       https://github.com/blockbitsio/

 * @name        Application Entity Generic Contract
 * @package     BlockBitsIO
 * @author      Micky Socaci <[email protected]>

    Used for the ABI interface when assets need to call Application Entity.

    This is required, otherwise we end up loading the assets themselves when we load the ApplicationEntity contract
    and end up in a loop
*/



contract ApplicationEntityABI {

    address public ProposalsEntity;
    address public FundingEntity;
    address public MilestonesEntity;
    address public MeetingsEntity;
    address public BountyManagerEntity;
    address public TokenManagerEntity;
    address public ListingContractEntity;
    address public FundingManagerEntity;
    address public NewsContractEntity;

    bool public _initialized = false;
    bool public _locked = false;
    uint8 public CurrentEntityState;
    uint8 public AssetCollectionNum;
    address public GatewayInterfaceAddress;
    address public deployerAddress;
    address testAddressAllowUpgradeFrom;
    mapping (bytes32 => uint8) public EntityStates;
    mapping (bytes32 => address) public AssetCollection;
    mapping (uint8 => bytes32) public AssetCollectionIdToName;
    mapping (bytes32 => uint256) public BylawsUint256;
    mapping (bytes32 => bytes32) public BylawsBytes32;

    function ApplicationEntity() public;
    function getEntityState(bytes32 name) public view returns (uint8);
    function linkToGateway( address _GatewayInterfaceAddress, bytes32 _sourceCodeUrl ) external;
    function setUpgradeState(uint8 state) public ;
    function addAssetProposals(address _assetAddresses) external;
    function addAssetFunding(address _assetAddresses) external;
    function addAssetMilestones(address _assetAddresses) external;
    function addAssetMeetings(address _assetAddresses) external;
    function addAssetBountyManager(address _assetAddresses) external;
    function addAssetTokenManager(address _assetAddresses) external;
    function addAssetFundingManager(address _assetAddresses) external;
    function addAssetListingContract(address _assetAddresses) external;
    function addAssetNewsContract(address _assetAddresses) external;
    function getAssetAddressByName(bytes32 _name) public view returns (address);
    function setBylawUint256(bytes32 name, uint256 value) public;
    function getBylawUint256(bytes32 name) public view returns (uint256);
    function setBylawBytes32(bytes32 name, bytes32 value) public;
    function getBylawBytes32(bytes32 name) public view returns (bytes32);
    function initialize() external returns (bool);
    function getParentAddress() external view returns(address);
    function createCodeUpgradeProposal( address _newAddress, bytes32 _sourceCodeUrl ) external returns (uint256);
    function acceptCodeUpgradeProposal(address _newAddress) external;
    function initializeAssetsToThisApplication() external returns (bool);
    function transferAssetsToNewApplication(address _newAddress) external returns (bool);
    function lock() external returns (bool);
    function canInitiateCodeUpgrade(address _sender) public view returns(bool);
    function doStateChanges() public;
    function hasRequiredStateChanges() public view returns (bool);
    function anyAssetHasChanges() public view returns (bool);
    function extendedAnyAssetHasChanges() internal view returns (bool);
    function getRequiredStateChanges() public view returns (uint8, uint8);
    function getTimestamp() view public returns (uint256);

}

/*

 * source       https://github.com/blockbitsio/

 * @name        Gateway Interface Contract
 * @package     BlockBitsIO
 * @author      Micky Socaci <[email protected]>

 Used as a resolver to retrieve the latest deployed version of the Application

 ENS: gateway.main.blockbits.eth will point directly to this contract.

    ADD ENS domain ownership / transfer methods

*/





contract GatewayInterface {

    event EventGatewayNewLinkRequest ( address indexed newAddress );
    event EventGatewayNewAddress ( address indexed newAddress );

    address public currentApplicationEntityAddress;
    ApplicationEntityABI private currentApp;

    address public deployerAddress;

    function GatewayInterface() public {
        deployerAddress = msg.sender;
    }

    /**
    @notice Get current ApplicationEntity Contract address
    @return {
        "currentApplicationEntityAddress": Currently bound application address
    }
    */
    function getApplicationAddress() external view returns (address) {
        return currentApplicationEntityAddress;
    }


    /**
    @notice ApplicationEntity Contract requests to be linked
    @dev modifier validCodeUpgradeInitiator
    @param _newAddress address, The address of the application contract
    @param _sourceCodeUrl bytes32, The url of the application source code on etherscan
    @return {
        "bool": TRUE if successfully processed
    }
    */
    function requestCodeUpgrade( address _newAddress, bytes32 _sourceCodeUrl )
        external
        validCodeUpgradeInitiator
        returns (bool)
    {
        require(_newAddress != address(0x0));

        EventGatewayNewLinkRequest ( _newAddress );

        /*
            case 1 - Newly Deployed Gateway and Application

            gateway links to app and initializes
        */
        if(currentApplicationEntityAddress == address(0x0)) {

            if(!ApplicationEntityABI(_newAddress).initializeAssetsToThisApplication()) {
                revert();
            }
            link(_newAddress);
            return true;
        } else {
            /*
                case 2 - Actual Code Upgrade Request

                - Current app should exist already
                - Current app
                    - Create a proposal
                    - Vote on result
                    - Get Result
                    - Approve Result
            */
            currentApp.createCodeUpgradeProposal(_newAddress, _sourceCodeUrl);
        }
    }

    /**
    @notice ApplicationEntity Contract approves code Upgrade
    @dev modifier onlyCurrentApplicationEntity
    @param _newAddress address, The address of the new application contract
    @return {
        "bool": TRUE if successfully processed
    }
    */
    function approveCodeUpgrade( address _newAddress ) external returns (bool) {
        require(msg.sender == currentApplicationEntityAddress);
        uint8 atState = currentApp.CurrentEntityState();
        lockCurrentApp();
        if(!currentApp.transferAssetsToNewApplication(_newAddress)) {
            revert();
        }
        link(_newAddress);
        currentApp.setUpgradeState( atState );
        return true;
    }

    /**
    @notice Locks current application entity
    @dev Internally used by gateway to lock current application entity before switching to the new one
    */
    function lockCurrentApp() internal {
        if(!currentApp.lock()) {
            revert();
        }
    }

    /**
    @notice Link to new Application Entity
    @param _newAddress address, The address of the new application contract
    @return {
        "bool": TRUE if successfully processed
    }
    */
    function link( address _newAddress ) internal returns (bool) {

        currentApplicationEntityAddress = _newAddress;
        currentApp = ApplicationEntityABI(currentApplicationEntityAddress);
        if( !currentApp.initialize() ) {
            revert();
        }
        EventGatewayNewAddress(currentApplicationEntityAddress);
        return true;
    }


    /**
    @notice Get current News Contract address
    @return {
        "address": 0x address of the News Contract
    }
    */
    function getNewsContractAddress() external view returns (address) {
        return currentApp.NewsContractEntity();
    }

    /**
    @notice Get current Listing Contract address
    @return {
        "address": 0x address of the Listing Contract
    }
    */
    function getListingContractAddress() external view returns (address) {
        return currentApp.ListingContractEntity();
    }

    /*
    * Validates if new application's deployer is allowed to upgrade current app
    */

    /**
    @notice Validates if new application's deployer is allowed to upgrade current app
    */
    modifier validCodeUpgradeInitiator() {
        bool valid = false;

        ApplicationEntityABI newDeployedApp = ApplicationEntityABI(msg.sender);
        address newDeployer = newDeployedApp.deployerAddress();

        if(newDeployer == deployerAddress) {
            valid = true;
        } else {
            if(currentApplicationEntityAddress != address(0x0)) {
                currentApp = ApplicationEntityABI(currentApplicationEntityAddress);
                if(currentApp.canInitiateCodeUpgrade(newDeployer)) {
                    valid = true;
                }
            }
        }

        // ok if current app accepts newDeployer as a token holder that can do a code upgrade
        // ok if newDeployer is oldDeployer
        require( valid == true );
        _;
    }
}

Contract Security Audit

Contract ABI

[{"constant":false,"inputs":[{"name":"_newAddress","type":"address"}],"name":"approveCodeUpgrade","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"currentApplicationEntityAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getApplicationAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newAddress","type":"address"},{"name":"_sourceCodeUrl","type":"bytes32"}],"name":"requestCodeUpgrade","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getListingContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getNewsContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"deployerAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"newAddress","type":"address"}],"name":"EventGatewayNewLinkRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"newAddress","type":"address"}],"name":"EventGatewayNewAddress","type":"event"}]

6060604052341561000f57600080fd5b60028054600160a060020a03191633600160a060020a03161790556107ba806100396000396000f300606060405236156100675763ffffffff60e060020a6000350416630e09461d811461006c5780635cbbdfc91461009f57806370d8915a146100ce5780637913c465146100e1578063b2baede414610103578063eaa4028314610116578063efdee94f14610129575b600080fd5b341561007757600080fd5b61008b600160a060020a036004351661013c565b604051901515815260200160405180910390f35b34156100aa57600080fd5b6100b26102b7565b604051600160a060020a03909116815260200160405180910390f35b34156100d957600080fd5b6100b26102c6565b34156100ec57600080fd5b61008b600160a060020a03600435166024356102d5565b341561010e57600080fd5b6100b261057f565b341561012157600080fd5b6100b26105e8565b341561013457600080fd5b6100b2610632565b60008054819033600160a060020a0390811691161461015a57600080fd5b600154600160a060020a0316637278d6236000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156101a257600080fd5b6102c65a03f115156101b357600080fd5b5050506040518051905090506101c7610641565b600154600160a060020a031663361821278460006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561022057600080fd5b6102c65a03f1151561023157600080fd5b50505060405180519050151561024657600080fd5b61024f836106b1565b50600154600160a060020a031663cf70c6c78260405160e060020a63ffffffff841602815260ff9091166004820152602401600060405180830381600087803b151561029a57600080fd5b6102c65a03f115156102ab57600080fd5b50600195945050505050565b600054600160a060020a031681565b600054600160a060020a031690565b6000803381600160a060020a03821663efdee94f82604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561031f57600080fd5b6102c65a03f1151561033057600080fd5b5050506040518051600254909250600160a060020a0380841691161415905061035c5760019250610410565b600054600160a060020a03161561041057600080546001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392831617908190551690635d1339459083906040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b15156103eb57600080fd5b6102c65a03f115156103fc57600080fd5b505050604051805190501561041057600192505b60018315151461041f57600080fd5b600160a060020a038616151561043457600080fd5b85600160a060020a03167ffa88dd200abb8b02c67092a21cd9a0f4004faece7f6c2c52d5c0decee58f525660405160405180910390a2600054600160a060020a031615156104fb5785600160a060020a03166322b013436000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156104c257600080fd5b6102c65a03f115156104d357600080fd5b5050506040518051905015156104e857600080fd5b6104f1866106b1565b5060019350610576565b600154600160a060020a031663584ae175878760006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561055a57600080fd5b6102c65a03f1151561056b57600080fd5b505050604051805150505b50505092915050565b600154600090600160a060020a031663385fbe2482604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156105c957600080fd5b6102c65a03f115156105da57600080fd5b505050604051805191505090565b600154600090600160a060020a031663e8be2e8e82604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156105c957600080fd5b600254600160a060020a031681565b600154600160a060020a031663f83d08ba6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561068957600080fd5b6102c65a03f1151561069a57600080fd5b5050506040518051905015156106af57600080fd5b565b60008054600160a060020a0380841673ffffffffffffffffffffffffffffffffffffffff199283161780845560018054909316908216179182905516638129fc1c82604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561072857600080fd5b6102c65a03f1151561073957600080fd5b50505060405180519050151561074e57600080fd5b600054600160a060020a03167ffba64b22a8cde6265e682400b205af8a25a918f1fed3b3306249e8fc9fed7a9160405160405180910390a25060019190505600a165627a7a72305820f6a47ed551234b148887eb7bbddc77a31c4a5adde771a9c9d62f20d3ea317e770029

Swarm Source

bzzr://f6a47ed551234b148887eb7bbddc77a31c4a5adde771a9c9d62f20d3ea317e77
Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.