Skip to content

Commit

Permalink
Merge pull request #35 from opencog/enhancement/minor-cleanups-market
Browse files Browse the repository at this point in the history
enhancement/minor-cleanups-market
  • Loading branch information
tiero authored Oct 10, 2017
2 parents d37d4a7 + ec5772d commit 28ab909
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
17 changes: 6 additions & 11 deletions dao/contracts/MarketJob.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity^0.4.11;
pragma solidity ^0.4.11;

import "./ownership/ownable.sol";

Expand All @@ -8,12 +8,8 @@ contract MarketJob is ownable {
bytes public lastPacket;
bytes public firstPacket;
bool public jobCompleted;
mapping (address => uint) public amounts;

modifier allowed {
require(amounts[msg.sender] != 0);
_;
}
mapping (address => uint) public amounts;

modifier jobDone {
require(jobCompleted == true);
Expand Down Expand Up @@ -42,16 +38,15 @@ contract MarketJob is ownable {
}
}

// todo: review since tests fail
function withdraw() payable allowed jobDone external {
require(amounts[msg.sender] == msg.value);
uint amount = amounts[msg.sender];
function withdraw() external jobDone {
require(amounts[msg.sender] > 0);
uint256 amount = amounts[msg.sender];

amounts[msg.sender] = 0;
msg.sender.transfer(amount);
}

function setJobCompleted() jobPending external {
function setJobCompleted() external jobPending {
jobCompleted = true;
}
}
12 changes: 4 additions & 8 deletions dao/contracts/agent/Agent.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ import "../ownership/ownable.sol";
contract Agent is AgentInterface, ownable {

bytes[] public packets;
MarketJob market;
uint tokenAmount;
MarketJob job;

function() payable {
tokenAmount = msg.value;
}
function() payable { }

function sendPacket(address target, bytes packet) external onlyOwner {
Agent(target).appendPacket(packet);
Expand All @@ -29,9 +26,8 @@ contract Agent is AgentInterface, ownable {
return packets[id];
}

function appendJob(address[] agents, uint[] amounts, address payer, bytes firstPacket, bytes lastPacket) external constant returns (address) {
market = new MarketJob(agents, amounts, payer, firstPacket, lastPacket);
return market;
function setJob(MarketJob _job) external returns (address) {
job = _job;
}

}

0 comments on commit 28ab909

Please sign in to comment.