add bebadge contract
This commit is contained in:
parent
3c6d47fc15
commit
06058724d6
30705
build/contracts/BEBadge.json
Normal file
30705
build/contracts/BEBadge.json
Normal file
File diff suppressed because one or more lines are too long
@ -46131,7 +46131,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:15:27.639Z",
|
"updatedAt": "2023-03-07T05:51:10.382Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -29743,7 +29743,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:13:36.539Z",
|
"updatedAt": "2023-03-07T05:50:51.793Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -9829,7 +9829,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:12:43.611Z",
|
"updatedAt": "2023-03-07T05:50:35.118Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -22571,7 +22571,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:13:26.066Z",
|
"updatedAt": "2023-03-07T05:50:47.304Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -11967,7 +11967,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:13:00.069Z",
|
"updatedAt": "2023-03-07T05:50:39.368Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -22767,7 +22767,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:13:13.705Z",
|
"updatedAt": "2023-03-07T05:50:43.734Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
File diff suppressed because one or more lines are too long
@ -42506,7 +42506,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:15:10.858Z",
|
"updatedAt": "2023-03-07T05:51:06.376Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -46109,7 +46109,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:16:07.131Z",
|
"updatedAt": "2023-03-07T05:51:20.702Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -26363,7 +26363,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:12:17.382Z",
|
"updatedAt": "2023-03-07T05:50:30.823Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -29138,7 +29138,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:14:07.976Z",
|
"updatedAt": "2023-03-07T05:50:56.352Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -25437,7 +25437,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:16:23.469Z",
|
"updatedAt": "2023-03-07T05:51:28.961Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
File diff suppressed because one or more lines are too long
@ -33503,7 +33503,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:15:57.221Z",
|
"updatedAt": "2023-03-07T05:51:16.699Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -3146,8 +3146,8 @@
|
|||||||
"80001": {
|
"80001": {
|
||||||
"events": {},
|
"events": {},
|
||||||
"links": {},
|
"links": {},
|
||||||
"address": "0x4897e0f90B88216eBC71cc084217AE4348541f9C",
|
"address": "0xD166E700c85474829b100881C489a049f0a1C28C",
|
||||||
"transactionHash": "0xbaa4ca4afa3cc6a884fa93777ef992c4aeea5a4bbd32aab9481cfe5eaa2e3cdf"
|
"transactionHash": "0x354d816a4df1ae2479912765f26b39cc1651fc0dfc70699e1a22a7a051b8e586"
|
||||||
},
|
},
|
||||||
"1660724532588": {
|
"1660724532588": {
|
||||||
"events": {},
|
"events": {},
|
||||||
@ -3235,7 +3235,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.11",
|
"schemaVersion": "3.4.11",
|
||||||
"updatedAt": "2023-01-11T04:29:42.169Z",
|
"updatedAt": "2023-04-11T03:22:29.594Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -57056,7 +57056,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:14:24.980Z",
|
"updatedAt": "2023-03-07T05:51:01.820Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -49916,7 +49916,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:16:14.578Z",
|
"updatedAt": "2023-03-07T05:51:25.060Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -14963,7 +14963,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:15:57.234Z",
|
"updatedAt": "2023-03-07T05:51:16.717Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -28699,7 +28699,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.4",
|
"schemaVersion": "3.4.4",
|
||||||
"updatedAt": "2023-01-10T09:14:24.998Z",
|
"updatedAt": "2023-03-07T05:51:01.844Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
const market = {
|
const market = {
|
||||||
feeToAddress: "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
feeToAddress: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||||
mallFeeAddress: "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
mallFeeAddress: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||||
paymentTokens: [
|
paymentTokens: [
|
||||||
"0x0039f574ee5cc39bdd162e9a88e3eb1f111baf48", // USDT
|
"0x514609B71340E149Cb81A80A953D07A7Fe41bd4F", // USDT
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const admins = {
|
const admins = {
|
||||||
admin: "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
admin: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||||
proposers: [
|
proposers: [
|
||||||
"0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
"0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||||
"0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
|
"0x746338765a8FbDD1c5aB61bfb92CD6D960C3C662",
|
||||||
],
|
],
|
||||||
|
confirmers: ["0x50A8e60041A206AcaA5F844a1104896224be6F39"],
|
||||||
executors: [
|
executors: [
|
||||||
"0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
"0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||||
"0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
|
"0x746338765a8FbDD1c5aB61bfb92CD6D960C3C662",
|
||||||
"0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
|
"0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
32
config/config_22.js
Normal file
32
config/config_22.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
const market = {
|
||||||
|
feeToAddress: "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
||||||
|
mallFeeAddress: "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
||||||
|
paymentTokens: [
|
||||||
|
"0x0039f574ee5cc39bdd162e9a88e3eb1f111baf48", // USDT
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const admins = {
|
||||||
|
admin: "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
||||||
|
proposers: [
|
||||||
|
"0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
||||||
|
"0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
|
||||||
|
],
|
||||||
|
executors: [
|
||||||
|
"0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
||||||
|
"0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
|
||||||
|
"0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const token = {
|
||||||
|
baseTokenURI: "https://market.cebg.games/api/nft/info/",
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
market,
|
||||||
|
admins,
|
||||||
|
token,
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = config;
|
@ -1,32 +0,0 @@
|
|||||||
const market = {
|
|
||||||
feeToAddress: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
|
||||||
mallFeeAddress: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
|
||||||
paymentTokens: [
|
|
||||||
"0x514609B71340E149Cb81A80A953D07A7Fe41bd4F", // USDT
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const admins = {
|
|
||||||
admin: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
|
||||||
proposers: [
|
|
||||||
"0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
|
||||||
"0x746338765a8FbDD1c5aB61bfb92CD6D960C3C662",
|
|
||||||
],
|
|
||||||
executors: [
|
|
||||||
"0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
|
||||||
"0x746338765a8FbDD1c5aB61bfb92CD6D960C3C662",
|
|
||||||
"0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const token = {
|
|
||||||
baseTokenURI: "https://market.cebg.games/api/nft/info/",
|
|
||||||
};
|
|
||||||
|
|
||||||
var config = {
|
|
||||||
market,
|
|
||||||
admins,
|
|
||||||
token,
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = config;
|
|
@ -3,23 +3,35 @@ pragma solidity 0.8.10;
|
|||||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||||
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
|
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
|
||||||
import "@openzeppelin/contracts/security/Pausable.sol";
|
import "@openzeppelin/contracts/security/Pausable.sol";
|
||||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
import "@openzeppelin/contracts/access/AccessControl.sol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* only for test
|
* only for test
|
||||||
*/
|
*/
|
||||||
contract BEUSDT is ERC20, ERC20Burnable, Pausable, Ownable {
|
contract BEUSDT is ERC20, ERC20Burnable, Pausable, AccessControl {
|
||||||
constructor() ERC20("BE test USDT", "USDT") {}
|
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
|
||||||
|
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||||
|
|
||||||
function pause() external onlyOwner {
|
constructor(
|
||||||
|
string memory name_,
|
||||||
|
string memory symbol_
|
||||||
|
) ERC20(name_, symbol_) {
|
||||||
|
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
||||||
|
_setupRole(PAUSER_ROLE, msg.sender);
|
||||||
|
_setupRole(MINTER_ROLE, msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor() ERC20("BE test USDT", "USDT") {}
|
||||||
|
|
||||||
|
function pause() external onlyRole(PAUSER_ROLE) {
|
||||||
_pause();
|
_pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
function unpause() external onlyOwner {
|
function unpause() external onlyRole(PAUSER_ROLE) {
|
||||||
_unpause();
|
_unpause();
|
||||||
}
|
}
|
||||||
|
|
||||||
function mint(address to, uint256 amount) external onlyOwner {
|
function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) {
|
||||||
_mint(to, amount);
|
_mint(to, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,4 +42,20 @@ contract BEUSDT is ERC20, ERC20Burnable, Pausable, Ownable {
|
|||||||
) internal override whenNotPaused {
|
) internal override whenNotPaused {
|
||||||
super._beforeTokenTransfer(from, to, amount);
|
super._beforeTokenTransfer(from, to, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setPauserRole(address to) external {
|
||||||
|
grantRole(PAUSER_ROLE, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removePauserRole(address to) external {
|
||||||
|
revokeRole(PAUSER_ROLE, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMintRole(address to) external {
|
||||||
|
grantRole(MINTER_ROLE, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeMintRole(address to) external {
|
||||||
|
revokeRole(MINTER_ROLE, to);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
205
contracts/tokens/erc721/BEBadge.sol
Normal file
205
contracts/tokens/erc721/BEBadge.sol
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity 0.8.10;
|
||||||
|
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
||||||
|
import "@openzeppelin/contracts/access/AccessControl.sol";
|
||||||
|
|
||||||
|
contract BEBadge is AccessControl, ERC721Enumerable {
|
||||||
|
mapping(uint256 => bool) public lockedTokens;
|
||||||
|
string private _baseTokenURI = "https://market.cebg.games/api/nft/info/";
|
||||||
|
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||||
|
bytes32 public constant BURN_ROLE = keccak256("BURN_ROLE");
|
||||||
|
bytes32 public constant LOCK_ROLE = keccak256("LOCK_ROLE");
|
||||||
|
uint256 public immutable supplyLimit;
|
||||||
|
|
||||||
|
event Lock(uint256 indexed tokenId);
|
||||||
|
event UnLock(uint256 indexed tokenId);
|
||||||
|
event BatchMint(address indexed to, uint256[] tokenIds);
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
string memory name_,
|
||||||
|
string memory symbol_,
|
||||||
|
uint256 supplyLimt_
|
||||||
|
) ERC721(name_, symbol_) {
|
||||||
|
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
||||||
|
_setupRole(MINTER_ROLE, msg.sender);
|
||||||
|
_setupRole(BURN_ROLE, msg.sender);
|
||||||
|
_setupRole(LOCK_ROLE, msg.sender);
|
||||||
|
supplyLimit = supplyLimt_;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _baseURI() internal view virtual override returns (string memory) {
|
||||||
|
return _baseTokenURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Creates a new token for `to`. Its token ID will be automatically
|
||||||
|
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
|
||||||
|
* URI autogenerated based on the base URI passed at construction.
|
||||||
|
*
|
||||||
|
* See {ERC721-_mint}.
|
||||||
|
*
|
||||||
|
* Requirements:
|
||||||
|
*
|
||||||
|
* - the caller must have the `MINTER_ROLE`.
|
||||||
|
*/
|
||||||
|
function mint(
|
||||||
|
address to,
|
||||||
|
uint256 tokenId
|
||||||
|
) external virtual onlyRole(MINTER_ROLE) {
|
||||||
|
if (supplyLimit > 0) {
|
||||||
|
require(totalSupply() < supplyLimit, "Exceed the total supply");
|
||||||
|
}
|
||||||
|
_mint(to, tokenId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Batch mint tokens and transfer to specified address.
|
||||||
|
*
|
||||||
|
* Requirements:
|
||||||
|
* - Caller must have `MINTER_ROLE`.
|
||||||
|
* - The total supply limit should not be exceeded.
|
||||||
|
* - The number of tokenIds offered for minting should not exceed 100.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function batchMint(
|
||||||
|
address to,
|
||||||
|
uint256[] calldata tokenIds
|
||||||
|
) external onlyRole(MINTER_ROLE) {
|
||||||
|
if (supplyLimit > 0) {
|
||||||
|
require(
|
||||||
|
(totalSupply() + tokenIds.length) <= supplyLimit,
|
||||||
|
"Exceed the total supply"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
require(tokenIds.length <= 100, "tokenIds too many");
|
||||||
|
for (uint256 i = 0; i < tokenIds.length; i++) {
|
||||||
|
_mint(to, tokenIds[i]);
|
||||||
|
}
|
||||||
|
emit BatchMint(to, tokenIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Grant mint role to address
|
||||||
|
*/
|
||||||
|
function setMintRole(address to) external {
|
||||||
|
grantRole(MINTER_ROLE, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Remove mint role to address
|
||||||
|
*/
|
||||||
|
function removeMintRole(address to) external {
|
||||||
|
revokeRole(MINTER_ROLE, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev grant burn role to address
|
||||||
|
*/
|
||||||
|
function setBurnRole(address to) external {
|
||||||
|
grantRole(BURN_ROLE, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Remove burn role to address
|
||||||
|
*/
|
||||||
|
function removeBurnRole(address proxy) external {
|
||||||
|
revokeRole(BURN_ROLE, proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Add address for lock item
|
||||||
|
*/
|
||||||
|
function grantLockRole(address to) external {
|
||||||
|
grantRole(LOCK_ROLE, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Remove address for lock item
|
||||||
|
*/
|
||||||
|
function removeLockRole(address account) external {
|
||||||
|
revokeRole(LOCK_ROLE, account);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Lock token to use in game or for rental
|
||||||
|
*/
|
||||||
|
function lock(uint256 tokenId) external onlyRole(LOCK_ROLE) {
|
||||||
|
require(_exists(tokenId), "Must be valid tokenId");
|
||||||
|
require(!lockedTokens[tokenId], "Token has already locked");
|
||||||
|
lockedTokens[tokenId] = true;
|
||||||
|
emit Lock(tokenId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Unlock token to use blockchain or sale on marketplace
|
||||||
|
*/
|
||||||
|
function unlock(uint256 tokenId) external onlyRole(LOCK_ROLE) {
|
||||||
|
require(_exists(tokenId), "Must be valid tokenId");
|
||||||
|
require(lockedTokens[tokenId], "Token has already unlocked");
|
||||||
|
lockedTokens[tokenId] = false;
|
||||||
|
emit UnLock(tokenId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Get lock status
|
||||||
|
*/
|
||||||
|
function isLocked(uint256 tokenId) external view returns (bool) {
|
||||||
|
return lockedTokens[tokenId];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Set token URI
|
||||||
|
*/
|
||||||
|
function updateBaseURI(
|
||||||
|
string calldata baseTokenURI
|
||||||
|
) external onlyRole(DEFAULT_ADMIN_ROLE) {
|
||||||
|
_baseTokenURI = baseTokenURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev See {IERC165-_beforeTokenTransfer}.
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev See {IERC165-supportsInterface}.
|
||||||
|
*/
|
||||||
|
function supportsInterface(
|
||||||
|
bytes4 interfaceId
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
virtual
|
||||||
|
override(AccessControl, ERC721Enumerable)
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
return super.supportsInterface(interfaceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Burns `tokenId`.
|
||||||
|
*
|
||||||
|
* Requirements:
|
||||||
|
*
|
||||||
|
* - The caller must own `tokenId` or be an approved operator.
|
||||||
|
*/
|
||||||
|
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(
|
||||||
|
ownerOf(tokenId) == owner,
|
||||||
|
"current address is not owner of this item now"
|
||||||
|
);
|
||||||
|
_burn(tokenId);
|
||||||
|
}
|
||||||
|
}
|
37
migrations/2_depoly_etc.js
Normal file
37
migrations/2_depoly_etc.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
const Badge = artifacts.require("tokens/erc721/BEBadge");
|
||||||
|
const Coin = artifacts.require("tokens/erc20/BEUSDT");
|
||||||
|
const Wallet = artifacts.require("tokens/erc721/BEMultiSigWallet");
|
||||||
|
const config = require("../config/config");
|
||||||
|
|
||||||
|
module.exports = async function (deployer, network, accounts) {
|
||||||
|
// await deployer.deploy(Badge, "BE Badge", "Badge", "0");
|
||||||
|
// const badgeInstance = await Badge.deployed();
|
||||||
|
// if (badgeInstance) {
|
||||||
|
// console.log("BEBadge successfully deployed. ");
|
||||||
|
// console.log("address: " + badgeInstance.address);
|
||||||
|
// }
|
||||||
|
// await badgeInstance.updateBaseURI(config.token.baseTokenURI);
|
||||||
|
// await deployer.deploy(Coin, "BE test USDT", "USDT");
|
||||||
|
// const coinInstance = await Coin.deployed();
|
||||||
|
// if (coinInstance) {
|
||||||
|
// console.log("BEUSDT successfully deployed. ");
|
||||||
|
// console.log("address: " + coinInstance.address);
|
||||||
|
// }
|
||||||
|
await deployer.deploy(
|
||||||
|
Wallet,
|
||||||
|
60,
|
||||||
|
1,
|
||||||
|
config.admins.proposers,
|
||||||
|
config.admins.confirmers,
|
||||||
|
config.admins.executors
|
||||||
|
);
|
||||||
|
const walletInstance = await Wallet.deployed();
|
||||||
|
if (walletInstance) {
|
||||||
|
console.log("BEMultiSigWallet successfully deployed.");
|
||||||
|
console.log("address: " + walletInstance.address);
|
||||||
|
}
|
||||||
|
// await badgeInstance.setMintRole(walletInstance.address);
|
||||||
|
// console.log("success add wallet to badge's mint role");
|
||||||
|
// await coinInstance.setMintRole(walletInstance.address);
|
||||||
|
// console.log("success add wallet to usdt's mint role");
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user