Change bytes to bytes32[] in UnanimousConsent

import "BulletinBoard.sol";

/**
 * This contract performs an "eval" on arbitrary contracts but only with the
 * consent of all participants named.
 */
contract UnanimousConsent {

	enum ConsentState {
		NONE,
		CONSENTED,
		EXECUTED
	}

	struct Action {
		address target;
		uint value;
		bytes32[] calldata;
		bool initialized;
	}

	// Records the current state of consent for a given hash and address
	mapping (bytes32 =>
			mapping (address => ConsentState)) consentStates;

	// Contains all of the sent execution actions
	mapping (bytes32 => Action) actions;

	// Holds all of the participants in the current UnanimousConsent contract
	address[] participants;

	// Holds the BulletinBoard for counterfactual addressing
	BulletinBoard public bulletinBoard;

	modifier onlySelf {
		if (msg.sender == address(this)) {
			_
		} else {
			throw;
		}
	}

	/**
	 * Creates a new UnanimousConsent contract.
	 *
	 * _participants: The initial participants in the contract
	 */
	function UnanimousConsent(address[] _participants) {
		participants = _participants;
		bulletinBoard = new BulletinBoard(this);
	}

	/**
	 * Adds an `Action` to potentially be executed.
	 *
	 * _target: The target of the execution call
	 * _value: The amount of Ether to send
	 * _calldata: The calldata associated with the call
	 */
	function addAction(address _target, uint _value, bytes32[] _calldata) external {
		Action memory action = Action(_target, _value, _calldata, true);
		actions[sha3(_target, _value, _calldata)] = action;
	}

	/**
	 * Evaluates arbitrary functions of contracts, but only with universal
	 * consent. Note that any `eval` sub-calls should `throw` in the event that
	 * there is a contract execution failure (such as if a precondition isn't
	 * met or if a verification of some sort fails) to prevent this call from
	 * finishing.
	 *
	 * _actionHashes: The hashes of the `Action` that have been submitted
	 */
	function eval(bytes32[] _actionHashes) {
		uint i;
		bytes32 hash = sha3(_actionHashes);

		for (i = participants.length; i > 0; i--) {
			if (consentStates[hash][participants[i-1]] == ConsentState.CONSENTED) {
				consentStates[hash][participants[i-1]] = ConsentState.EXECUTED;
			} else {
				throw;
			}
		}

		for (i = 0; i < _actionHashes.length; i++) {
			Action memory action = actions[_actionHashes[i]];
			if (!(action.initialized && action.target.call.value(action.value)(action.calldata))) {
				throw;
			}
		}
	}

	/**
	 * Provides consent for the hash of an execution call for the sender of the
	 * message.
	 *
	 * _hash: The hash of the execution call
	 *
	 * returns: `true` if successful, otherwise `false`
	 */
	function consent(bytes32 _hash) returns (bool) {
		if (consentStates[_hash][msg.sender] == ConsentState.NONE) {
			consentStates[_hash][msg.sender] = ConsentState.CONSENTED;
			return true;
		} else {
			return false;
		}
	}

	/**
	 * Changes the participants in the current contract. Intended to only be
	 * called by this contract's `eval`.
	 *
	 * _participants: The new participants in the contract
	 */
	function changeParticipants(address[] _participants) external onlySelf {
		participants = _participants;
	}

	/**
	 * Removes a group of `Action` that have been submitted. Intended to be
	 * called by this contract's `eval`.
	 *
	 * _actionHashes: The hashes of the `Action` that have been submitted
	 */
	function cleanActions(bytes32[] _actionHashes) external onlySelf {
		for (uint i = _actionHashes.length; i > 0; i--) {
			delete actions[_actionHashes[i-1]];
		}
	}

	/**
	 * Cleans up previously approved consents. Intended to only be called by
	 * this contract's `eval`.
	 *
	 * _hashes: The list of hashes to clean
	 * _participants: The list of address whose hashes should be cleaned
	 */
	function clean(bytes32[] _hashes, address[] _participants) external onlySelf {
		for (uint i = _hashes.length; i > 0; i--) {
			for (uint j = _participants.length; j > 0; j--) {
				delete consentStates[_hashes[i-1]][_participants[j-1]];
			}
		}
	}

	/**
	 * Kills the current contract. Intended to only be called by this contract's
	 * eval.
	 *
	 * _recipient: The recipient of funds from the `selfdestruct` call
	 */
	function kill(address _recipient) external onlySelf {
		selfdestruct(_recipient);
	}
}

import "BulletinBoard.sol";

/**
 * This contract performs an "eval" on arbitrary contracts but only with the
 * consent of all participants named.
 */
contract UnanimousConsent {

	enum ConsentState {
		NONE,
		CONSENTED,
		EXECUTED
	}

	struct Action {
		address target;
		uint value;
		bytes calldata;
		bool initialized;
	}

	// Records the current state of consent for a given hash and address
	mapping (bytes32 =>
			mapping (address => ConsentState)) consentStates;

	// Contains all of the sent execution actions
	mapping (bytes32 => Action) actions;

	// Holds all of the participants in the current UnanimousConsent contract
	address[] participants;

	// Holds the BulletinBoard for counterfactual addressing
	BulletinBoard public bulletinBoard;

	modifier onlySelf {
		if (msg.sender == address(this)) {
			_
		} else {
			throw;
		}
	}

	/**
	 * Creates a new UnanimousConsent contract.
	 *
	 * _participants: The initial participants in the contract
	 */
	function UnanimousConsent(address[] _participants) {
		participants = _participants;
		bulletinBoard = new BulletinBoard(this);
	}

	/**
	 * Adds an `Action` to potentially be executed.
	 *
	 * _target: The target of the execution call
	 * _value: The amount of Ether to send
	 * _calldata: The calldata associated with the call
	 */
	function addAction(address _target, uint _value, bytes _calldata) external {
		Action memory action = Action(_target, _value, _calldata, true);
		actions[sha3(_target, _value, _calldata)] = action;
	}

	/**
	 * Evaluates arbitrary functions of contracts, but only with universal
	 * consent. Note that any `eval` sub-calls should `throw` in the event that
	 * there is a contract execution failure (such as if a precondition isn't
	 * met or if a verification of some sort fails) to prevent this call from
	 * finishing.
	 *
	 * _actionHashes: The hashes of the `Action` that have been submitted
	 */
	function eval(bytes32[] _actionHashes) {
		uint i;
		bytes32 hash = sha3(_actionHashes);

		for (i = participants.length; i > 0; i--) {
			if (consentStates[hash][participants[i-1]] == ConsentState.CONSENTED) {
				consentStates[hash][participants[i-1]] = ConsentState.EXECUTED;
			} else {
				throw;
			}
		}

		for (i = 0; i < _actionHashes.length; i++) {
			Action memory action = actions[_actionHashes[i]];
			if (!(action.initialized && action.target.call.value(action.value)(action.calldata))) {
				throw;
			}
		}
	}

	/**
	 * Provides consent for the hash of an execution call for the sender of the
	 * message.
	 *
	 * _hash: The hash of the execution call
	 *
	 * returns: `true` if successful, otherwise `false`
	 */
	function consent(bytes32 _hash) returns (bool) {
		if (consentStates[_hash][msg.sender] == ConsentState.NONE) {
			consentStates[_hash][msg.sender] = ConsentState.CONSENTED;
			return true;
		} else {
			return false;
		}
	}

	/**
	 * Changes the participants in the current contract. Intended to only be
	 * called by this contract's `eval`.
	 *
	 * _participants: The new participants in the contract
	 */
	function changeParticipants(address[] _participants) external onlySelf {
		participants = _participants;
	}

	/**
	 * Removes a group of `Action` that have been submitted. Intended to be
	 * called by this contract's `eval`.
	 *
	 * _actionHashes: The hashes of the `Action` that have been submitted
	 */
	function cleanActions(bytes32[] _actionHashes) external onlySelf {
		for (uint i = _actionHashes.length; i > 0; i--) {
			delete actions[_actionHashes[i-1]];
		}
	}

	/**
	 * Cleans up previously approved consents. Intended to only be called by
	 * this contract's `eval`.
	 *
	 * _hashes: The list of hashes to clean
	 * _participants: The list of address whose hashes should be cleaned
	 */
	function clean(bytes32[] _hashes, address[] _participants) external onlySelf {
		for (uint i = _hashes.length; i > 0; i--) {
			for (uint j = _participants.length; j > 0; j--) {
				delete consentStates[_hashes[i-1]][_participants[j-1]];
			}
		}
	}

	/**
	 * Kills the current contract. Intended to only be called by this contract's
	 * eval.
	 *
	 * _recipient: The recipient of funds from the `selfdestruct` call
	 */
	function kill(address _recipient) external onlySelf {
		selfdestruct(_recipient);
	}
}


Create SimpleTokenBounty

Create SimpleTokenBounty

pragma solidity ^0.4.0;
import './PullPayment.sol';
import './token/SimpleToken.sol';

/*
 * Bounty
 * This bounty will pay out if you can cause a SimpleToken's balance
 * to be lower than its totalSupply, which would mean that it doesn't
 * have sufficient ether for everyone to withdraw.
 */
contract Bounty is PullPayment {

  bool public claimed;
  mapping(address => address) public researchers;

  function() {
    if (claimed) throw;
  }

  function createTarget() returns(SimpleToken) {
    SimpleToken target = new SimpleToken();
    researchers[target] = msg.sender;
    return target;
  }

  function claim(SimpleToken target) {
    address researcher = researchers[target];
    if (researcher == 0) throw;
    // Check SimpleToken contract invariants
    // Customize this to the specifics of your contract
    if (target.totalSupply() == target.balance) {
      throw;
    }
    asyncSend(researcher, this.balance);
    claimed = true;
  }

}

error: pathspec 'contracts/bounties/SimpleTokenBounty.sol' did not match any file(s) known to git


separate future block call stuff

separate future block call stuff

import "libraries/GroveLib.sol";

library CallLib {
        /*
         *  Address: 0x2746bcf29bffafcc7906752f639819171d18ce2b
         */
        struct Call {
                address contract_address;
                bytes4 abi_signature;
                bytes call_data;
                uint anchor_gas_price;
                uint suggested_gas;

                address bidder;
                uint bid_amount;
                uint bidder_deposit;

                bool was_successful;
                bool was_called;
                bool is_cancelled;
        }

        // The number of blocks that each caller in the pool has to complete their
        // call.
        uint constant CALL_WINDOW_SIZE = 16;

        address constant creator = 0xd3cda913deb6f67967b99d67acdfa1712c293601;

        function extract_call_data(Call storage call, bytes data) public {
            call.call_data.length = data.length - 4;
            if (data.length > 4) {
                    for (uint i = 0; i < call.call_data.length; i++) {
                            call.call_data[i] = data[i + 4];
                    }
            }
        }

        function send_safe(address to_address, uint value) public returns (uint) {
                if (value > address(this).balance) {
                        value = address(this).balance;
                }
                if (value > 0) {
                        AccountingLib.sendRobust(to_address, value);
                        return value;
                }
                return 0;
        }

        function get_gas_scalar(uint base_gas_price, uint gas_price) constant returns (uint) {
                /*
                 *  Return a number between 0 - 200 to scale the fee based on
                 *  the gas price set for the calling transaction as compared
                 *  to the gas price of the scheduling transaction.
                 *
                 *  - number approaches zero as the transaction gas price goes
                 *  above the gas price recorded when the call was scheduled.
                 *
                 *  - the number approaches 200 as the transaction gas price
                 *  drops under the price recorded when the call was scheduled.
                 *
                 *  This encourages lower gas costs as the lower the gas price
                 *  for the executing transaction, the higher the payout to the
                 *  caller.
                 */
                if (gas_price > base_gas_price) {
                        return 100 * base_gas_price / gas_price;
                }
                else {
                        return 200 - 100 * base_gas_price / (2 * base_gas_price - gas_price);
                }
        }

        event CallExecuted(address indexed executor, uint gas_cost, uint payment, uint fee, bool success);

        event _CallAborted(address executor, bytes32 reason);
        function CallAborted(address executor, bytes32 reason) public {
            _CallAborted(executor, reason);
        }

        function execute(Call storage self, uint start_gas, address executor, uint overhead, uint extraGas) public {
            FutureCall call = FutureCall(this);

            // If the pre-execution checks do not pass, exit early.
            if (!call.before_execute(executor)) {
                return;
            }

            // Make the call
            self.was_successful = self.contract_address.call.gas(msg.gas - overhead)(self.abi_signature, self.call_data);
            self.was_called = true;

            // Compute the scalar (0 - 200) for the fee.
            uint gas_scalar = get_gas_scalar(self.anchor_gas_price, tx.gasprice);

            uint base_payment;
            if (self.bidder == 0x0) {
                base_payment = call.base_payment();
            }
            else {
                base_payment = self.bid_amount;
            }
            uint payment = self.bidder_deposit + base_payment * gas_scalar / 100;
            uint fee = call.base_fee() * gas_scalar / 100;

            // zero out the deposit
            self.bidder_deposit = 0;

            // Log how much gas this call used.  EXTRA_CALL_GAS is a fixed
            // amount that represents the gas usage of the commands that
            // happen after this line.
            uint gas_cost = tx.gasprice * (start_gas - msg.gas + extraGas);

            // Now we need to pay the executor as well as keep fee.
            payment = send_safe(executor, payment + gas_cost);
            fee = send_safe(creator, fee);

            // Log execution
            CallExecuted(executor, gas_cost, payment, fee, self.was_successful);
        }

        event Cancelled(address indexed cancelled_by);

        function cancel(Call storage self, address sender) public {
                Cancelled(sender);
                if (self.bidder_deposit >= 0) {
                    send_safe(self.bidder, self.bidder_deposit);
                }
                var call = FutureCall(this);
                send_safe(call.scheduler_address(), address(this).balance);
                self.is_cancelled = true;
        }

        /*
         *  Bid API
         *  - Gas costs for this transaction are not covered so it
         *    must be up to the call executors to ensure that their actions
         *    remain profitable.  Any form of bidding war is likely to eat into
         *    profits.
         */
        event Claimed(address executor, uint bid_amount);

        // The duration (in blocks) during which the maximum bid will slowly rise
        // towards the base_payment amount.
        uint constant BID_GROWTH_WINDOW = 240;

        // The duration (in blocks) after the BID_WINDOW that bidding will
        // remain open.
        uint constant MAXIMUM_BID_WINDOW = 15;

        // The duration (in blocks) before the call's target block during which
        // all actions are frozen.  This includes bidding, cancellation,
        // registering call data.
        uint constant BEFORE_CALL_FREEZE_WINDOW = 10;

        /*
         *  The maximum allowed bid slowly rises across a window of blocks
         *  BID_GROWTH_WINDOW prior to the call.  No bidder is allowed to bid
         *  above this value.  This is intended to prevent bidding wars in that
         *  each caller should know how much they are willing to execute a call
         *  for.
         */
        function get_bid_amount_for_block(uint block_number) constant returns (uint) {
            /*
             *   [--growth-window--][--max-window--][--freeze-window--]
             *
             *
             */
            var call = FutureBlockCall(this);

            uint last_block = call.target_block() - BEFORE_CALL_FREEZE_WINDOW;

            // bid window has closed
            if (block_number > last_block) return call.base_payment();

            uint first_block = last_block - MAXIMUM_BID_WINDOW - BID_GROWTH_WINDOW;

            // bid window has not begun
            if (block_number < first_block) return 0;

            // in the maximum bid window.
            if (block_number > last_block - MAXIMUM_BID_WINDOW) return call.base_payment();

            uint x = block_number - first_block;

            return call.base_payment() * x / BID_GROWTH_WINDOW;
        }

        function claim(Call storage self, address executor, uint deposit_amount, uint base_payment) public returns (bool) {
                // Already claimed
                if (self.bidder != 0x0) return false;

                // Insufficient Deposit
                if (deposit_amount < 2 * base_payment) return false;

                var call = FutureBlockCall(this);

                // Too early
                if (block.number < call.target_block() - BEFORE_CALL_FREEZE_WINDOW - MAXIMUM_BID_WINDOW - BID_GROWTH_WINDOW) return false;

                // Too late
                if (block.number > call.target_block() - BEFORE_CALL_FREEZE_WINDOW) return false;
                self.bid_amount = get_bid_amount_for_block(block.number);
                self.bidder = executor;
                self.bidder_deposit = deposit_amount;

                // Log the bid.
                Claimed(executor, self.bid_amount);
        }

        function check_execution_authorization(Call storage self, address executor, uint block_number) returns (bool) {
                /*
                 *  Check whether the given `executor` is authorized.
                 */
                var call = FutureBlockCall(this);

                uint target_block = call.target_block();

                // Invalid, not in call window.
                if (block_number < target_block || block_number > target_block + call.grace_period()) throw;

                // Within the reserved call window so if there is a bidder, the
                // executor must be the biddor.
                if (block_number - target_block < CALL_WINDOW_SIZE) {
                    return (self.bidder == 0x0 || self.bidder == executor);
                }

                // Must be in the free-for-all period.
                return true;
        }
}

contract FutureCall {
        address public scheduler_address;

        uint public base_payment;
        uint public base_fee;

        CallLib.Call call;

        /*
         *  Data accessor functions.
         */
        function contract_address() constant returns (address) {
            return call.contract_address;
        }

        function abi_signature() constant returns (bytes4) {
            return call.abi_signature;
        }

        function call_data() constant returns (bytes) {
            return call.call_data;
        }

        function anchor_gas_price() constant returns (uint) {
            return call.anchor_gas_price;
        }

        function suggested_gas() constant returns (uint) {
            return call.suggested_gas;
        }

        function bidder() constant returns (address) {
            return call.bidder;
        }

        function bid_amount() constant returns (uint) {
            return call.bid_amount;
        }

        function bidder_deposit() constant returns (uint) {
            return call.bidder_deposit;
        }

        function was_successful() constant returns (bool) {
            return call.was_successful;
        }

        function was_called() constant returns (bool) {
            return call.was_called;
        }

        function is_cancelled() constant returns (bool) {
            return call.is_cancelled;
        }

        function get_bid_amount_for_block() constant returns (uint) {
            return CallLib.get_bid_amount_for_block(block.number);
        }

        function get_bid_amount_for_block(uint block_number) constant returns (uint) {
            return CallLib.get_bid_amount_for_block(block_number);
        }

        function () {
                // Fallback to allow sending funds to this contract.
                // Also allows call data registration.
                if (msg.sender == scheduler_address && msg.data.length > 0) {
                        if (call.call_data.length != 0) {
                            throw;
                        }
                        call.call_data = msg.data;
                }
        }

        modifier notcancelled { if (call.is_cancelled) throw; _ }

        // The author (Piper Merriam) address.
        address constant creator = 0xd3cda913deb6f67967b99d67acdfa1712c293601;

        function register_data() public notcancelled {
            if (msg.sender != scheduler_address || call.call_data.length > 0) {
                // cannot write over call data
                throw;
            }
            CallLib.extract_call_data(call, msg.data);
        }

        function claim() public notcancelled returns (bool) {
            bool success = CallLib.claim(call, msg.sender, msg.value, base_payment);
            if (!success) {
                if (!AccountingLib.sendRobust(msg.sender, msg.value)) throw;
            }
            return success;
        }

        function check_execution_authorization(address executor, uint block_number) constant returns (bool) {
            return CallLib.check_execution_authorization(call, executor, block_number);
        }

        // API for inherited contracts
        function before_execute(address executor) public returns (bool);
        function after_execute(address executor) internal;
        function get_overhead() constant returns (uint);
        function get_extra_gas() constant returns (uint);

        function send_safe(address to_address, uint value) internal {
            CallLib.send_safe(to_address, value);
        }

        function execute() public notcancelled {
            uint start_gas = msg.gas;

            // Check that the call should be executed now.
            if (!before_execute(msg.sender)) return;

            // Execute the call
            CallLib.execute(call, start_gas, msg.sender, get_overhead(), get_extra_gas());

            // Any logic that needs to occur after the call has executed should
            // go in after_execute
            after_execute(msg.sender);
        }
}

contract FutureBlockCall is FutureCall {
        uint public target_block;
        uint8 public grace_period;

        function FutureBlockCall(address _scheduler_address, uint _target_block, uint8 _grace_period, address _contract_address, bytes4 _abi_signature, uint _suggested_gas, uint _base_payment, uint _base_fee) {
                // TODO: split this constructor across this contract and the
                // parent contract FutureCall
                scheduler_address = _scheduler_address;

                target_block = _target_block;
                grace_period = _grace_period;

                base_payment = _base_payment;
                base_fee = _base_fee;

                call.suggested_gas = _suggested_gas;
                call.anchor_gas_price = tx.gasprice;
                call.contract_address = _contract_address;
                call.abi_signature = _abi_signature;
        }

        function before_execute(address executor) public returns (bool) {
            if (block.number < target_block || block.number > target_block + grace_period) {
                // Not being called within call window.
                CallLib.CallAborted(executor, "NOT_IN_CALL_WINDOW");
                return false;
            }

            // If they are not authorized to execute the call at this time,
            // exit early.
            if (!CallLib.check_execution_authorization(call, executor, block.number)) {
                CallLib.CallAborted(executor, "NOT_AUTHORIZED");
                return;
            }

            return true;
        }

        function after_execute(address executor) internal {
            // Refund any leftover funds.
            CallLib.send_safe(scheduler_address, address(this).balance);
        }

        function get_overhead() constant returns (uint) {
                // TODO real numbers
                return 146000;
        }

        function get_extra_gas() constant returns (uint) {
                // TODO real numbers
                return 117000;
        }

        uint constant BID_GROWTH_WINDOW = 240;
        uint constant MAXIMUM_BID_WINDOW = 15;
        uint constant BEFORE_CALL_FREEZE_WINDOW = 10;

        function cancel() public notcancelled {
            // Before the bid window
            if (block.number < target_block - BEFORE_CALL_FREEZE_WINDOW - MAXIMUM_BID_WINDOW - BID_GROWTH_WINDOW) {
                // already cancelled
                if (msg.sender != scheduler_address) throw;
                CallLib.cancel(call, msg.sender);
                return;
            }
            if (block.number > target_block + grace_period) {
                // already called
                if (call.was_called) throw;
                CallLib.cancel(call, msg.sender);
                return;
            }
            throw;
        }
}

import "libraries/GroveLib.sol";

library CallLib {
        /*
         *  Address: 0x2746bcf29bffafcc7906752f639819171d18ce2b
         */
        struct Call {
                address contract_address;
                bytes4 abi_signature;
                bytes call_data;
                uint anchor_gas_price;
                uint suggested_gas;

                address bidder;
                uint bid_amount;
                uint bidder_deposit;

                bool was_successful;
                bool was_called;
                bool is_cancelled;
        }

        // The number of blocks that each caller in the pool has to complete their
        // call.
        uint constant CALL_WINDOW_SIZE = 16;

        address constant creator = 0xd3cda913deb6f67967b99d67acdfa1712c293601;

        function extract_call_data(Call storage call, bytes data) public {
            call.call_data.length = data.length - 4;
            if (data.length > 4) {
                    for (uint i = 0; i < call.call_data.length; i++) {
                            call.call_data[i] = data[i + 4];
                    }
            }
        }

        function send_safe(address to_address, uint value) public returns (uint) {
                if (value > address(this).balance) {
                        value = address(this).balance;
                }
                if (value > 0) {
                        AccountingLib.sendRobust(to_address, value);
                        return value;
                }
                return 0;
        }

        function get_gas_scalar(uint base_gas_price, uint gas_price) constant returns (uint) {
                /*
                 *  Return a number between 0 - 200 to scale the fee based on
                 *  the gas price set for the calling transaction as compared
                 *  to the gas price of the scheduling transaction.
                 *
                 *  - number approaches zero as the transaction gas price goes
                 *  above the gas price recorded when the call was scheduled.
                 *
                 *  - the number approaches 200 as the transaction gas price
                 *  drops under the price recorded when the call was scheduled.
                 *
                 *  This encourages lower gas costs as the lower the gas price
                 *  for the executing transaction, the higher the payout to the
                 *  caller.
                 */
                if (gas_price > base_gas_price) {
                        return 100 * base_gas_price / gas_price;
                }
                else {
                        return 200 - 100 * base_gas_price / (2 * base_gas_price - gas_price);
                }
        }

        event CallExecuted(address indexed executor, uint gas_cost, uint payment, uint fee, bool success);

        event _CallAborted(address executor, bytes32 reason);
        function CallAborted(address executor, bytes32 reason) public {
            _CallAborted(executor, reason);
        }

        function execute(Call storage self, uint start_gas, address executor, uint overhead, uint extraGas) public {
            FutureCall call = FutureCall(this);

            // If the pre-execution checks do not pass, exit early.
            if (!call.before_execute(executor)) {
                return;
            }

            // Make the call
            self.was_successful = self.contract_address.call.gas(msg.gas - overhead)(self.abi_signature, self.call_data);
            self.was_called = true;

            // Compute the scalar (0 - 200) for the fee.
            uint gas_scalar = get_gas_scalar(self.anchor_gas_price, tx.gasprice);

            uint base_payment;
            if (self.bidder == 0x0) {
                base_payment = call.base_payment();
            }
            else {
                base_payment = self.bid_amount;
            }
            uint payment = self.bidder_deposit + base_payment * gas_scalar / 100;
            uint fee = call.base_fee() * gas_scalar / 100;

            // zero out the deposit
            self.bidder_deposit = 0;

            // Log how much gas this call used.  EXTRA_CALL_GAS is a fixed
            // amount that represents the gas usage of the commands that
            // happen after this line.
            uint gas_cost = tx.gasprice * (start_gas - msg.gas + extraGas);

            // Now we need to pay the executor as well as keep fee.
            payment = send_safe(executor, payment + gas_cost);
            fee = send_safe(creator, fee);

            // Log execution
            CallExecuted(executor, gas_cost, payment, fee, self.was_successful);
        }

        event Cancelled(address indexed cancelled_by);

        function cancel(Call storage self, address sender) public {
                Cancelled(sender);
                if (self.bidder_deposit >= 0) {
                    send_safe(self.bidder, self.bidder_deposit);
                }
                var call = FutureCall(this);
                send_safe(call.scheduler_address(), address(this).balance);
                self.is_cancelled = true;
        }

        /*
         *  Bid API
         *  - Gas costs for this transaction are not covered so it
         *    must be up to the call executors to ensure that their actions
         *    remain profitable.  Any form of bidding war is likely to eat into
         *    profits.
         */
        event Claimed(address executor, uint bid_amount);

        // The duration (in blocks) during which the maximum bid will slowly rise
        // towards the base_payment amount.
        uint constant BID_GROWTH_WINDOW = 240;

        // The duration (in blocks) after the BID_WINDOW that bidding will
        // remain open.
        uint constant MAXIMUM_BID_WINDOW = 15;

        // The duration (in blocks) before the call's target block during which
        // all actions are frozen.  This includes bidding, cancellation,
        // registering call data.
        uint constant BEFORE_CALL_FREEZE_WINDOW = 10;

        /*
         *  The maximum allowed bid slowly rises across a window of blocks
         *  BID_GROWTH_WINDOW prior to the call.  No bidder is allowed to bid
         *  above this value.  This is intended to prevent bidding wars in that
         *  each caller should know how much they are willing to execute a call
         *  for.
         */
        function get_bid_amount_for_block(uint block_number) constant returns (uint) {
            /*
             *   [--growth-window--][--max-window--][--freeze-window--]
             *
             *
             */
            var call = FutureBlockCall(this);

            uint last_block = call.target_block() - BEFORE_CALL_FREEZE_WINDOW;

            // bid window has closed
            if (block_number > last_block) return call.base_payment();

            uint first_block = last_block - MAXIMUM_BID_WINDOW - BID_GROWTH_WINDOW;

            // bid window has not begun
            if (block_number < first_block) return 0;

            // in the maximum bid window.
            if (block_number > last_block - MAXIMUM_BID_WINDOW) return call.base_payment();

            uint x = block_number - first_block;

            return call.base_payment() * x / BID_GROWTH_WINDOW;
        }

        function claim(Call storage self, address executor, uint deposit_amount, uint base_payment) public returns (bool) {
                // Already claimed
                if (self.bidder != 0x0) return false;

                // Insufficient Deposit
                if (deposit_amount < 2 * base_payment) return false;

                var call = FutureCall(this);

                // Too early
                if (block.number < call.target_block() - BEFORE_CALL_FREEZE_WINDOW - MAXIMUM_BID_WINDOW - BID_GROWTH_WINDOW) return false;

                // Too late
                if (block.number > call.target_block() - BEFORE_CALL_FREEZE_WINDOW) return false;
                self.bid_amount = get_bid_amount_for_block(block.number);
                self.bidder = executor;
                self.bidder_deposit = deposit_amount;

                // Log the bid.
                Claimed(executor, self.bid_amount);
        }

        function check_execution_authorization(Call storage self, address executor, uint block_number) returns (bool) {
                /*
                 *  Check whether the given `executor` is authorized.
                 */
                var call = FutureCall(this);

                uint target_block = call.target_block();

                // Invalid, not in call window.
                if (block_number < target_block || block_number > target_block + call.grace_period()) throw;

                // Within the reserved call window so if there is a bidder, the
                // executor must be the biddor.
                if (block_number - target_block < CALL_WINDOW_SIZE) {
                    return (self.bidder == 0x0 || self.bidder == executor);
                }

                // Must be in the free-for-all period.
                return true;
        }
}

contract FutureCall {
        address public scheduler_address;

        uint public base_payment;
        uint public base_fee;

        // TODO: These *should* live on FutureBlockCall but I haven't figured
        // the modularity part out quite yet.  For now I'm going to muddle
        // these two concepts together for the sake of progress and pay this
        // debt down later.
        uint public target_block;
        uint8 public grace_period;

        CallLib.Call call;

        /*
         *  Data accessor functions.
         */
        function contract_address() constant returns (address) {
            return call.contract_address;
        }

        function abi_signature() constant returns (bytes4) {
            return call.abi_signature;
        }

        function call_data() constant returns (bytes) {
            return call.call_data;
        }

        function anchor_gas_price() constant returns (uint) {
            return call.anchor_gas_price;
        }

        function suggested_gas() constant returns (uint) {
            return call.suggested_gas;
        }

        function bidder() constant returns (address) {
            return call.bidder;
        }

        function bid_amount() constant returns (uint) {
            return call.bid_amount;
        }

        function bidder_deposit() constant returns (uint) {
            return call.bidder_deposit;
        }

        function was_successful() constant returns (bool) {
            return call.was_successful;
        }

        function was_called() constant returns (bool) {
            return call.was_called;
        }

        function is_cancelled() constant returns (bool) {
            return call.is_cancelled;
        }

        function get_bid_amount_for_block() constant returns (uint) {
            return CallLib.get_bid_amount_for_block(block.number);
        }

        function get_bid_amount_for_block(uint block_number) constant returns (uint) {
            return CallLib.get_bid_amount_for_block(block_number);
        }

        function () {
                // Fallback to allow sending funds to this contract.
                // Also allows call data registration.
                if (msg.sender == scheduler_address && msg.data.length > 0) {
                        if (call.call_data.length != 0) {
                            throw;
                        }
                        call.call_data = msg.data;
                }
        }

        modifier notcancelled { if (call.is_cancelled) throw; _ }

        // The author (Piper Merriam) address.
        address constant creator = 0xd3cda913deb6f67967b99d67acdfa1712c293601;

        function register_data() public notcancelled {
            if (msg.sender != scheduler_address || call.call_data.length > 0) {
                // cannot write over call data
                throw;
            }
            CallLib.extract_call_data(call, msg.data);
        }

        function claim() public notcancelled returns (bool) {
            bool success = CallLib.claim(call, msg.sender, msg.value, base_payment);
            if (!success) {
                if (!AccountingLib.sendRobust(msg.sender, msg.value)) throw;
            }
            return success;
        }

        function check_execution_authorization(address executor, uint block_number) constant returns (bool) {
            return CallLib.check_execution_authorization(call, executor, block_number);
        }

        // API for inherited contracts
        function before_execute(address executor) public returns (bool);
        function after_execute(address executor) internal;
        function get_overhead() constant returns (uint);
        function get_extra_gas() constant returns (uint);

        function send_safe(address to_address, uint value) internal {
            CallLib.send_safe(to_address, value);
        }

        function execute() public notcancelled {
            uint start_gas = msg.gas;

            // Check that the call should be executed now.
            if (!before_execute(msg.sender)) return;

            // Execute the call
            CallLib.execute(call, start_gas, msg.sender, get_overhead(), get_extra_gas());

            // Any logic that needs to occur after the call has executed should
            // go in after_execute
            after_execute(msg.sender);
        }
}

contract FutureBlockCall is FutureCall {
        // TODO: This it the *appropriate* place for these to live, but for
        // unfortunate reasons, they are present on the FutureCall contract
        // class.
        //uint public target_block;
        //uint8 public grace_period;

        function FutureBlockCall(address _scheduler_address, uint _target_block, uint8 _grace_period, address _contract_address, bytes4 _abi_signature, uint _suggested_gas, uint _base_payment, uint _base_fee) {
                // TODO: split this constructor across this contract and the
                // parent contract FutureCall
                scheduler_address = _scheduler_address;

                target_block = _target_block;
                grace_period = _grace_period;

                base_payment = _base_payment;
                base_fee = _base_fee;

                call.suggested_gas = _suggested_gas;
                call.anchor_gas_price = tx.gasprice;
                call.contract_address = _contract_address;
                call.abi_signature = _abi_signature;
        }

        function before_execute(address executor) public returns (bool) {
            if (block.number < target_block || block.number > target_block + grace_period) {
                // Not being called within call window.
                CallLib.CallAborted(executor, "NOT_IN_CALL_WINDOW");
                return false;
            }

            // If they are not authorized to execute the call at this time,
            // exit early.
            if (!CallLib.check_execution_authorization(call, executor, block.number)) {
                CallLib.CallAborted(executor, "NOT_AUTHORIZED");
                return;
            }

            return true;
        }

        function after_execute(address executor) internal {
            // Refund any leftover funds.
            CallLib.send_safe(scheduler_address, address(this).balance);
        }

        function get_overhead() constant returns (uint) {
                // TODO real numbers
                return 146000;
        }

        function get_extra_gas() constant returns (uint) {
                // TODO real numbers
                return 117000;
        }

        uint constant BID_GROWTH_WINDOW = 240;
        uint constant MAXIMUM_BID_WINDOW = 15;
        uint constant BEFORE_CALL_FREEZE_WINDOW = 10;

        function cancel() public notcancelled {
            // Before the bid window
            if (block.number < target_block - BEFORE_CALL_FREEZE_WINDOW - MAXIMUM_BID_WINDOW - BID_GROWTH_WINDOW) {
                // already cancelled
                if (msg.sender != scheduler_address) throw;
                CallLib.cancel(call, msg.sender);
                return;
            }
            if (block.number > target_block + grace_period) {
                // already called
                if (call.was_called) throw;
                CallLib.cancel(call, msg.sender);
                return;
            }
            throw;
        }
}


Soft cap check must be before hard cap. (if soft cap is reached, we still allow to process txn, unless the txn amount is so big that it also exceeds the hard cap)

pragma solidity ^0.4.15;
import './SmartTokenController.sol';
import './Utils.sol';
import './Managed.sol';
import './Pausable.sol';
import './SmartToken.sol';
import './interfaces/ISmartToken.sol';

/*

    The CrowdsaleController allows contributing ether in exchange for Rootcoin tokens
    The price remains fixed for the entire duration of the crowdsale
    Presale contributes are allocated (manually) with additional 20% tokens from the beneficiary tokens.
    Presale contribute mst use pre-verified addresses. (KYC)
*/
contract CrowdsaleController is SmartTokenController, Managed, Pausable {

    uint256 public constant MIN_CONTRIBUTION = 0.01 ether;      // general sale min contribution
    uint256 public constant DURATION = 14 days;                 // crowdsale duration
    uint256 public constant TOKEN_PRICE_N = 1;                  // initial price in wei (numerator)
    uint256 public constant TOKEN_PRICE_D = 1000;               // initial price in wei (denominator) (1000 wei equals 1 token)
    uint256 public constant MAX_GAS_PRICE = 50000000000 wei;    // maximum gas price for contribution transactions
    uint256 public constant MAX_CONTRIBUTION = 40 ether;        // maximum ether allowed to contribute by an unauthorized single account
    uint256 public constant SOFTCAP_GRACE_DURATION = 86400;     // crowdsale softcap reached grace duration in seconds (10 seconds for tests)
    uint256 public TOTAL_ETHER_CAP = 1000000 ether;             // overall ether contribution cap
    uint256 public TOTAL_ETHER_SOFT_CAP = 500000 ether;         // overall ether contribution soft cap

    //Presale constants
    uint256 public constant PRESALE_DURATION = 14 days;               // pressale duration
    uint256 public constant PRESALE_MIN_CONTRIBUTION = 200 ether;     // pressale min contribution

    //Token constants
    string public constant TOKEN_NAME = "Rootcoin"; //Token name
    string public constant TOKEN_SYM = "RCT";       //Token symbol
    uint8 public constant TOKEN_DEC = 18;           //Token decimals

    //State variables
    uint256 public startTime = 0;                   // crowdsale start time (in seconds)
    uint256 public endTime = 0;                     // crowdsale end time (in seconds)
    uint256 public totalEtherContributed = 0;       // ether contributed so far
    address public beneficiary = 0x0;               // address to receive all ether contributions
    mapping(address => bool) public whiteList;  //whitelist of accounts that can participate in presale and also contribute more than MAX_CONTRIBUTION

    // triggered on each contribution
    event Contribution(address indexed _contributor, uint256 _amount, uint256 _return);

    /**
        @dev constructor
        @param _startTime      crowdsale start time
        @param _beneficiary    address to receive all ether contributions
    */
    function CrowdsaleController(uint256 _startTime, address _beneficiary)
        SmartTokenController(new SmartToken(TOKEN_NAME, TOKEN_SYM, TOKEN_DEC))
        validAddress(_beneficiary)
        earlierThan(_startTime)
    {
        startTime = _startTime;
        endTime = startTime + DURATION;
        beneficiary = _beneficiary;
        token.disableTransfers(true);
    }

    // verifies that the gas price is lower than 50 gwei
    modifier validGasPrice() {
        assert(tx.gasprice <= MAX_GAS_PRICE);
        _;
    }

    // ensures that it's earlier than the given time
    modifier earlierThan(uint256 _time) {
        assert(now < _time);
        _;
    }

    // ensures that the current time is between _startTime (inclusive) and _endTime (exclusive)
    modifier between(uint256 _startTime, uint256 _endTime) {
        assert(now >= _startTime && now < _endTime);
        _;
    }

    // ensures that we didn't reach the soft ether cap, and sets the end time time when we do. Must be placed before the etherCapNotReached.
    modifier etherSoftCapNotReached(uint256 _contribution) {
        if (safeAdd(totalEtherContributed, _contribution) >= TOTAL_ETHER_SOFT_CAP) {
            endTime = now + SOFTCAP_GRACE_DURATION;
        }
        _;
    }

    // ensures that we didn't reach the ether cap
    modifier etherCapNotReached(uint256 _contribution) {
        assert(safeAdd(totalEtherContributed, _contribution) <= TOTAL_ETHER_CAP);
        _;
    }

    // verifies that the contribution is more than general minimum
    modifier validateMinPrice() {
        require(msg.value >= MIN_CONTRIBUTION);
        _;
    }

    // verifies that the presale contribution is more than presale minimum
    modifier validatePresaleMinPrice() {
        require(msg.value >= PRESALE_MIN_CONTRIBUTION);
        _;
    }

    // verifies that the presale contribution is from predefined address - TBD (not in use unless we decide to make a whitelist.)
    modifier validatePresaleAddress() {
         require(whiteList[msg.sender] == true);
        _;
    }

    // verifies that the total contributions from contributing account do not reach max alloewed unless it is on the whitelist.
    modifier maxAccountContributionNotReached() {
        assert(safeAdd(msg.value, safeMul(token.balanceOf(msg.sender), TOKEN_PRICE_N) / TOKEN_PRICE_D) <= MAX_CONTRIBUTION || whiteList[msg.sender]==true);
        _;
    }

    /**
        @dev computes the number of tokens that should be issued for a given contribution

        @param _contribution    contribution amount

        @return computed number of tokens
    */
    function computeReturn(uint256 _contribution) public constant returns (uint256) {
        // return safeMul(_contribution, TOKEN_PRICE_D) / TOKEN_PRICE_N;
        return safeMul(_contribution, TOKEN_PRICE_D);
    }

    /**
        @dev adds a whitelist address for which there is no max contribution and is alloewed to participate in the presale.

        @param _address    verified contributor address

        @return true
    */
    function addToWhitelist(address _address)
    public
    managerOnly
    returns (bool added)
    {
        whiteList[_address] = true;
        return true;
    }

    /**
        @dev removes a whitelist address for which there is no max contribution and is alloewed to participate in the presale.

        @param _address    verified contributor address to be removed

        @return true
    */
    function removeFromWhitelist(address _address)
    public
    managerOnly
    returns (bool added)
    {
        whiteList[_address] = false;
        return true;
    }

    /**
        @dev ETH contribution
        can only be called during the crowdsale

        @return tokens issued in return
    */
    function contributeETH()
        public
        payable
        between(startTime, endTime)
        whenNotPaused
        validateMinPrice
        maxAccountContributionNotReached
        returns (uint256 amount)
    {
        return processContribution();
    }

     /**
        @dev handles contribution during presale (min 200 ether)
        can only be called 14 days before the crowdsale start date

        @return tokens issued in return
    */
    function contributePreSale()
        public
        payable
        between(safeSub(startTime,PRESALE_DURATION), startTime)
        whenNotPaused
        validatePresaleMinPrice
        validatePresaleAddress
        returns (uint256 amount)
    {
        return processContribution();
    }

     /**
        @dev handles contribution with Fiat - for
        can only be called by manager

        @return tokens issued in return
    */
    function contributeFiat(address _contributor, uint256 _amount)
        public
        payable
        managerOnly
        between(safeSub(startTime,PRESALE_DURATION), safeAdd(startTime, DURATION))
        whenNotPaused
        returns (uint256 amount)
    {
        uint256 tokenAmount = computeReturn(_amount);

        totalEtherContributed = safeAdd(totalEtherContributed, _amount); // update the total contribution amount
        token.issue(_contributor, tokenAmount); // issue new funds to the contributor's address, provided by the manager, in the smart token
        token.issue(beneficiary, tokenAmount); // issue tokens to the beneficiary

        Contribution(_contributor, msg.value, tokenAmount);
        return tokenAmount;
    }

    /**
        @dev handles contribution logic
        note that the Contribution event is triggered using the sender as the contributor, regardless of the actual contributor

        @return tokens issued in return
    */
    function processContribution() private
        active
        etherSoftCapNotReached(msg.value)
        etherCapNotReached(msg.value)
        validGasPrice
        returns (uint256 amount)
    {
        uint256 tokenAmount = computeReturn(msg.value);
        assert(beneficiary.send(msg.value)); // transfer the ether to the beneficiary account
        totalEtherContributed = safeAdd(totalEtherContributed, msg.value); // update the total contribution amount
        token.issue(msg.sender, tokenAmount); // issue new funds to the contributor in the smart token
        token.issue(beneficiary, tokenAmount); // issue tokens to the beneficiary

        Contribution(msg.sender, msg.value, tokenAmount);
        return tokenAmount;
    }

    // fallback
    function() payable {
        contributeETH();
    }
}

pragma solidity ^0.4.15;
import './SmartTokenController.sol';
import './Utils.sol';
import './Managed.sol';
import './Pausable.sol';
import './SmartToken.sol';
import './interfaces/ISmartToken.sol';

/*
    Crowdsale v0.1

    The crowdsale version of the smart token controller, allows contributing ether in exchange for Rootcoin tokens
    The price remains fixed for the entire duration of the crowdsale
    Note that 20% of the contributions are for the Bancor token's reserve
    Presale contributes are allocated (manually) with additional 20% tokens from the beneficiary tokens.
*/
contract CrowdsaleController is SmartTokenController, Managed, Pausable {
    string public version = "0.1";

    uint256 public constant PRESALE_DURATION = 14 days;                 // pressale duration
    uint256 public constant PRESALE_MIN_CONTRIBUTION = 200 ether;     // pressale min contribution
    uint256 public constant MIN_CONTRIBUTION = 0.01 ether;      // general sale min contribution
    uint256 public constant DURATION = 14 days;                 // crowdsale duration
    uint256 public constant SOFTCAP_GRACE_DURATION = 10; //86400;    // crowdsale softcap reached grace duration in seconds (10 seconds for tests)
    uint256 public constant TOKEN_PRICE_N = 1;                  // initial price in wei (numerator)
    uint256 public constant TOKEN_PRICE_D = 1000;                // initial price in wei (denominator) (1000 wei equals 1 token)
    uint256 public constant MAX_GAS_PRICE = 50000000000 wei;    // maximum gas price for contribution transactions
    uint256 public constant MAX_CONTRIBUTION = 40 ether;    // maximum ether allowed to contribute by an unauthorized single account
    uint256 public TOTAL_ETHER_CAP = 1000000 ether;   // overall ether contribution cap
    uint256 public TOTAL_ETHER_SOFT_CAP = 500000 ether;   // overall ether contribution soft cap

    string public constant TOKEN_NAME = "Rootcoin"; //Token name
    string public constant TOKEN_SYM = "RCT";       //Token symbol
    uint8 public constant TOKEN_DEC = 18;           //Token decimals
    uint256 public startTime = 0;                   // crowdsale start time (in seconds)
    uint256 public endTime = 0;                     // crowdsale end time (in seconds)
    // uint256 public totalEtherSoftCapReached = 0;    // the time that the fost cap was reached set to 0 until reached
    uint256 public totalEtherContributed = 0;       // ether contributed so far
    address public beneficiary = 0x0;               // address to receive all ether contributions

    mapping(address => bool) public whiteList;  //whitelist of accounts that can participate in presale and also contribute more than MAX_CONTRIBUTION

    // triggered on each contribution
    event Contribution(address indexed _contributor, uint256 _amount, uint256 _return);

    /**
        @dev constructor
        @param _startTime      crowdsale start time
        @param _beneficiary    address to receive all ether contributions
    */
    function CrowdsaleController(uint256 _startTime, address _beneficiary)
        SmartTokenController(new SmartToken(TOKEN_NAME, TOKEN_SYM, TOKEN_DEC))
        validAddress(_beneficiary)
        earlierThan(_startTime)
    {
        startTime = _startTime;
        endTime = startTime + DURATION;
        beneficiary = _beneficiary;
        token.disableTransfers(true);
    }

    // verifies that the gas price is lower than 50 gwei
    modifier validGasPrice() {
        assert(tx.gasprice <= MAX_GAS_PRICE);
        _;
    }

    // ensures that it's earlier than the given time
    modifier earlierThan(uint256 _time) {
        assert(now < _time);
        _;
    }

    // ensures that the current time is between _startTime (inclusive) and _endTime (exclusive)
    modifier between(uint256 _startTime, uint256 _endTime) {
        assert(now >= _startTime && now < _endTime);
        _;
    }

    // ensures that we didn't reach the ether cap
    modifier etherCapNotReached(uint256 _contribution) {
        assert(safeAdd(totalEtherContributed, _contribution) <= TOTAL_ETHER_CAP);
        _;
    }

    // ensures that we didn't reach the soft ether cap, and sets the ent time time if we do
    modifier etherSoftCapNotReached(uint256 _contribution) {
        if (safeAdd(totalEtherContributed, _contribution) >= TOTAL_ETHER_SOFT_CAP) {
            endTime = now + SOFTCAP_GRACE_DURATION;
        }
        _;
    }

    // verifies that the contribution is more than general minimum
    modifier validateMinPrice() {
        require(msg.value >= MIN_CONTRIBUTION);
        _;
    }

    // verifies that the presale contribution is more than presale minimum
    modifier validatePresaleMinPrice() {
        require(msg.value >= PRESALE_MIN_CONTRIBUTION);
        _;
    }

    // verifies that the presale contribution is from predefined address - TBD (not in use unless we decide to make a whitelist.)
    modifier validatePresaleAddress() {
         require(whiteList[msg.sender] == true);
        _;
    }

    // verifies that the total contributions from contributing account do not reach max alloewed unless it is on the whitelist.
    modifier maxAccountContributionNotReached() {
        assert(safeAdd(msg.value, safeMul(token.balanceOf(msg.sender), TOKEN_PRICE_N) / TOKEN_PRICE_D) <= MAX_CONTRIBUTION || whiteList[msg.sender]==true);
        _;
    }

    /**
        @dev computes the number of tokens that should be issued for a given contribution

        @param _contribution    contribution amount

        @return computed number of tokens
    */
    function computeReturn(uint256 _contribution) public constant returns (uint256) {
        // return safeMul(_contribution, TOKEN_PRICE_D) / TOKEN_PRICE_N;
        return safeMul(_contribution, TOKEN_PRICE_D);
    }

    /**
        @dev adds a whitelist address for which there is no max contribution and is alloewed to participate in the presale.

        @param _address    verified contributor address

        @return true
    */
    function addToWhitelist(address _address)
    public
    managerOnly
    returns (bool added)
    {
        whiteList[_address] = true;
        return true;
    }

    /**
        @dev removes a whitelist address for which there is no max contribution and is alloewed to participate in the presale.

        @param _address    verified contributor address to be removed

        @return true
    */
    function removeFromWhitelist(address _address)
    public
    managerOnly
    returns (bool added)
    {
        whiteList[_address] = false;
        return true;
    }

    /**
        @dev ETH contribution
        can only be called during the crowdsale

        @return tokens issued in return
    */
    function contributeETH()
        public
        payable
        between(startTime, endTime)
        whenNotPaused
        validateMinPrice
        maxAccountContributionNotReached
        returns (uint256 amount)
    {
        return processContribution();
    }

     /**
        @dev handles contribution during presale (min 200 ether)
        can only be called 14 days before the crowdsale start date

        @return tokens issued in return
    */
    function contributePreSale()
        public
        payable
        between(safeSub(startTime,PRESALE_DURATION), startTime)
        whenNotPaused
        validatePresaleMinPrice
        validatePresaleAddress
        returns (uint256 amount)
    {
        return processContribution();
    }

     /**
        @dev handles contribution with Fiat - for
        can only be called by manager

        @return tokens issued in return
    */
    function contributeFiat(address _contributor, uint256 _amount)
        public
        payable
        managerOnly
        between(safeSub(startTime,PRESALE_DURATION), safeAdd(startTime, DURATION))
        whenNotPaused
        returns (uint256 amount)
    {
        uint256 tokenAmount = computeReturn(_amount);

        totalEtherContributed = safeAdd(totalEtherContributed, _amount); // update the total contribution amount
        token.issue(_contributor, tokenAmount); // issue new funds to the contributor's address, provided by the manager, in the smart token
        token.issue(beneficiary, tokenAmount); // issue tokens to the beneficiary

        Contribution(_contributor, msg.value, tokenAmount);
        return tokenAmount;
    }

    /**
        @dev handles contribution logic
        note that the Contribution event is triggered using the sender as the contributor, regardless of the actual contributor

        @return tokens issued in return
    */
    function processContribution() private
        active
        etherCapNotReached(msg.value)
        etherSoftCapNotReached(msg.value)
        validGasPrice
        returns (uint256 amount)
    {
        uint256 tokenAmount = computeReturn(msg.value);
        assert(beneficiary.send(msg.value)); // transfer the ether to the beneficiary account
        totalEtherContributed = safeAdd(totalEtherContributed, msg.value); // update the total contribution amount
        token.issue(msg.sender, tokenAmount); // issue new funds to the contributor in the smart token
        token.issue(beneficiary, tokenAmount); // issue tokens to the beneficiary

        Contribution(msg.sender, msg.value, tokenAmount);
        return tokenAmount;
    }

    // fallback
    function() payable {
        contributeETH();
    }
}


Create UnanimousConsentSignatureProxy.sol

Should probably think of a shorter name

contract UnanimousConsentSignatureProxy {
    address signer;
    address unanimousConsent;

    function UnanimousConsentSignatureProxy(address _signer, address _unanimousConsent) {
        signer = _signer;
        unanimousConsent = _unanimousConsent;
    }

    function forward(bytes32[] hashes, uint8[] v, bytes32[] r, bytes32[] s) returns(bool) {
        uint length = hashes.length;
        for (uint i = 0; i < length; ++i) {
            if (ecrecover(hashes[i], v[i], r[i], s[i]) != signer) {
                return false;
            }
        }
        return unanimousConsent.call(bytes4(sha3("consent(bytes32)")), hashes);
    }
}

error: pathspec 'contracts/UnanimousConsentSignatureProxy.sol' did not match any file(s) known to git


Set commit hash in LivepeerVerifier

Set commit hash in LivepeerVerifier

pragma solidity ^0.4.13;

import "../Manager.sol";
import "./IVerifier.sol";
import "./IVerifiable.sol";

contract LivepeerVerifier is Manager, IVerifier {
    // IPFS hash of verification computation archive
    string public verificationCodeHash;
    // Solvers that can submit results for requests
    address[] public solvers;
    // Track if an address is a solver
    mapping (address => bool) public isSolver;

    struct Request {
        uint256 jobId;
        uint256 claimId;
        uint256 segmentNumber;
        bytes32 commitHash;
    }

    mapping (uint256 => Request) public requests;
    uint256 public requestCount;

    // Check if sender is JobsManager
    modifier onlyJobsManager() {
        require(msg.sender == controller.getContract(keccak256("JobsManager")));
        _;
    }

    // Check if sender is a solver
    modifier onlySolvers() {
        require(isSolver[msg.sender]);
        _;
    }

    event VerifyRequest(uint256 indexed requestId, uint256 indexed jobId, uint256 indexed claimId, uint256 segmentNumber, string transcodingOptions, string dataStorageHash, bytes32 dataHash, bytes32 transcodedDataHash);
    event Callback(uint256 indexed requestId, uint256 indexed jobId, uint256 indexed claimId, uint256 segmentNumber, bool result);

    function LivepeerVerifier(address _controller, address[] _solvers, string _verificationCodeHash) Manager(_controller) {
        // Set solvers
        for (uint256 i = 0; i < _solvers.length; i++) {
            // Address must not already be a solver and must not be a null address
            require(!isSolver[_solvers[i]] && _solvers[i] != address(0));

            isSolver[_solvers[i]] = true;
        }
        solvers = _solvers;
        // Set verification code hash
        verificationCodeHash = _verificationCodeHash;
    }

    /*
     * @dev Fire VerifyRequest event which solvers should listen for to retrieve verification parameters
     */
    function verify(
        uint256 _jobId,
        uint256 _claimId,
        uint256 _segmentNumber,
        string _transcodingOptions,
        string _dataStorageHash,
        bytes32[2] _dataHashes
    )
        external
        payable
        onlyJobsManager
        returns (bool)
    {
        // Store request parameters
        requests[requestCount].jobId = _jobId;
        requests[requestCount].claimId = _claimId;
        requests[requestCount].segmentNumber = _segmentNumber;
        requests[requestCount].commitHash = keccak256(_dataHashes[0], _dataHashes[1]);

        VerifyRequest(requestCount, _jobId, _claimId, _segmentNumber, _transcodingOptions, _dataStorageHash, _dataHashes[0], _dataHashes[1]);

        // Update request count
        requestCount++;

        return true;
    }

    /*
     * @dev Callback function invoked by a solver to submit the result of a verification computation
     * @param _requestId Request identifier
     * @param _result Result of verification computation - keccak256 hash of transcoded segment data
     */
    function __callback(uint256 _requestId, bytes32 _result) external onlySolvers returns (bool) {
        Request memory q = requests[_requestId];

        // Check if transcoded data hash returned by solver matches originally submitted transcoded data hash
        if (q.commitHash == _result) {
            IVerifiable(controller.getContract(keccak256("JobsManager"))).receiveVerification(q.jobId, q.claimId, q.segmentNumber, true);
            Callback(_requestId, q.jobId, q.claimId, q.segmentNumber, true);
        } else {
            IVerifiable(controller.getContract(keccak256("JobsManager"))).receiveVerification(q.jobId, q.claimId, q.segmentNumber, false);
            Callback(_requestId, q.jobId, q.claimId, q.segmentNumber, false);
        }

        // Remove request
        delete requests[_requestId];

        return true;
    }

    /*
     * @dev Return price of verification which is zero for this implementation
     */
    function getPrice() public constant returns (uint256) {
        return 0;
    }
}

pragma solidity ^0.4.13;

import "../Manager.sol";
import "./IVerifier.sol";
import "./IVerifiable.sol";

contract LivepeerVerifier is Manager, IVerifier {
    // IPFS hash of verification computation archive
    string public verificationCodeHash;
    // Solvers that can submit results for requests
    address[] public solvers;
    // Track if an address is a solver
    mapping (address => bool) public isSolver;

    struct Request {
        uint256 jobId;
        uint256 claimId;
        uint256 segmentNumber;
        bytes32 transcodedDataHash;
    }

    mapping (uint256 => Request) public requests;
    uint256 public requestCount;

    // Check if sender is JobsManager
    modifier onlyJobsManager() {
        require(msg.sender == controller.getContract(keccak256("JobsManager")));
        _;
    }

    // Check if sender is a solver
    modifier onlySolvers() {
        require(isSolver[msg.sender]);
        _;
    }

    event VerifyRequest(uint256 indexed requestId, uint256 indexed jobId, uint256 indexed claimId, uint256 segmentNumber, string transcodingOptions, string dataStorageHash, bytes32 dataHash, bytes32 transcodedDataHash);
    event Callback(uint256 indexed requestId, uint256 indexed jobId, uint256 indexed claimId, uint256 segmentNumber, bool result);

    function LivepeerVerifier(address _controller, address[] _solvers, string _verificationCodeHash) Manager(_controller) {
        // Set solvers
        for (uint256 i = 0; i < _solvers.length; i++) {
            // Address must not already be a solver and must not be a null address
            require(!isSolver[_solvers[i]] && _solvers[i] != address(0));

            isSolver[_solvers[i]] = true;
        }
        solvers = _solvers;
        // Set verification code hash
        verificationCodeHash = _verificationCodeHash;
    }

    /*
     * @dev Fire VerifyRequest event which solvers should listen for to retrieve verification parameters
     */
    function verify(
        uint256 _jobId,
        uint256 _claimId,
        uint256 _segmentNumber,
        string _transcodingOptions,
        string _dataStorageHash,
        bytes32[2] _dataHashes
    )
        external
        payable
        onlyJobsManager
        returns (bool)
    {
        // Store request parameters
        requests[requestCount].jobId = _jobId;
        requests[requestCount].claimId = _claimId;
        requests[requestCount].segmentNumber = _segmentNumber;
        requests[requestCount].transcodedDataHash = _dataHashes[1];

        VerifyRequest(requestCount, _jobId, _claimId, _segmentNumber, _transcodingOptions, _dataStorageHash, _dataHashes[0], _dataHashes[1]);

        // Update request count
        requestCount++;

        return true;
    }

    /*
     * @dev Callback function invoked by a solver to submit the result of a verification computation
     * @param _requestId Request identifier
     * @param _result Result of verification computation - keccak256 hash of transcoded segment data
     */
    function __callback(uint256 _requestId, bytes32 _result) external onlySolvers returns (bool) {
        Request memory q = requests[_requestId];

        // Check if transcoded data hash returned by solver matches originally submitted transcoded data hash
        if (q.transcodedDataHash == _result) {
            IVerifiable(controller.getContract(keccak256("JobsManager"))).receiveVerification(q.jobId, q.claimId, q.segmentNumber, true);
            Callback(_requestId, q.jobId, q.claimId, q.segmentNumber, true);
        } else {
            IVerifiable(controller.getContract(keccak256("JobsManager"))).receiveVerification(q.jobId, q.claimId, q.segmentNumber, false);
            Callback(_requestId, q.jobId, q.claimId, q.segmentNumber, false);
        }

        // Remove request
        delete requests[_requestId];

        return true;
    }

    /*
     * @dev Return price of verification which is zero for this implementation
     */
    function getPrice() public constant returns (uint256) {
        return 0;
    }
}


Fix for solidity compiler warnings, issue #367. Crazy and temporary solution, but it's working.

pragma solidity ^0.4.11;

import "./CanReclaimToken.sol";

/**
 * @title Contracts that should not own Tokens
 * @author Remco Bloemen <remco@2π.com>
 * @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens.
 * Should tokens (any ERC20Basic compatible) end up in the contract, it allows the
 * owner to reclaim the tokens.
 */
contract HasNoTokens is CanReclaimToken {

 /**
  * @dev Reject all ERC23 compatible tokens
  * @param from_ address The address that is transferring the tokens
  * @param value_ uint256 the amount of the specified token
  * @param data_ Bytes The data passed from the caller.
  */
  function tokenFallback(address from_, uint256 value_, bytes data_) external {
    // revert();
    if(true || from_ == 0 || value_ == 0 || data_.length == 0 ) revert(); // Temporary fix for solidity compiler warning
  }

}

pragma solidity ^0.4.11;

import "./CanReclaimToken.sol";

/**
 * @title Contracts that should not own Tokens
 * @author Remco Bloemen <remco@2π.com>
 * @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens.
 * Should tokens (any ERC20Basic compatible) end up in the contract, it allows the
 * owner to reclaim the tokens.
 */
contract HasNoTokens is CanReclaimToken {

 /**
  * @dev Reject all ERC23 compatible tokens
  * @param from_ address The address that is transferring the tokens
  * @param value_ uint256 the amount of the specified token
  * @param data_ Bytes The data passed from the caller.
  */
  function tokenFallback(address from_, uint256 value_, bytes data_) external {
    revert();
  }

}


Fix BuilderDAO shares creation behaviour

//
// AIRA Builder for basic DAO contracts
//
// Ethereum address:
//  - Testnet:
//

import 'creator/CreatorTokenEmission.sol';
import 'creator/CreatorCore.sol';
import './Builder.sol';

contract BuilderDAO is Builder {
    function BuilderDAO(uint _price, address _cashflow, address _proposal)
             Builder(_price, _cashflow, _proposal)
    {}

    function create(string _dao_name, string _dao_description,
                    string _shares_name, string _shares_symbol, uint _shares_count) {
        // DAO core
        var dao = CreatorCore.create(_dao_name, _dao_description);

        var shares = CreatorTokenEmission.create(_shares_name, _shares_symbol, 0, _shares_count);
        shares.transfer(msg.sender, _shares_count);
        shares.delegate(msg.sender);

        // Append shares module
        dao.setModule(_shares_name, shares,
                      "github://airalab/core/token/TokenEmission.sol", true);

        // Delegate DAO to sender
        dao.delegate(msg.sender);

        // Notify
        deal(dao);
    }
}

//
// AIRA Builder for basic DAO contracts
//
// Ethereum address:
//  - Testnet:
//

import 'creator/CreatorTokenEmission.sol';
import 'creator/CreatorCore.sol';
import './Builder.sol';

contract BuilderDAO is Builder {
    function BuilderDAO(uint _price, address _cashflow, address _proposal)
             Builder(_price, _cashflow, _proposal)
    {}

    function create(string _dao_name, string _dao_description,
                    string _shares_name, string _shares_symbol, uint _shares_count) {
        // DAO core
        var dao = CreatorCore.create(_dao_name, _dao_description);

        var shares = CreatorTokenEmission.create(_shares_name, _shares_symbol, 0, _shares_count);
        shares.delegate(msg.sender);

        // Append shares module
        dao.setModule(_shares_name, shares,
                      "github://airalab/core/token/TokenEmission.sol", true);

        // Delegate DAO to sender
        dao.delegate(msg.sender);

        // Notify
        deal(dao);
    }
}


add external makeAssessment

add external makeAssessment

pragma solidity ^0.4.0;

import "./UserRegistry.sol";
import "./ConceptRegistry.sol";
import "./Assessment.sol";
import "./Math.sol";

/*
@type: contract
@name: Concept
@purpose: To store concept data and create and store information about assessments of this concept
*/
contract Concept {
  address[] public parents; //The concepts that this concept is child to (ie: Calculus is child to Math)
  address[] public children; //The concepts that this concept is parent to (ie: Math is parent to Calculus)
  address userRegistry; //The address of the userRegistry contract
  address conceptRegistry; //The address of the conceptRegistry contract
  uint public maxWeight; //The current highest weight for this assessment
  address[] public owners; //Those who have earned the concept
  mapping (address => int) public currentScores; //The most recent score of a user
  mapping (address => bool) public assessmentExists; //All existing assessments
  mapping (address => uint) public weights; //The weighting used by the assessor selection algorhitm for each owner
  mapping (address => mapping (address => uint)) public extMakeAssessmentAmount;

  modifier onlyUserRegistry() {
    if(msg.sender != userRegistry) //checks if msg.sender has the same address as userRegistry
    {
      throw; //throws the function call if not
    }
    _;
  }

  modifier onlyConceptRegistry() {
    if(msg.sender != conceptRegistry) //checks if msg.sender has the same address as conceptRegistry
    {
      throw; //throws the function call if not
    }
    _;
  }

  modifier onlyThis() {
    if(msg.sender != address(this)) {//Checks if msg.sender is this contract
      throw; //Throws out the function call if it isn't
    }
    _;
  }

  modifier onlyConcept(){
      if(!ConceptRegistry(conceptRegistry).conceptExists(msg.sender)) {
          throw;
      }
      _;
  }

  /*
  @type: event
  @name: CompletedAssessment
  @purpose: To build a database of completed assessments
  */
  event CompletedAssessment (
    address _assessee, //The address of the user who took the assessment
    int _score, //The score of the assessee
    address _assessment
  );

  function Concept(address[] _parents, address _userRegistry) {
    parents = _parents;
    userRegistry = _userRegistry;
    conceptRegistry = UserRegistry(userRegistry).conceptRegistry();
  }

  function getOwnerLength() constant returns(uint) {
    return owners.length;
  }

  function getParentsLength() constant returns(uint) {
    return parents.length;
  }

  function getChildrenLength() constant returns(uint) {
    return children.length;
  }

  /*
  @type: function
  @purpose: To add a user to the contract the first user for this concept
  @param: address firstUser = the address of the first user to own the concept
  @returns: nothing
  */
  function addFirstUser(address user) onlyUserRegistry() {
    if(ConceptRegistry(conceptRegistry).mewAddress() == address(this))
    {
      this.addOwner(user, 100);
    }
  }

  function addParent(address _parent) onlyConceptRegistry() {
    parents.push(_parent);
  }

  function addChild(address _child) onlyConceptRegistry() {
    children.push(_child);
  }

  function getRandomMember(uint seed) returns(address) {
    address randomUser = owners[Math.getRandom(seed, owners.length-1)];
    if(UserRegistry(userRegistry).availability(randomUser) && weights[randomUser] > now % maxWeight) {
        return randomUser;
     }
    return address(0x0);
  }

  /*
  @type: function
  @purpose: To make a new assessment
  @param: uint time = the time that assessors will have to assess in this assessment
  @param: uint size = the size of the assessment
  @returns: nothing
  */
  function makeAssessment(uint cost, uint size) returns(bool) {
    if(size >= 5 && subtractBalance(msg.sender, cost*size)) { //Checks if the assessment has a size of at least 5
      Assessment newAssessment = new Assessment(msg.sender, userRegistry, conceptRegistry, size, cost); //Makes a new assessment with the given parameters
      assessmentExists[address(newAssessment)] = true; //Sets the assessment's existance to true
      //User(msg.sender).notification(address(this), 19); //You have been charged for your assessment
      newAssessment.setAssessorPool(block.number, address(this), size*20); //Calls the function to set the assessor pool
      return true;
    }
    else {
      return false;
    }
  }

  function extMakeAssessment(address _assessee, uint _cost, uint _size) returns(bool) {
    if(extMakeAssessmentAmount[_assessee][msg.sender] >= _cost * _size &&
       _size >= 5 &&
       subtractBalance(_assessee, _cost*_size)) {
        Assessment newAssessment = new Assessment(_assessee, userRegistry, conceptRegistry, _size, _cost);
        assessmentExists[address(newAssessment)] = true;
        newAssessment.setAssessorPool(block.number, address(this), _size*20);
        extMakeAssessmentAmount[_assessee][msg.sender] -= _cost*_size;
    }
    else {
        return false;
    }
  }

  /*
  @type: function
  @purpose: To finish the assessment process
  @param: int score = the assessee's score
  @param: address assessee = the address of the assessee
  @param: address assessment = the address of the assessment
  @returns: nothing
  */
  function finishAssessment(int score, address assessee, address assessment) {
    if(msg.sender == assessment) { //Checks to make sure this function is being callled by the assessment
      if(score > 0) {
        owners.push(assessee); //Makes the assessee an owner of this concept
        uint weight = Assessment(assessment).size()*uint(score);
        this.addOwner(assessee, weight);
      }
      currentScores[assessee] = score; //Maps the assessee to their score
      CompletedAssessment(assessee, score, assessment); //Makes an event with this assessment's data
    }
  }

  /*
  @type: function
  @purpose: To add an owner to a concept and recursively add an owner to parent concept, halving the added weight with each generation and chinging the macWeight for a concept if neccisairy
  @param: bool pass = whether or not the assessee passed the assessment
  @param: address assessee = the address of the assessee
  @param: uint weight = the weight for the owner
  @returns: nothing
  */
  function addOwner(address assessee, uint weight) onlyConcept() {
    owners.push(assessee); //adds the owner to the array
    weights[assessee] += weight; //adds the weight to the current value in mapping
    if(weight > maxWeight) {//checks if the weight is greater than the currant maxWeight
      maxWeight = weight; //if so changes the maxWeight value
    }
    for(uint i = 0; i < parents.length; i++) {
      Concept(parents[i]).addOwner(assessee, weight/2); //recursively adds owner to all parent concepts but with half the weight
    }
  }

  function subtractBalance(address _from, uint _amount) returns(bool) {
    if(assessmentExists[msg.sender] || msg.sender == address(this)) { //Checks if msg.sender is an existing assessment
      return UserRegistry(userRegistry).subtractBalance(_from, _amount);
    }
  }

  function addBalance(address _to, uint _amount)  returns(bool) {
    if(assessmentExists[msg.sender]) { //Checks if msg.sender is an existing assessment
      return UserRegistry(userRegistry).addBalance(_to, _amount); //Changes the user's token balance
    }
  }

  function remove(address reciever) onlyThis() {
    suicide(reciever);
  }
}

pragma solidity ^0.4.0;

import "./UserRegistry.sol";
import "./ConceptRegistry.sol";
import "./Assessment.sol";
import "./Math.sol";

/*
@type: contract
@name: Concept
@purpose: To store concept data and create and store information about assessments of this concept
*/
contract Concept {
  address[] public parents; //The concepts that this concept is child to (ie: Calculus is child to Math)
  address[] public children; //The concepts that this concept is parent to (ie: Math is parent to Calculus)
  address userRegistry; //The address of the userRegistry contract
  address conceptRegistry; //The address of the conceptRegistry contract
  uint public maxWeight; //The current highest weight for this assessment
  address[] public owners; //Those who have earned the concept
  mapping (address => int) public currentScores; //The most recent score of a user
  mapping (address => bool) public assessmentExists; //All existing assessments
  mapping (address => uint) public weights; //The weighting used by the assessor selection algorhitm for each owner

  modifier onlyUserRegistry() {
    if(msg.sender != userRegistry) //checks if msg.sender has the same address as userRegistry
    {
      throw; //throws the function call if not
    }
    _;
  }

  modifier onlyConceptRegistry() {
    if(msg.sender != conceptRegistry) //checks if msg.sender has the same address as conceptRegistry
    {
      throw; //throws the function call if not
    }
    _;
  }

  modifier onlyThis() {
    if(msg.sender != address(this)) {//Checks if msg.sender is this contract
      throw; //Throws out the function call if it isn't
    }
    _;
  }

  modifier onlyConcept(){
      if(!ConceptRegistry(conceptRegistry).conceptExists(msg.sender)) {
          throw;
      }
      _;
  }

  /*
  @type: event
  @name: CompletedAssessment
  @purpose: To build a database of completed assessments
  */
  event CompletedAssessment (
    address _assessee, //The address of the user who took the assessment
    int _score, //The score of the assessee
    address _assessment
  );

  function Concept(address[] _parents, address _userRegistry) {
    parents = _parents;
    userRegistry = _userRegistry;
    conceptRegistry = UserRegistry(userRegistry).conceptRegistry();
  }

  function getOwnerLength() constant returns(uint) {
    return owners.length;
  }

  function getParentsLength() constant returns(uint) {
    return parents.length;
  }

  function getChildrenLength() constant returns(uint) {
    return children.length;
  }

  /*
  @type: function
  @purpose: To add a user to the contract the first user for this concept
  @param: address firstUser = the address of the first user to own the concept
  @returns: nothing
  */
  function addFirstUser(address user) onlyUserRegistry() {
    if(ConceptRegistry(conceptRegistry).mewAddress() == address(this))
    {
      this.addOwner(user, 100);
    }
  }

  function addParent(address _parent) onlyConceptRegistry() {
    parents.push(_parent);
  }

  function addChild(address _child) onlyConceptRegistry() {
    children.push(_child);
  }

  function getRandomMember(uint seed) returns(address) {
    address randomUser = owners[Math.getRandom(seed, owners.length-1)];
    if(UserRegistry(userRegistry).availability(randomUser) && weights[randomUser] > now % maxWeight) {
        return randomUser;
     }
    return address(0x0);
  }

  /*
  @type: function
  @purpose: To make a new assessment
  @param: uint time = the time that assessors will have to assess in this assessment
  @param: uint size = the size of the assessment
  @returns: nothing
  */
  function makeAssessment(uint cost, uint size) returns(bool) {
    if(size >= 5 && subtractBalance(msg.sender, cost*size)) { //Checks if the assessment has a size of at least 5
      Assessment newAssessment = new Assessment(msg.sender, userRegistry, conceptRegistry, size, cost); //Makes a new assessment with the given parameters
      assessmentExists[address(newAssessment)] = true; //Sets the assessment's existance to true
      //User(msg.sender).notification(address(this), 19); //You have been charged for your assessment
      newAssessment.setAssessorPool(block.number, address(this), size*20); //Calls the function to set the assessor pool
      return true;
    }
    else {
      return false;
    }
  }

  /*
  @type: function
  @purpose: To finish the assessment process
  @param: int score = the assessee's score
  @param: address assessee = the address of the assessee
  @param: address assessment = the address of the assessment
  @returns: nothing
  */
  function finishAssessment(int score, address assessee, address assessment) {
    if(msg.sender == assessment) { //Checks to make sure this function is being callled by the assessment
      if(score > 0) {
        owners.push(assessee); //Makes the assessee an owner of this concept
        uint weight = Assessment(assessment).size()*uint(score);
        this.addOwner(assessee, weight);
      }
      currentScores[assessee] = score; //Maps the assessee to their score
      CompletedAssessment(assessee, score, assessment); //Makes an event with this assessment's data
    }
  }

  /*
  @type: function
  @purpose: To add an owner to a concept and recursively add an owner to parent concept, halving the added weight with each generation and chinging the macWeight for a concept if neccisairy
  @param: bool pass = whether or not the assessee passed the assessment
  @param: address assessee = the address of the assessee
  @param: uint weight = the weight for the owner
  @returns: nothing
  */
  function addOwner(address assessee, uint weight) onlyConcept() {
    owners.push(assessee); //adds the owner to the array
    weights[assessee] += weight; //adds the weight to the current value in mapping
    if(weight > maxWeight) {//checks if the weight is greater than the currant maxWeight
      maxWeight = weight; //if so changes the maxWeight value
    }
    for(uint i = 0; i < parents.length; i++) {
      Concept(parents[i]).addOwner(assessee, weight/2); //recursively adds owner to all parent concepts but with half the weight
    }
  }

  function subtractBalance(address _from, uint _amount) returns(bool) {
    if(assessmentExists[msg.sender] || msg.sender == address(this)) { //Checks if msg.sender is an existing assessment
      return UserRegistry(userRegistry).subtractBalance(_from, _amount);
    }
  }

  function addBalance(address _to, uint _amount)  returns(bool) {
    if(assessmentExists[msg.sender]) { //Checks if msg.sender is an existing assessment
      return UserRegistry(userRegistry).addBalance(_to, _amount); //Changes the user's token balance
    }
  }

  function remove(address reciever) onlyThis() {
    suicide(reciever);
  }
}


added SWAP.sol

added SWAP.sol

pragma solidity ^0.4.0;
contract Swap {

	struct SwapTransactionObj {
        uint pvn_to_ether_amt;
        uint eth_to_pvn_amt;
        address eth_addr;
        address pvn_addr;
        uint exchange_rate;
        uint timestamp;
        bytes32 hash;
        bool isTx;
	}
    mapping (bytes32 => SwapTransactionObj) swapTransactions;
    bytes32[] public swapTransactionList;
    mapping (address => uint) eth_balance;
    mapping (address => uint) pvn_balance;

    function is_transaction(bytes32 _transaction_hash) public constant returns(bool isIndeed) {
	    return swapTransactions[_transaction_hash].isTx;
    }

    function get_transaction_count() public constant returns(uint transactionCount) {
	 return swapTransactionList.length;
    }

    function make_hash(uint _pvn_to_eth_amt, uint _eth_to_pvn_amt, address _eth_addr, address _pvn_addr, uint _exchange_rate) public returns (bytes32 hash) {
        //hash = bytes32(_pvn_to_eth_amt);

        hash = bytes32(_pvn_to_eth_amt) | bytes32(_eth_to_pvn_amt);
        hash = hash | bytes32(_eth_addr);
        hash = hash | bytes32(_pvn_addr);
        hash = hash | bytes32(block.timestamp);
        hash = hash | bytes32(_exchange_rate);
    }

    function new_transaction(uint _pvn_to_eth_amt, uint _eth_to_pvn_amt, address _eth_addr, address _pvn_addr, uint _exchange_rate) public returns (uint rowNumber) {
        bytes32 _hash = make_hash(_pvn_to_eth_amt, _eth_to_pvn_amt, _eth_addr, _pvn_addr, _exchange_rate);

	    if(is_transaction(_hash)) revert();
	    require( _pvn_to_eth_amt * _eth_to_pvn_amt ==0 );
	    require (_pvn_to_eth_amt>0 || _eth_to_pvn_amt>0);

	    // converting from pvn_eth to eth
	    if (_pvn_to_eth_amt > 0 && _eth_to_pvn_amt ==0) {

	        require( pvn_balance[_pvn_addr] - _pvn_to_eth_amt > 0);
	        eth_balance[_eth_addr] += (_pvn_to_eth_amt / master_exchange_rate);
	        pvn_balance[_pvn_addr] -= (_pvn_to_eth_amt);
	    }

	    // converting from eth to pvn_eth
	    if (_eth_to_pvn_amt > 0 && _pvn_to_eth_amt==0) {

	        require( eth_balance[_eth_addr] - _eth_to_pvn_amt > 0 );
	        eth_balance[_eth_addr] -= _eth_to_pvn_amt;
	        pvn_balance[_pvn_addr] += (_eth_to_pvn_amt * master_exchange_rate);
	    }

	    swapTransactions[_hash] = SwapTransactionObj({
	        pvn_to_ether_amt: _pvn_to_eth_amt,
	        eth_to_pvn_amt: _eth_to_pvn_amt,
	        eth_addr: _eth_addr,
	        pvn_addr: _pvn_addr,
	        exchange_rate: _exchange_rate,
	        timestamp: block.timestamp,
	        hash: _hash,
	        isTx: true

	    });

	    return swapTransactionList.push(_hash)-1;

    }

    address public owner;
    uint master_exchange_rate;
    string[5] greetings;

    function Swap() public payable {
	  owner = msg.sender;
	  master_exchange_rate = 1000;

	  greetings[0] = "Hi, my name is Omar Metwally.";
	  greetings[1] = "I am the creator of this contract.";
	  greetings[2] = "Black Swan Lives!";
	  greetings[3] = "Watching Parnassus on a beautiful, sunny day in SF...";
	  greetings[4] = "Healthcare is a human right.";
	}

	/*
    event NewRecord (
	owner_name, owner_address, ipfs_hash, description, shared_with_fingerprint, shared_by_fingerprint);

    function add_record(string _owner_name, address _owner_address, string _fname, string _ipfs_hash, string _description ) public returns (uint rowNumber) {
	if (is_record(_ipfs_hash)) {
        update_record( _owner_name, _owner_address, _fname, _ipfs_hash, _description );
	} else {
	    new_record(_owner_name, _owner_address, _fname, _ipfs_hash, _description );
	   // RecordCreated(_owner_name, _ipfs_hash, _description );
	}

    }

    function update_record( string _owner_name, address _owner_address, string _fname, string _ipfs_hash, string _description ) public  {
            if(!is_record(_ipfs_hash)) revert();
            recordStructs[_ipfs_hash].owner_name=_owner_name;
            recordStructs[_ipfs_hash].owner_address=_owner_address;
            recordStructs[_ipfs_hash].fname=_fname;
			recordStructs[_ipfs_hash].ipfs_hash=_ipfs_hash;
            recordStructs[_ipfs_hash].descr=_description;
        }
    */

    /* Generates a random number from 0 to 10 based on the last block hash */
    function randomGen(uint seed) public constant returns (uint randomNumber) {
        return(uint(sha3(block.blockhash(block.number-1), seed ))%10);
    }

	/*
	event RecordCreated (
		string _owner_name,
		address _owner_address,
		string _fname,
		string _ipfs_hash,
		string _description
	);
    */

	function get_transaction_by_row(uint row) public constant returns (uint pvn_to_ether_amt, uint eth_to_pvn_amt, address eth_addr, address pvn_addr, uint exchange_rate, uint timestamp, bytes32 hash) {

	   require(row<swapTransactionList.length);
	   require(row>=0);

	   pvn_to_ether_amt=swapTransactions[swapTransactionList[row]].pvn_to_ether_amt;
	   eth_to_pvn_amt=swapTransactions[swapTransactionList[row]].eth_to_pvn_amt;
	   eth_addr=swapTransactions[swapTransactionList[row]].eth_addr;
	   pvn_addr=swapTransactions[swapTransactionList[row]].pvn_addr;
	   exchange_rate=swapTransactions[swapTransactionList[row]].exchange_rate;
	   timestamp=swapTransactions[swapTransactionList[row]].timestamp;
	   hash=swapTransactions[swapTransactionList[row]].hash;
	}

	function set_master_exchange_rate(uint new_rate) public constant returns (uint exchange_rate) {
	    require(msg.sender == owner);
	    master_exchange_rate = new_rate;
	    return master_exchange_rate;
	}

    /*
	function get_record_by_ipfs_hash(string ipfs_hash) public constant returns (string _owner_name, address _owner_address, string _fname, string _ipfs_hash, string _description ) {

	   require(is_record(ipfs_hash));

	   _owner_name=recordStructs[ipfs_hash].owner_name;
	   _owner_address=recordStructs[ipfs_hash].owner_address;
	   _fname=recordStructs[ipfs_hash].fname;
	   _ipfs_hash=recordStructs[ipfs_hash].ipfs_hash;
	   _description=recordStructs[ipfs_hash].descr;
	}
	*/

	function greet_omar(uint _i) public constant returns (string greeting) {
		require(_i>=0);
		require(_i<greetings.length);
		return greetings[_i];
	}

	function die() public {
			if (msg.sender == owner) {

				selfdestruct(owner);
			}
	}
}

error: pathspec 'ddash/source/swap.sol' did not match any file(s) known to git