// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.6.12; import "./TimeLockedWallet.sol"; contract TimeLockedWalletFactory { TimeLockedWallet[] public wallets; mapping(address => TimeLockedWallet[]) wals; event TimeLockedWalletCreated(address _creator, address _owner); function getWallets(address _user) public view returns (TimeLockedWallet[] memory) { return wals[_user]; } function createTimeLockedWallet( address _owner, IERC20 _token, uint256 _unlockDate ) external { TimeLockedWallet wallet = new TimeLockedWallet( _owner, _token, _unlockDate ); wallets.push(wallet); // Add wallet to sender's wallets. wals[msg.sender].push(wallet); // If owner is the same as sender then add wallet to sender's wallets too. if (msg.sender != _owner) { wals[_owner].push(wallet); } // Emit event. Created(wallet, msg.sender, _owner, block.timestamp, _unlockDate); } // Prevents accidental sending of ether to the factory receive() external payable { revert(); } event Created( TimeLockedWallet wallet, address from, address to, uint256 createdAt, uint256 unlockDate ); }