-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathbatchMint.sol
72 lines (57 loc) · 2.25 KB
/
batchMint.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./ERC721A.sol";
contract Deployed is ReentrancyGuard {
function saleMint(uint256 _ammount) external payable nonReentrant {}
function revealed() public pure returns (bool) {}
function priceSale() public pure returns (uint256) {}
}
contract contractMint is ReentrancyGuard, IERC721Receiver, Ownable {
Deployed dc;
function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes memory _data
) public override returns (bytes4) {
return 0x150b7a02;
}
function existing(address _t) external onlyOwner {
dc = Deployed(_t);
}
// TODO: renounceOwnership
function getStatus() public view returns (bool result) {
return dc.revealed();
}
function getPrice() public view returns (uint256 result) {
return dc.priceSale();
}
function mint(uint256 _val) external payable onlyOwner nonReentrant {
dc.saleMint{value: _val * getPrice()}(_val);
}
function mint(address _e, uint256 _val) external payable onlyOwner {
(bool success, ) = _e.call{value: _val * getPrice()}(
abi.encodePacked(bytes4(keccak256("saleMint(uint256)")), _val)
); // D's storage is set, E is not modified
require(success);
}
function withdrawMoney() external onlyOwner nonReentrant {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer failed.");
}
function withdrawNFT(address _e, uint256 id)
external
nonReentrant
onlyOwner
{
ERC721A token = ERC721A(_e);
require(token.balanceOf(address(this)) > 0, "Caller must own nft");
require(token.ownerOf(id) == address(this), "You must own the token");
token.transferFrom(address(this), msg.sender, id);
// TODO: (bool success, ) = _e.call(abi.encodePacked(bytes4(keccak256("transferFrom(address,address,uint256)")), address(this), msg.sender,id));
// require(success, "Transfer failed.");
}
}