all files / contracts/mocks/ MockERC721.sol

100% Statements 12/12
100% Branches 0/0
100% Functions 10/10
100% Lines 12/12
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126                                                                                    54× 54× 42×               12×                                                                                                                     149× 149×              
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.6;
 
import "./../utils/ERC721Enhanced.sol";
 
 
/**
 * @title Mock ERC721
 * @author solace.fi
 * @notice Mock ERC721 is only used to test other contracts.
 */
contract MockERC721 is ERC721Enhanced {
 
    // Count of all tokens created.
    uint256 internal _tokenCount = 0;
 
    struct AfterTransfer {
        address from;
        address to;
        uint256 tokenID;
    }
 
    AfterTransfer public lastTransfer;
 
    /**
     * @notice Constructs the Mock Token contract.
     * @param name The name of the token.
     * @param symbol The symbol of the token.
     */
    constructor(
        string memory name,
        string memory symbol
    )
    // solhint-disable-next-line no-empty-blocks
    ERC721Enhanced(name, symbol) { }
 
    /**
     * @notice Mints a new token.
     * @param recipient The recipient of the token.
     * @return tokenID The ID of the new token.
     */
    function mint(address recipient) external returns (uint256 tokenID) {
        tokenID = ++_tokenCount; // autoincrement from 1
        _mint(recipient, tokenID);
        return tokenID;
    }
 
    /**
     * @notice Burns a token.
     * @param tokenID The token to burn.
     */
    function burn(uint256 tokenID) external {
        _burn(tokenID);
    }
 
    /**
     * @notice Count of all tokens created.
     * @return count Count.
     */
    function tokenCount() external view returns (uint256 count) {
        return _tokenCount;
    }
 
    /**
     * @notice Do a thing to a token.
     * @param tokenID The ID of the token to do stuff to.
     * @return res The result.
     */
    function doThing1(uint256 tokenID) external tokenMustExist(tokenID) returns (uint256 res) {
        return tokenID * 2;
    }
 
    /**
     * @notice Do a thing to a token.
     * @param tokenID The ID of the token to do stuff to.
     * @return res The result.
     */
    function doThing2(uint256 tokenID) external onlyOwner(tokenID) returns (uint256 res) {
        return tokenID * 3;
    }
 
    /**
     * @notice Do a thing to a token.
     * @param tokenID The ID of the token to do stuff to.
     * @return res The result.
     */
    function doThing3(uint256 tokenID) external onlyOwnerOrApproved(tokenID) returns (uint256 res) {
        return tokenID * 4;
    }
 
    /**
     * @notice Get the base URI.
     */
    function getBaseURI() external view returns (string memory) {
        return _baseURI();
    }
 
    /**
     * @notice Sets the base URI for computing `tokenURI`.
     * Can only be called by the current [**governor**](/docs/protocol/governance).
     * @param baseURI_ The new base URI.
     */
    function setBaseURI(string memory baseURI_) external {
        _setBaseURI(baseURI_);
    }
 
    /**
     * @notice Hook that is called after any token transfer. This includes minting and burning.
     * @param from The user that sends the token, or zero if minting.
     * @param to The zero that receives the token, or zero if burning.
     * @param tokenID The ID of the token being transferred.
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 tokenID
    ) internal virtual override {
        super._afterTokenTransfer(from, to, tokenID);
        lastTransfer = AfterTransfer({
            from: from,
            to: to,
            tokenID: tokenID
        });
    }
}