|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity 0.8.26; |
| 3 | + |
| 4 | +import { IStoryNFT } from "./IStoryNFT.sol"; |
| 5 | + |
| 6 | +/// @title Story NFT Factory Interface |
| 7 | +/// @notice Story NFT Factory is the entrypoint for creating new Story NFT collections. |
| 8 | +interface IStoryNFTFactory { |
| 9 | + //////////////////////////////////////////////////////////////////////////// |
| 10 | + // Errors // |
| 11 | + //////////////////////////////////////////////////////////////////////////// |
| 12 | + /// @notice Invalid signature provided to StoryNFTFactory functions. |
| 13 | + /// @param signature The signature that is invalid. |
| 14 | + error StoryNFTFactory__InvalidSignature(bytes signature); |
| 15 | + |
| 16 | + /// @notice NftTemplate is not whitelisted to be used as a StoryNFT. |
| 17 | + /// @param nftTemplate The NFT template that is not whitelisted. |
| 18 | + error StoryNFTFactory__NftTemplateNotWhitelisted(address nftTemplate); |
| 19 | + |
| 20 | + /// @notice Organization is already deployed by the StoryNFTFactory. |
| 21 | + /// @param orgName The name of the organization that is already deployed. |
| 22 | + /// @param deployedStoryNft The address of the already deployed StoryNFT for the organization. |
| 23 | + error StoryNFTFactory__OrgAlreadyDeployed(string orgName, address deployedStoryNft); |
| 24 | + |
| 25 | + /// @notice Organization is not found in the StoryNFTFactory. |
| 26 | + /// @param orgName The name of the organization that is not found. |
| 27 | + error StoryNFTFactory__OrgNotFoundByOrgName(string orgName); |
| 28 | + |
| 29 | + /// @notice Organization is not found in the StoryNFTFactory. |
| 30 | + /// @param orgTokenId The token ID of the organization that is not found. |
| 31 | + error StoryNFTFactory__OrgNotFoundByOrgTokenId(uint256 orgTokenId); |
| 32 | + |
| 33 | + /// @notice Organization is not found in the StoryNFTFactory. |
| 34 | + /// @param orgIpId The ID of the organization IP that is not found. |
| 35 | + error StoryNFTFactory__OrgNotFoundByOrgIpId(address orgIpId); |
| 36 | + |
| 37 | + /// @notice Signature is already used to deploy a StoryNFT. |
| 38 | + /// @param signature The signature that is already used. |
| 39 | + error StoryNFTFactory__SignatureAlreadyUsed(bytes signature); |
| 40 | + |
| 41 | + /// @notice BaseStoryNFT is not supported by the StoryNFTFactory. |
| 42 | + /// @param tokenContract The address of the token contract that does not implement IStoryNFT. |
| 43 | + error StoryNFTFactory__UnsupportedIStoryNFT(address tokenContract); |
| 44 | + |
| 45 | + /// @notice Zero address provided as a param to StoryNFTFactory functions. |
| 46 | + error StoryNFTFactory__ZeroAddressParam(); |
| 47 | + |
| 48 | + //////////////////////////////////////////////////////////////////////////// |
| 49 | + // Events // |
| 50 | + //////////////////////////////////////////////////////////////////////////// |
| 51 | + /// @notice Emitted when the default StoryNFT template is updated. |
| 52 | + /// @param defaultStoryNftTemplate The new default StoryNFT template. |
| 53 | + event StoryNFTFactoryDefaultStoryNftTemplateUpdated(address defaultStoryNftTemplate); |
| 54 | + |
| 55 | + /// @notice Emitted when a new orgnization NFT is minted and a new StoryNFT associated with it is deployed. |
| 56 | + /// @param orgName The name of the organization. |
| 57 | + /// @param orgNft The address of the organization NFT. |
| 58 | + /// @param orgTokenId The token ID of the organization NFT. |
| 59 | + /// @param orgIpId The ID of the organization IP. |
| 60 | + /// @param storyNft The address of the deployed StoryNFT. |
| 61 | + event StoryNftDeployed(string orgName, address orgNft, uint256 orgTokenId, address orgIpId, address storyNft); |
| 62 | + |
| 63 | + /// @notice Emitted when the signer of the StoryNFTFactory is updated. |
| 64 | + /// @param signer The new signer of the StoryNFTFactory. |
| 65 | + event StoryNFTFactorySignerUpdated(address signer); |
| 66 | + |
| 67 | + /// @notice Emitted when a new Story NFT template is whitelisted. |
| 68 | + /// @param nftTemplate The new Story NFT template that is whitelisted to be used in StoryNFTFactory. |
| 69 | + event StoryNFTFactoryNftTemplateWhitelisted(address nftTemplate); |
| 70 | + |
| 71 | + //////////////////////////////////////////////////////////////////////////// |
| 72 | + // Functions // |
| 73 | + //////////////////////////////////////////////////////////////////////////// |
| 74 | + /// @notice Mints a new organization NFT and deploys (creates a clone of) `storyNftTemplate` as the StoryNFT |
| 75 | + /// associated with the new organization NFT. |
| 76 | + /// @param storyNftTemplate The address of a whitelisted StoryNFT template to be cloned. |
| 77 | + /// @param orgNftRecipient The address of the recipient of the organization NFT. |
| 78 | + /// @param orgName The name of the organization. |
| 79 | + /// @param orgTokenURI The token URI of the organization NFT. |
| 80 | + /// @param signature The signature from the StoryNFTFactory's whitelist signer. This signautre is genreated by |
| 81 | + /// having the whitelist signer sign the caller's address (msg.sender) for this `deployStoryNft` function. |
| 82 | + /// @param storyNftInitParams The initialization parameters for StoryNFT {see {IStoryNFT-StoryNftInitParams}}. |
| 83 | + /// @return orgNft The address of the organization NFT. |
| 84 | + /// @return orgTokenId The token ID of the organization NFT. |
| 85 | + /// @return orgIpId The ID of the organization IP. |
| 86 | + /// @return storyNft The address of the dployed StoryNFT |
| 87 | + function deployStoryNft( |
| 88 | + address storyNftTemplate, |
| 89 | + address orgNftRecipient, |
| 90 | + string calldata orgName, |
| 91 | + string calldata orgTokenURI, |
| 92 | + bytes calldata signature, |
| 93 | + IStoryNFT.StoryNftInitParams calldata storyNftInitParams |
| 94 | + ) external returns (address orgNft, uint256 orgTokenId, address orgIpId, address storyNft); |
| 95 | + |
| 96 | + /// @notice Mints a new organization NFT and deploys (creates a clone of) `storyNftTemplate` as the StoryNFT |
| 97 | + /// associated with the new organization NFT. |
| 98 | + /// @dev Enforced to be only callable by the protocol admin in governance. |
| 99 | + /// @param storyNftTemplate The address of a whitelisted StoryNFT template to be cloned. |
| 100 | + /// @param orgNftRecipient The address of the recipient of the organization NFT. |
| 101 | + /// @param orgName The name of the organization. |
| 102 | + /// @param orgTokenURI The token URI of the organization NFT. |
| 103 | + /// @param storyNftInitParams The initialization parameters for StoryNFT {see {IStoryNFT-StoryNftInitParams}}. |
| 104 | + /// @param isRootOrg Whether the organization is the root organization. |
| 105 | + /// @return orgNft The address of the organization NFT. |
| 106 | + /// @return orgTokenId The token ID of the organization NFT. |
| 107 | + /// @return orgIpId The ID of the organization IP. |
| 108 | + /// @return storyNft The address of the dployed StoryNFT |
| 109 | + function deployStoryNftByAdmin( |
| 110 | + address storyNftTemplate, |
| 111 | + address orgNftRecipient, |
| 112 | + string calldata orgName, |
| 113 | + string calldata orgTokenURI, |
| 114 | + IStoryNFT.StoryNftInitParams calldata storyNftInitParams, |
| 115 | + bool isRootOrg |
| 116 | + ) external returns (address orgNft, uint256 orgTokenId, address orgIpId, address storyNft); |
| 117 | + |
| 118 | + /// @notice Sets the default StoryNFT template of the StoryNFTFactory. |
| 119 | + /// @param defaultStoryNftTemplate The new default StoryNFT template. |
| 120 | + function setDefaultStoryNftTemplate(address defaultStoryNftTemplate) external; |
| 121 | + |
| 122 | + /// @notice Sets the signer of the StoryNFTFactory. |
| 123 | + /// @param signer The new signer of the StoryNFTFactory. |
| 124 | + function setSigner(address signer) external; |
| 125 | + |
| 126 | + /// @notice Whitelists a new StoryNFT template. |
| 127 | + /// @param storyNftTemplate The new StoryNFT template to be whitelisted. |
| 128 | + function whitelistNftTemplate(address storyNftTemplate) external; |
| 129 | + |
| 130 | + /// @notice Returns the default StoryNFT template address. |
| 131 | + function getDefaultStoryNftTemplate() external view returns (address); |
| 132 | + |
| 133 | + /// @notice Returns the address of the StoryNFT for a given organization name. |
| 134 | + /// @param orgName The name of the organization. |
| 135 | + function getStoryNftAddressByOrgName(string calldata orgName) external view returns (address); |
| 136 | + |
| 137 | + /// @notice Returns the address of the StoryNFT for a given organization token ID. |
| 138 | + /// @param orgTokenId The token ID of the organization. |
| 139 | + function getStoryNftAddressByOrgTokenId(uint256 orgTokenId) external view returns (address); |
| 140 | + |
| 141 | + /// @notice Returns the address of the StoryNFT for a given organization IP ID. |
| 142 | + /// @param orgIpId The ID of the organization IP. |
| 143 | + function getStoryNftAddressByOrgIpId(address orgIpId) external view returns (address); |
| 144 | + |
| 145 | + /// @notice Returns whether a given StoryNFT template is whitelisted. |
| 146 | + /// @param storyNftTemplate The address of the StoryNFT template. |
| 147 | + function isNftTemplateWhitelisted(address storyNftTemplate) external view returns (bool); |
| 148 | +} |
0 commit comments