From 9ec3761126f2e9650aa6813a0c9b6259dcf9319a Mon Sep 17 00:00:00 2001 From: itzelot01 Date: Tue, 21 Nov 2023 20:29:48 +0000 Subject: [PATCH] Updating ERC721 and latest Solidity and OZ versions --- foundry.toml | 3 +++ lib/forge-std | 2 +- lib/openzeppelin-contracts | 2 +- src/DCO2s.sol | 19 +++++++++++++++---- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/foundry.toml b/foundry.toml index 25b918f..2f59907 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,5 +2,8 @@ src = "src" out = "out" libs = ["lib"] +solc = "0.8.23" # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + + diff --git a/lib/forge-std b/lib/forge-std index f73c73d..2f11269 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit f73c73d2018eb6a111f35e4dae7b4f27401e9421 +Subproject commit 2f112697506eab12d433a65fdc31a639548fe365 diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts index 932fddf..6bc1173 160000 --- a/lib/openzeppelin-contracts +++ b/lib/openzeppelin-contracts @@ -1 +1 @@ -Subproject commit 932fddf69a699a9a80fd2396fd1a2ab91cdda123 +Subproject commit 6bc1173c8e37ca7de2201a0230bb08e395074da1 diff --git a/src/DCO2s.sol b/src/DCO2s.sol index 99beef7..d564406 100644 --- a/src/DCO2s.sol +++ b/src/DCO2s.sol @@ -1,12 +1,13 @@ // 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/extensions/ERC721Enumerable.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; /// @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"); uint256 private _nextTokenId; @@ -19,9 +20,10 @@ contract DCO2s is ERC721, ERC721Enumerable, AccessControl { 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++; _safeMint(to, tokenId); + _setTokenURI(tokenId, uri); } // The following functions are overrides required by Solidity. @@ -41,10 +43,19 @@ contract DCO2s is ERC721, ERC721Enumerable, AccessControl { super._increaseBalance(account, value); } + function tokenURI(uint256 tokenId) + public + view + override(ERC721, ERC721URIStorage) + returns (string memory) + { + return super.tokenURI(tokenId); + } + function supportsInterface(bytes4 interfaceId) public view - override(ERC721, ERC721Enumerable, AccessControl) + override(ERC721, ERC721Enumerable, ERC721URIStorage, AccessControl) returns (bool) { return super.supportsInterface(interfaceId);