/* Crafted with love by Fueled on Bacon https://fueledonbacon.com */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "../NFTWallet.sol"; contract NFTWalletFactory is Ownable, AccessControl { error UserAlreadyHasAWallet(); event NewWallet(uint256 userId, address wallet); address private _adminRole; mapping(uint256 => address) public userToWallet; constructor(address adminRole) { _adminRole = adminRole; _setupRole(DEFAULT_ADMIN_ROLE, adminRole); } function setAdminRole(address adminRole) external onlyOwner { _adminRole = adminRole; } function deployWallet(uint256 userId) external onlyRole(DEFAULT_ADMIN_ROLE) { if(userToWallet[userId] != address(0)) revert UserAlreadyHasAWallet(); NFTWallet newWallet = new NFTWallet(_adminRole); address wallet = address(newWallet); userToWallet[userId] = wallet; emit NewWallet(userId, wallet); } }