diff --git a/ethereum/contracts/RollableWorkContract.sol b/ethereum/contracts/RollableWorkContract.sol index d5177a2..f4995e7 100644 --- a/ethereum/contracts/RollableWorkContract.sol +++ b/ethereum/contracts/RollableWorkContract.sol @@ -34,39 +34,18 @@ abstract contract RollableWorkContract is WorkContract { // Make work evidence post Author[] memory authors = new Author[](1); authors[0] = Author(1000000, stake.worker); + dao.addPost(authors, request.evidenceContentId, request.citations); - // TODO: send post and fee to rollup contract + // send worker stakes and customer fee to rollup contract dao.forwardAllowance( stake.worker, address(rollupContract), stake.amount ); - payable(address(rollupContract)).transfer(request.fee); - rollupContract.addItem( + rollupContract.addItem{value: request.fee}( stake.worker, stake.amount, - request.fee, request.evidenceContentId ); - - // dao.addPost(authors, request.evidenceContentId, request.citations); - // Initiate validation pool - uint poolIndex = dao.initiateValidationPool{value: request.fee}( - request.evidenceContentId, - POOL_DURATION, - [uint256(1), uint256(3)], - [uint256(1), uint256(2)], - 100, - true, - false, - "" - ); - // We have an approval from stake.worker to transfer up to stake.amount - dao.delegatedStakeOnValidationPool( - poolIndex, - stake.worker, - stake.amount, - true - ); } } diff --git a/ethereum/contracts/Rollup.sol b/ethereum/contracts/Rollup.sol index 29e34bb..39abe37 100644 --- a/ethereum/contracts/Rollup.sol +++ b/ethereum/contracts/Rollup.sol @@ -22,13 +22,12 @@ contract Rollup is Availability { function addItem( address worker, uint stakeAmount, - uint fee, string calldata evidenceContentId - ) public { + ) public payable { BatchItem storage item = items[itemCount++]; item.worker = worker; item.stakeAmount = stakeAmount; - item.fee = fee; + item.fee = msg.value; item.evidenceContentId = evidenceContentId; } diff --git a/ethereum/contracts/core/DAO.sol b/ethereum/contracts/core/DAO.sol index 023454e..ab77c17 100644 --- a/ethereum/contracts/core/DAO.sol +++ b/ethereum/contracts/core/DAO.sol @@ -14,7 +14,7 @@ contract DAO is Reputation, Forum, ValidationPools { uint256 value, uint duration ) external returns (bool) { - _approve(msg.sender, to, value); + _approve(msg.sender, to, allowance(msg.sender, to) + value); IAcceptAvailability(to).acceptAvailability(msg.sender, value, duration); return true; } diff --git a/ethereum/contracts/core/ValidationPools.sol b/ethereum/contracts/core/ValidationPools.sol index 391906d..a0f7a16 100644 --- a/ethereum/contracts/core/ValidationPools.sol +++ b/ethereum/contracts/core/ValidationPools.sol @@ -86,6 +86,9 @@ contract ValidationPools is Reputation, Forum { bool inFavor ) public { ValidationPool storage pool = validationPools[poolIndex]; + if (allowance(owner, msg.sender) < amount) { + amount = allowance(owner, msg.sender); + } _spendAllowance(owner, msg.sender, amount); _stakeOnValidationPool(pool, owner, amount, inFavor); }