delegated stake minor improvements
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 32s Details

This commit is contained in:
Ladd Hoffman 2024-04-28 17:45:07 -05:00
parent 37fd387cf3
commit 08dee20a29
4 changed files with 9 additions and 28 deletions

View File

@ -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
);
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}