Updating ERC721 and latest Solidity and OZ versions

This commit is contained in:
itzelot01 2023-11-21 20:29:48 +00:00
parent beb0887bf9
commit 9ec3761126
4 changed files with 20 additions and 6 deletions

View File

@ -2,5 +2,8 @@
src = "src" src = "src"
out = "out" out = "out"
libs = ["lib"] libs = ["lib"]
solc = "0.8.23"
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

@ -1 +1 @@
Subproject commit f73c73d2018eb6a111f35e4dae7b4f27401e9421 Subproject commit 2f112697506eab12d433a65fdc31a639548fe365

@ -1 +1 @@
Subproject commit 932fddf69a699a9a80fd2396fd1a2ab91cdda123 Subproject commit 6bc1173c8e37ca7de2201a0230bb08e395074da1

View File

@ -1,12 +1,13 @@
// SPDX-License-Identifier: GPL-3.0 // SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20; pragma solidity ^0.8.23;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/access/AccessControl.sol";
/// @custom:security-contact david@neetsec.com /// @custom:security-contact david@neetsec.com
contract DCO2s is ERC721, ERC721Enumerable, AccessControl { contract DCO2s is ERC721, ERC721Enumerable, ERC721URIStorage, AccessControl {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
uint256 private _nextTokenId; uint256 private _nextTokenId;
@ -19,9 +20,10 @@ contract DCO2s is ERC721, ERC721Enumerable, AccessControl {
return "https://gateway.decentralizedscience.org/ipfs/"; return "https://gateway.decentralizedscience.org/ipfs/";
} }
function safeMint(address to) public onlyRole(MINTER_ROLE) { function safeMint(address to, string memory uri) public onlyRole(MINTER_ROLE) {
uint256 tokenId = _nextTokenId++; uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId); _safeMint(to, tokenId);
_setTokenURI(tokenId, uri);
} }
// The following functions are overrides required by Solidity. // The following functions are overrides required by Solidity.
@ -41,10 +43,19 @@ contract DCO2s is ERC721, ERC721Enumerable, AccessControl {
super._increaseBalance(account, value); super._increaseBalance(account, value);
} }
function tokenURI(uint256 tokenId)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(tokenId);
}
function supportsInterface(bytes4 interfaceId) function supportsInterface(bytes4 interfaceId)
public public
view view
override(ERC721, ERC721Enumerable, AccessControl) override(ERC721, ERC721Enumerable, ERC721URIStorage, AccessControl)
returns (bool) returns (bool)
{ {
return super.supportsInterface(interfaceId); return super.supportsInterface(interfaceId);