update
This commit is contained in:
@@ -242,6 +242,13 @@ contract DODODrops is InitializableMintableERC20, ReentrancyGuard {
|
||||
_setFixedAmountInfo(tokenIdList);
|
||||
}
|
||||
|
||||
function addFixedAmountInfo(uint256[] memory addTokenIdList) external notStart() onlyOwner {
|
||||
for (uint256 i = 0; i < addTokenIdList.length; i++) {
|
||||
_TOKEN_ID_LIST_.push(addTokenIdList[i]);
|
||||
}
|
||||
emit SetFixedAmountInfo();
|
||||
}
|
||||
|
||||
function setTokenIdMapByIndex(uint256 index, uint256[] memory tokenIds) external notStart() onlyOwner {
|
||||
require(_IS_PROB_MODE_, "ONLY_ALLOW_PROB_MODE");
|
||||
require(tokenIds.length > 0 && index < _TOKEN_ID_MAP_.length,"PARAM_NOT_INVALID");
|
||||
|
||||
@@ -10,10 +10,12 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import {ERC1155} from "../../external/ERC1155/ERC1155.sol";
|
||||
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
|
||||
import {Strings} from "../../external/utils/Strings.sol";
|
||||
|
||||
contract DropsERC1155 is ERC1155, InitializableOwnable {
|
||||
using Strings for uint256;
|
||||
|
||||
mapping (address => bool) public _IS_ALLOWED_MINT_;
|
||||
mapping (uint256 => string) private _tokenURIs;
|
||||
string internal _baseUri = "";
|
||||
|
||||
// ============ Event =============
|
||||
@@ -43,25 +45,11 @@ contract DropsERC1155 is ERC1155, InitializableOwnable {
|
||||
_mint(account, id, amount, data);
|
||||
}
|
||||
|
||||
function batchSetTokenURI(uint256[] calldata ids, string[] calldata urls) external onlyOwner {
|
||||
require(ids.length == urls.length, "NOT_MATCH");
|
||||
for(uint256 i = 0; i < ids.length; i++) {
|
||||
_setTokenURI(ids[i], urls[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function uri(uint256 tokenId) public view override returns (string memory) {
|
||||
string memory _tokenURI = _tokenURIs[tokenId];
|
||||
string memory base = _baseUri;
|
||||
string memory baseURI = _baseUri;
|
||||
|
||||
if (bytes(base).length == 0) {
|
||||
return _tokenURI;
|
||||
}
|
||||
|
||||
return string(abi.encodePacked(base, _tokenURI));
|
||||
}
|
||||
|
||||
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal {
|
||||
_tokenURIs[tokenId] = _tokenURI;
|
||||
return bytes(baseURI).length > 0
|
||||
? string(abi.encodePacked(baseURI, tokenId.toString()))
|
||||
: '';
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,10 @@
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {ERC721URIStorage} from "../../external/ERC721/ERC721URIStorage.sol";
|
||||
import {ERC721Enumerable} from "../../external/ERC721/ERC721Enumerable.sol";
|
||||
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
|
||||
|
||||
contract DropsERC721 is ERC721URIStorage, InitializableOwnable {
|
||||
contract DropsERC721 is ERC721Enumerable, InitializableOwnable {
|
||||
mapping (address => bool) public _IS_ALLOWED_MINT_;
|
||||
|
||||
// ============ Event =============
|
||||
@@ -44,11 +44,4 @@ contract DropsERC721 is ERC721URIStorage, InitializableOwnable {
|
||||
require(_IS_ALLOWED_MINT_[msg.sender], "restricted");
|
||||
_mint(to, tokenId);
|
||||
}
|
||||
|
||||
function batchSetTokenURI(uint256[] calldata ids, string[] calldata urls) external onlyOwner {
|
||||
require(ids.length == urls.length, "NOT_MATCH");
|
||||
for(uint256 i = 0; i < ids.length; i++) {
|
||||
_setTokenURI(ids[i], urls[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,14 +13,14 @@ import {DecimalMath} from "../../lib/DecimalMath.sol";
|
||||
import {IDVM} from "../../DODOVendingMachine/intf/IDVM.sol";
|
||||
import {IDODOCallee} from "../../intf/IDODOCallee.sol";
|
||||
import {IERC20} from "../../intf/IERC20.sol";
|
||||
import {InitializableERC20} from "../../external/ERC20/InitializableERC20.sol";
|
||||
import {InitializableFragERC20} from "../../external/ERC20/InitializableFragERC20.sol";
|
||||
import {ICollateralVault} from "../../CollateralVault/intf/ICollateralVault.sol";
|
||||
|
||||
interface IBuyoutModel {
|
||||
function getBuyoutStatus(address fragAddr, address user) external view returns (int);
|
||||
}
|
||||
|
||||
contract Fragment is InitializableERC20 {
|
||||
contract Fragment is InitializableFragERC20 {
|
||||
using SafeMath for uint256;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
@@ -77,8 +77,7 @@ contract Fragment is InitializableERC20 {
|
||||
// init FRAG meta data
|
||||
name = string(abi.encodePacked("DODO_FRAG_", _symbol));
|
||||
symbol = string(abi.encodePacked("d_", _symbol));
|
||||
decimals = 18;
|
||||
super.init(address(this), _totalSupply, name, symbol, decimals);
|
||||
super.init(address(this), _totalSupply, name, symbol);
|
||||
|
||||
// init FRAG distribution
|
||||
uint256 vaultPreOwnerBalance = DecimalMath.mulFloor(_totalSupply, ownerRatio);
|
||||
|
||||
92
contracts/external/ERC20/InitializableFragERC20.sol
vendored
Normal file
92
contracts/external/ERC20/InitializableFragERC20.sol
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
|
||||
import {SafeMath} from "../../lib/SafeMath.sol";
|
||||
|
||||
contract InitializableFragERC20 {
|
||||
using SafeMath for uint256;
|
||||
|
||||
string public name;
|
||||
string public symbol;
|
||||
uint256 public totalSupply;
|
||||
|
||||
bool public initialized;
|
||||
|
||||
mapping(address => uint256) internal balances;
|
||||
mapping(address => mapping(address => uint256)) internal allowed;
|
||||
|
||||
event Transfer(address indexed from, address indexed to, uint256 amount);
|
||||
event Approval(address indexed owner, address indexed spender, uint256 amount);
|
||||
|
||||
function init(
|
||||
address _creator,
|
||||
uint256 _totalSupply,
|
||||
string memory _name,
|
||||
string memory _symbol
|
||||
) public {
|
||||
require(!initialized, "TOKEN_INITIALIZED");
|
||||
initialized = true;
|
||||
totalSupply = _totalSupply;
|
||||
balances[_creator] = _totalSupply;
|
||||
name = _name;
|
||||
symbol = _symbol;
|
||||
emit Transfer(address(0), _creator, _totalSupply);
|
||||
}
|
||||
|
||||
function decimals() public view returns (uint8) {
|
||||
return 18;
|
||||
}
|
||||
|
||||
function transfer(address to, uint256 amount) public returns (bool) {
|
||||
_transfer(msg.sender, to, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
function balanceOf(address owner) public view returns (uint256 balance) {
|
||||
return balances[owner];
|
||||
}
|
||||
|
||||
function transferFrom(
|
||||
address from,
|
||||
address to,
|
||||
uint256 amount
|
||||
) public returns (bool) {
|
||||
require(to != address(0), "TO_ADDRESS_IS_EMPTY");
|
||||
require(amount <= balances[from], "BALANCE_NOT_ENOUGH");
|
||||
require(amount <= allowed[from][msg.sender], "ALLOWANCE_NOT_ENOUGH");
|
||||
|
||||
balances[from] = balances[from].sub(amount);
|
||||
balances[to] = balances[to].add(amount);
|
||||
allowed[from][msg.sender] = allowed[from][msg.sender].sub(amount);
|
||||
emit Transfer(from, to, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
function approve(address spender, uint256 amount) public returns (bool) {
|
||||
allowed[msg.sender][spender] = amount;
|
||||
emit Approval(msg.sender, spender, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
function allowance(address owner, address spender) public view returns (uint256) {
|
||||
return allowed[owner][spender];
|
||||
}
|
||||
|
||||
function _transfer(address sender, address recipient, uint256 amount) internal {
|
||||
require(sender != address(0), "FROM_ADDRESS_IS_EMPTY");
|
||||
require(recipient != address(0), "TO_ADDRESS_IS_EMPTY");
|
||||
require(amount <= balances[sender], "BALANCE_NOT_ENOUGH");
|
||||
|
||||
balances[sender] = balances[sender].sub(amount);
|
||||
balances[recipient] = balances[recipient].add(amount);
|
||||
|
||||
emit Transfer(sender, recipient, amount);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user