From ec5772d54a9f471a526b57eb5e3ba7f5ce4006ed Mon Sep 17 00:00:00 2001 From: decanus Date: Tue, 10 Oct 2017 19:57:41 +0200 Subject: [PATCH] Minor cleanup of market job --- dao/contracts/MarketJob.sol | 17 ++++++----------- dao/contracts/agent/Agent.sol | 12 ++++-------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/dao/contracts/MarketJob.sol b/dao/contracts/MarketJob.sol index f1eb926..871d520 100644 --- a/dao/contracts/MarketJob.sol +++ b/dao/contracts/MarketJob.sol @@ -1,4 +1,4 @@ -pragma solidity^0.4.11; +pragma solidity ^0.4.11; import "./ownership/ownable.sol"; @@ -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); @@ -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; } } \ No newline at end of file diff --git a/dao/contracts/agent/Agent.sol b/dao/contracts/agent/Agent.sol index c468d59..5d9e073 100644 --- a/dao/contracts/agent/Agent.sol +++ b/dao/contracts/agent/Agent.sol @@ -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); @@ -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; } } \ No newline at end of file