-
Notifications
You must be signed in to change notification settings - Fork 0
/
ByzNft.sol
55 lines (47 loc) · 1.98 KB
/
ByzNft.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin-upgrades/contracts/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
import "../interfaces/IByzNft.sol";
import "../interfaces/IStrategyModuleManager.sol";
contract ByzNft is
Initializable,
OwnableUpgradeable,
ERC721Upgradeable,
IByzNft
{
// Unsafe to have a constructor in the context of a proxy contract
//constructor() ERC721("Byzantine NFT", "byzNFT") {}
/**
* @dev Initializes name, symbol and owner of the ERC721 collection.
* @dev owner is the StrategyModuleManager proxy contract
*/
function initialize(
IStrategyModuleManager _strategyModuleManager
) external initializer {
__ERC721_init("Byzantine NFT", "byzNFT");
_transferOwnership(address(_strategyModuleManager));
}
/**
* @notice Gets called when a full staker creates a Strategy Module
* @param _to The address of the staker who created the Strategy Module
* @param _nounce to calculate the tokenId. This is to prevent minting the same tokenId twice.
* @return The tokenId of the newly minted NFT (calculated from the number of Strategy Modules already deployed)
*/
function mint(address _to, uint64 _nounce) external onlyOwner returns (uint256) {
uint256 tokenId = uint256(keccak256(abi.encode(_nounce)));
_safeMint(_to, tokenId);
return tokenId;
}
/**
* @dev Overrides `_beforeTokenTransfer` to restrict token transfers to the StrategyModuleManager contract.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override view {
require(msg.sender == owner(), "ByzNft._transfer: Token transfer can only be initiated by the StrategyModuleManager, call StrategyModuleManager.transferStratModOwnership");
}
}