update openzeppelin to 4.9.2
This commit is contained in:
parent
831c564e81
commit
6152802fbc
@ -158,10 +158,10 @@ contract BEBadge is AccessControl, ERC721Enumerable {
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) internal virtual override(ERC721Enumerable) {
|
||||
require(!lockedTokens[tokenId], "Can not transfer locked token");
|
||||
super._beforeTokenTransfer(from, to, tokenId);
|
||||
uint256 firstTokenId,
|
||||
uint256 batchSize
|
||||
) internal virtual override {
|
||||
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,11 +29,10 @@ abstract contract BEBase is AccessControl, ERC721Enumerable, Ownable {
|
||||
*
|
||||
* - the caller must have the `MINTER_ROLE`.
|
||||
*/
|
||||
function mint(address to, uint256 tokenId)
|
||||
external
|
||||
virtual
|
||||
onlyRole(MINTER_ROLE)
|
||||
{
|
||||
function mint(
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) external virtual onlyRole(MINTER_ROLE) {
|
||||
require(!_exists(tokenId), "Must have unique tokenId");
|
||||
_mint(to, tokenId);
|
||||
}
|
||||
@ -120,16 +119,18 @@ abstract contract BEBase is AccessControl, ERC721Enumerable, Ownable {
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) internal virtual override(ERC721Enumerable) {
|
||||
require(!lockedTokens[tokenId], "Can not transfer locked token");
|
||||
super._beforeTokenTransfer(from, to, tokenId);
|
||||
uint256 firstTokenId,
|
||||
uint256 batchSize
|
||||
) internal virtual override {
|
||||
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC165-supportsInterface}.
|
||||
*/
|
||||
function supportsInterface(bytes4 interfaceId)
|
||||
function supportsInterface(
|
||||
bytes4 interfaceId
|
||||
)
|
||||
public
|
||||
view
|
||||
virtual
|
||||
@ -146,11 +147,10 @@ abstract contract BEBase is AccessControl, ERC721Enumerable, Ownable {
|
||||
*
|
||||
* - The caller must own `tokenId` or be an approved operator.
|
||||
*/
|
||||
function burn(address owner, uint256 tokenId)
|
||||
external
|
||||
virtual
|
||||
onlyRole(BURN_ROLE)
|
||||
{
|
||||
function burn(
|
||||
address owner,
|
||||
uint256 tokenId
|
||||
) external virtual onlyRole(BURN_ROLE) {
|
||||
require(_exists(tokenId), "TokenId not exists");
|
||||
require(!lockedTokens[tokenId], "Can not burn locked token");
|
||||
require(
|
||||
|
@ -123,10 +123,10 @@ contract NFT is AccessControl, ERC721Enumerable {
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) internal virtual override(ERC721Enumerable) {
|
||||
require(!lockedTokens[tokenId], "Can not transfer locked token");
|
||||
super._beforeTokenTransfer(from, to, tokenId);
|
||||
uint256 firstTokenId,
|
||||
uint256 batchSize
|
||||
) internal virtual override {
|
||||
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,10 +4,11 @@ pragma solidity 0.8.10;
|
||||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
||||
import "@openzeppelin/contracts/utils/Counters.sol";
|
||||
import "@openzeppelin/contracts/access/AccessControl.sol";
|
||||
import "../../interfaces/IMetaData.sol";
|
||||
|
||||
contract NFTSbt is AccessControl, ERC721Enumerable {
|
||||
using Counters for Counters.Counter;
|
||||
string private _baseTokenURI = "https://market.cebg.games/api/nft/info/";
|
||||
address private _metaAddress;
|
||||
bytes32 public constant BURN_ROLE = keccak256("BURN_ROLE");
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
uint256 public immutable supplyLimit;
|
||||
@ -46,33 +47,30 @@ contract NFTSbt is AccessControl, ERC721Enumerable {
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) internal override(ERC721Enumerable) {
|
||||
uint256 firstTokenId,
|
||||
uint256 batchSize
|
||||
) internal virtual override {
|
||||
require(from == address(0) || to == address(0), "Token not transferable");
|
||||
super._beforeTokenTransfer(from, to, tokenId);
|
||||
}
|
||||
|
||||
function _baseURI() internal view virtual override returns (string memory) {
|
||||
return _baseTokenURI;
|
||||
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Set token URI
|
||||
*/
|
||||
function updateBaseURI(
|
||||
string calldata baseTokenURI
|
||||
function updateMetaAddress(
|
||||
address metaAddress
|
||||
) external onlyRole(DEFAULT_ADMIN_ROLE) {
|
||||
_baseTokenURI = baseTokenURI;
|
||||
_metaAddress = metaAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev one type nft has same tokenURI
|
||||
* @dev one type badge has same tokenURI
|
||||
*/
|
||||
function tokenURI(
|
||||
uint256 tokenId
|
||||
) public view virtual override returns (string memory) {
|
||||
string memory baseURI = _baseURI();
|
||||
return bytes(baseURI).length > 0 ? baseURI : "";
|
||||
) public view override returns (string memory) {
|
||||
require(_exists(tokenId), "URI query for nonexistent token");
|
||||
return IMetaData(_metaAddress).getMetaData(address(this), tokenId);
|
||||
}
|
||||
|
||||
function mint(address to) external onlyRole(MINTER_ROLE) returns (uint256) {
|
||||
|
16
package-lock.json
generated
16
package-lock.json
generated
@ -9,7 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@openzeppelin/contracts": "^4.5.0",
|
||||
"@openzeppelin/contracts": "4.9.2",
|
||||
"fs-jetpack": "^5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -1509,9 +1509,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@openzeppelin/contracts": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmmirror.com/@openzeppelin/contracts/-/contracts-4.5.0.tgz",
|
||||
"integrity": "sha512-fdkzKPYMjrRiPK6K4y64e6GzULR7R7RwxSigHS8DDp7aWDeoReqsQI+cxHV1UuhAqX69L1lAaWDxenfP+xiqzA=="
|
||||
"version": "4.9.2",
|
||||
"resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.2.tgz",
|
||||
"integrity": "sha512-mO+y6JaqXjWeMh9glYVzVu8HYPGknAAnWyxTRhGeckOruyXQMNnlcW6w/Dx9ftLeIQk6N+ZJFuVmTwF7lEIFrg=="
|
||||
},
|
||||
"node_modules/@openzeppelin/test-helpers": {
|
||||
"version": "0.5.15",
|
||||
@ -24767,9 +24767,9 @@
|
||||
}
|
||||
},
|
||||
"@openzeppelin/contracts": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmmirror.com/@openzeppelin/contracts/-/contracts-4.5.0.tgz",
|
||||
"integrity": "sha512-fdkzKPYMjrRiPK6K4y64e6GzULR7R7RwxSigHS8DDp7aWDeoReqsQI+cxHV1UuhAqX69L1lAaWDxenfP+xiqzA=="
|
||||
"version": "4.9.2",
|
||||
"resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.2.tgz",
|
||||
"integrity": "sha512-mO+y6JaqXjWeMh9glYVzVu8HYPGknAAnWyxTRhGeckOruyXQMNnlcW6w/Dx9ftLeIQk6N+ZJFuVmTwF7lEIFrg=="
|
||||
},
|
||||
"@openzeppelin/test-helpers": {
|
||||
"version": "0.5.15",
|
||||
@ -41399,7 +41399,7 @@
|
||||
"truffle-plugin-stdjsonin": {
|
||||
"version": "git+ssh://git@github.com/mhrsalehi/truffle-plugin-stdjsonin.git#0ddb4110de7e14b2242f7467600d1ac149e2c460",
|
||||
"dev": true,
|
||||
"from": "truffle-plugin-stdjsonin@https://github.com/mhrsalehi/truffle-plugin-stdjsonin/",
|
||||
"from": "truffle-plugin-stdjsonin@github:mhrsalehi/truffle-plugin-stdjsonin",
|
||||
"requires": {
|
||||
"cli-logger": "^0.5.40"
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
"truffle-plugin-verify": "^0.5.25"
|
||||
},
|
||||
"dependencies": {
|
||||
"@openzeppelin/contracts": "^4.5.0",
|
||||
"@openzeppelin/contracts": "4.9.2",
|
||||
"fs-jetpack": "^5.1.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user