// SPDX-License-Identifier: Unlicense pragma solidity ^0.8.24; import "./core/DAO.sol"; import "./core/Forum.sol"; import "./WorkContract.sol"; import "./interfaces/IOnValidate.sol"; contract Onboarding is WorkContract, IOnValidate { constructor( DAO dao_, Proposals proposals_, uint price_ ) WorkContract(dao_, proposals_, price_) {} /// Accept work approval/disapproval from customer function submitWorkApproval( uint requestIndex, bool approval ) external override { WorkRequest storage request = requests[requestIndex]; require( request.status == WorkStatus.EvidenceSubmitted, "Status must be EvidenceSubmitted" ); AvailabilityStake storage stake = stakes[request.stakeIndex]; request.status = WorkStatus.ApprovalSubmitted; request.approval = approval; // Make work evidence post Author[] memory authors = new Author[](1); authors[0] = Author(100, stake.worker); dao.addPost(authors, request.evidenceContentId, request.citations); emit WorkApprovalSubmitted(requestIndex, approval); // Initiate validation pool uint poolIndex = dao.initiateValidationPool{ value: request.fee - request.fee / 10 }( request.evidenceContentId, POOL_DURATION, [uint256(1), uint256(3)], [uint256(1), uint256(2)], 100, true, true, abi.encode(requestIndex) ); // We have an approval from stake.worker to transfer up to stake.amount dao.delegatedStakeOnValidationPool( poolIndex, stake.worker, stake.amount, true ); } /// Callback to be executed when review pool completes function onValidate( bool votePasses, bool quorumMet, uint, uint, bytes calldata callbackData ) external returns (uint) { require( msg.sender == address(dao), "onValidate may only be called by the DAO contract" ); uint requestIndex = abi.decode(callbackData, (uint)); WorkRequest storage request = requests[requestIndex]; if (!votePasses || !quorumMet) { // refund the customer the remaining amount payable(request.customer).transfer(request.fee / 10); return 1; } // Make onboarding post Citation[] memory emptyCitations; Author[] memory authors = new Author[](1); authors[0] = Author(100, request.customer); dao.addPost(authors, request.requestContentId, emptyCitations); dao.initiateValidationPool{value: request.fee / 10}( request.requestContentId, POOL_DURATION, [uint256(1), uint256(3)], [uint256(1), uint256(2)], 100, true, false, "" ); return 0; } }