From 517fa6970cbbdafcb0e1ea9763ef5e79be71f758 Mon Sep 17 00:00:00 2001 From: Afrasiyab Haider Date: Tue, 7 Jan 2025 14:49:01 +0000 Subject: [PATCH] Implement receive function to handle received ETH in Ethlance.sol implements the TODO in the receive function of the Ethlance.sol contract to handle received ETH. The function constructs _offeredValues from msg.value and calls _createJobWithPassedData with the decoded msg.data. Changes: Implement receive function to handle received ETH. Construct _offeredValues from msg.value. Call _createJobWithPassedData with the decoded msg.data. Impact: This change ensures that the contract correctly handles incoming ETH and creates jobs accordingly, improving the functionality and robustness of the Ethlance platform. --- contracts/Ethlance.sol | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/contracts/Ethlance.sol b/contracts/Ethlance.sol index 30144d58..942c2a45 100644 --- a/contracts/Ethlance.sol +++ b/contracts/Ethlance.sol @@ -409,17 +409,22 @@ contract Ethlance is IERC721Receiver, IERC1155Receiver, DSAuth { return bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")); } - /** * @dev This function is called automatically when this contract receives ETH * It calls {_createJob} where: * - passed `_offerer` is `msg.sender` * - passed `_offeredValues` are constructed from `msg.value` * - rest of arguments is obtained by decoding `msg.data` - * TODO: Needs implementation */ - receive( - ) external payable { + receive() external payable { + EthlanceStructs.TokenValue[] memory offeredValues = new EthlanceStructs.TokenValue[](1); + offeredValues[0] = EthlanceStructs.TokenValue({ + token: address(0), + value: msg.value + }); + + bytes memory data = msg.data; + _createJobWithPassedData(data); } function supportsInterface(bytes4 interfaceId) external override pure returns (bool) {