// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import "@openzeppelin/contracts/utils/Multicall.sol"; import "@openzeppelin/contracts/interfaces/IERC721Receiver.sol"; import "./IUniverseWizardV1.sol"; import "../utils/WarperWizardsHelperV1.sol"; import "../../../universe/universe-token/UniverseToken.sol"; import "../../../contract-registry/ContractEntity.sol"; import "../../../contract-registry/Contracts.sol"; contract UniverseWizardV1 is IUniverseWizardV1, IERC721Receiver, ContractEntity, Multicall { /** * @dev Universe Wizard constructor */ constructor(address metahub) { _metahub = IMetahub(metahub); } function setupUniverse(IUniverseRegistry.UniverseParams calldata universeParams) external returns (uint256 universeId) { IUniverseRegistry universeRegistry = IUniverseRegistry(_metahub.getContract(Contracts.UNIVERSE_REGISTRY)); universeId = universeRegistry.createUniverse(universeParams); UniverseToken(universeRegistry.universeToken()).safeTransferFrom(address(this), msg.sender, universeId); } /** * @inheritdoc IUniverseWizardV1 */ function setupUniverseAndWarper( IUniverseRegistry.UniverseParams calldata universeParams, ITaxTermsRegistry.TaxTerms calldata universeWarperTaxTerms, address existingWarperAddress, IWarperManager.WarperRegistrationParams memory warperRegistrationParams, bytes32 warperPresetId, bytes calldata warperInitData ) external returns (uint256 universeId, address deployedWarperAddress) { IUniverseRegistry universeRegistry = IUniverseRegistry(_metahub.getContract(Contracts.UNIVERSE_REGISTRY)); universeId = universeRegistry.createUniverse(universeParams); warperRegistrationParams.universeId = universeId; deployedWarperAddress = WarperWizardsHelperV1.deployWarperFromPresetOrReturnExistingOne( existingWarperAddress, warperPresetId, warperInitData, _metahub ); WarperWizardsHelperV1.registerWarperAndCheckTaxTermsExist( deployedWarperAddress, universeWarperTaxTerms, warperRegistrationParams, _metahub ); UniverseToken(universeRegistry.universeToken()).safeTransferFrom(address(this), msg.sender, universeId); } // solhint-disable no-unused-vars function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4) { return IERC721Receiver.onERC721Received.selector; } /** * @inheritdoc IContractEntity */ function contractKey() external pure override returns (bytes4) { return Contracts.UNIVERSE_WIZARD_V1; } /** * @inheritdoc IERC165 */ function supportsInterface(bytes4 interfaceId) public view override(ContractEntity, IERC165) returns (bool) { return interfaceId == type(IUniverseWizardV1).interfaceId || super.supportsInterface(interfaceId); } }