|
|
|
@ -6,14 +6,13 @@ import "./IMastersFedi.sol";
|
|
|
|
|
import "./Address.sol";
|
|
|
|
|
import "./IERC1155Metadata.sol";
|
|
|
|
|
import "./ERC1155Metadata.sol";
|
|
|
|
|
import "./IERC223ReceivingContract.sol";
|
|
|
|
|
import "@openzeppelin/contracts/utils/Strings.sol";
|
|
|
|
|
import "@openzeppelin/contracts/utils/Base64.sol";
|
|
|
|
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
|
|
|
import "@openzeppelin/contracts/security/Pausable.sol";
|
|
|
|
|
import "@openzeppelin/contracts/token/common/ERC2981.sol";
|
|
|
|
|
|
|
|
|
|
contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, ERC2981, IERC223ReceivingContract, Ownable, Pausable {
|
|
|
|
|
contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, ERC2981, Ownable, Pausable {
|
|
|
|
|
using Address for address;
|
|
|
|
|
|
|
|
|
|
mapping (uint256 => address) public contracts;
|
|
|
|
@ -140,24 +139,6 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, E
|
|
|
|
|
destroyable = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@dev called by token 1 contract after transfer, this is the only method to wrap 1.
|
|
|
|
|
*/
|
|
|
|
|
function tokenFallback(address _from, uint256 _value, bytes memory) override external {
|
|
|
|
|
require(_from == owner(), "Only owner can wrap token 1");
|
|
|
|
|
require(msg.sender == contracts[1] , "Can only transfer from token 1 owner");
|
|
|
|
|
IMastersFedi curio = IMastersFedi(contracts[1]);
|
|
|
|
|
require (curio.balanceOf(address(this)) <= 450, "Sanity transfer exceeded");
|
|
|
|
|
// no balance check is done because an overflow would fail the sanity check anyway
|
|
|
|
|
|
|
|
|
|
balances[1][_from] += _value;
|
|
|
|
|
|
|
|
|
|
// mint
|
|
|
|
|
emit TransferSingle(msg.sender, address(0), _from, 1, _value);
|
|
|
|
|
|
|
|
|
|
// safe transfer acceptance check not necessary because locked to a known contract
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@notice Converts old-style NFT to new-style
|
|
|
|
|
@dev For an NFT ID, queries and transfers tokens from the appropriate
|
|
|
|
@ -169,7 +150,6 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, E
|
|
|
|
|
function wrap(uint256 _id, uint256 _quantity) external whenNotPaused {
|
|
|
|
|
address tokenContract = contracts[_id];
|
|
|
|
|
require(tokenContract != address(0), "invalid id");
|
|
|
|
|
require(_id != 1, "cannot wrap token 1 this way");
|
|
|
|
|
IMastersFedi curio = IMastersFedi(tokenContract);
|
|
|
|
|
|
|
|
|
|
// these are here for convenience because curio contract doesn't throw meaningful exceptions
|
|
|
|
@ -206,7 +186,6 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, E
|
|
|
|
|
|
|
|
|
|
address tokenContract = contracts[_id];
|
|
|
|
|
require(tokenContract != address(0), "invalid id");
|
|
|
|
|
require(_id != 1, "cannot wrap token 1 this way");
|
|
|
|
|
IMastersFedi curio = IMastersFedi(tokenContract);
|
|
|
|
|
|
|
|
|
|
require(curio.balanceOf(msg.sender) >= _quantity, "insufficient curio balance");
|
|
|
|
@ -235,7 +214,6 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, E
|
|
|
|
|
function unwrap(uint256 _id, uint256 _quantity) external whenNotPaused {
|
|
|
|
|
address tokenContract = contracts[_id];
|
|
|
|
|
require(tokenContract != address(0), "invalid id");
|
|
|
|
|
require(_id != 1, "token 1 cannot be unwrapped");
|
|
|
|
|
IMastersFedi curio = IMastersFedi(tokenContract);
|
|
|
|
|
|
|
|
|
|
require(balances[_id][msg.sender] >= _quantity, "insufficient balance");
|
|
|
|
@ -263,7 +241,6 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, E
|
|
|
|
|
|
|
|
|
|
address tokenContract = contracts[_id];
|
|
|
|
|
require(tokenContract != address(0), "invalid id");
|
|
|
|
|
require(_id != 1, "token 1 cannot be unwrapped");
|
|
|
|
|
IMastersFedi curio = IMastersFedi(tokenContract);
|
|
|
|
|
|
|
|
|
|
require(balances[_id][msg.sender] >= _quantity, "insufficient balance");
|
|
|
|
|