rm safemath new solidity doesn't need it
This commit is contained in:
parent
dcc29d5d4d
commit
6ede82efa8
|
@ -3,7 +3,6 @@ pragma solidity ^0.8.17;
|
|||
|
||||
import "./ERC1155.sol";
|
||||
import "./IMastersFedi.sol";
|
||||
import "./SafeMath.sol";
|
||||
import "./Address.sol";
|
||||
import "./IERC1155Metadata.sol";
|
||||
import "@openzeppelin/contracts/utils/Strings.sol";
|
||||
|
@ -11,7 +10,6 @@ import "@openzeppelin/contracts/utils/Base64.sol";
|
|||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
|
||||
contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, Ownable {
|
||||
using SafeMath for uint256;
|
||||
using Address for address;
|
||||
|
||||
mapping (uint256 => address) public contracts;
|
||||
|
@ -104,7 +102,7 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, Ownable {
|
|||
|
||||
curio.transferFrom(msg.sender, address(this), _quantity);
|
||||
|
||||
balances[_id][msg.sender] = balances[_id][msg.sender].add(_quantity);
|
||||
balances[_id][msg.sender] += _quantity;
|
||||
|
||||
// mint
|
||||
emit TransferSingle(msg.sender, address(0), msg.sender, _id, _quantity);
|
||||
|
@ -139,7 +137,7 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, Ownable {
|
|||
|
||||
curio.transferFrom(msg.sender, address(this), _quantity);
|
||||
|
||||
balances[_id][msg.sender] = balances[_id][msg.sender].add(_quantity);
|
||||
balances[_id][msg.sender] += _quantity;
|
||||
|
||||
if (callerIsContract) {
|
||||
_doSafeTransferAcceptanceCheck(msg.sender, msg.sender, msg.sender, _id, _quantity, '');
|
||||
|
@ -163,7 +161,7 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, Ownable {
|
|||
IMastersFedi curio = IMastersFedi(tokenContract);
|
||||
|
||||
require(balances[_id][msg.sender] >= _quantity, "insufficient balance");
|
||||
balances[_id][msg.sender] = balances[_id][msg.sender].sub(_quantity);
|
||||
balances[_id][msg.sender] -= _quantity;
|
||||
|
||||
curio.transfer(msg.sender, _quantity);
|
||||
|
||||
|
@ -188,7 +186,7 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, Ownable {
|
|||
IMastersFedi curio = IMastersFedi(tokenContract);
|
||||
|
||||
require(balances[_id][msg.sender] >= _quantity, "insufficient balance");
|
||||
balances[_id][msg.sender] = balances[_id][msg.sender].sub(_quantity);
|
||||
balances[_id][msg.sender] -= _quantity;
|
||||
|
||||
curio.transfer(msg.sender, _quantity);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
pragma solidity ^0.8.17;
|
||||
|
||||
import "./SafeMath.sol";
|
||||
import "./Address.sol";
|
||||
import "./Common.sol";
|
||||
import "./IERC1155TokenReceiver.sol";
|
||||
|
@ -10,7 +9,6 @@ import "./IERC1155.sol";
|
|||
// A sample implementation of core ERC1155 function.
|
||||
contract ERC1155 is IERC1155, ERC165, CommonConstants
|
||||
{
|
||||
using SafeMath for uint256;
|
||||
using Address for address;
|
||||
|
||||
// id => (owner => balance)
|
||||
|
@ -69,10 +67,8 @@ contract ERC1155 is IERC1155, ERC165, CommonConstants
|
|||
require(_to != address(0x0), "_to must be non-zero.");
|
||||
require(_from == msg.sender || operatorApproval[_from][msg.sender] == true, "Need operator approval for 3rd party transfers.");
|
||||
|
||||
// SafeMath will throw with insuficient funds _from
|
||||
// or if _id is not valid (balance will be 0)
|
||||
balances[_id][_from] = balances[_id][_from].sub(_value);
|
||||
balances[_id][_to] = _value.add(balances[_id][_to]);
|
||||
balances[_id][_from] -= _value;
|
||||
balances[_id][_to] += _value;
|
||||
|
||||
// MUST emit event
|
||||
emit TransferSingle(msg.sender, _from, _to, _id, _value);
|
||||
|
@ -111,10 +107,8 @@ contract ERC1155 is IERC1155, ERC165, CommonConstants
|
|||
uint256 id = _ids[i];
|
||||
uint256 value = _values[i];
|
||||
|
||||
// SafeMath will throw with insuficient funds _from
|
||||
// or if _id is not valid (balance will be 0)
|
||||
balances[id][_from] = balances[id][_from].sub(value);
|
||||
balances[id][_to] = value.add(balances[id][_to]);
|
||||
balances[id][_from] -= value;
|
||||
balances[id][_to] += value;
|
||||
}
|
||||
|
||||
// Note: instead of the below batch versions of event and acceptance check you MAY have emitted a TransferSingle
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
pragma solidity ^0.8.17;
|
||||
|
||||
|
||||
/**
|
||||
* @title SafeMath
|
||||
* @dev Math operations with safety checks that throw on error
|
||||
*/
|
||||
library SafeMath {
|
||||
|
||||
/**
|
||||
* @dev Multiplies two numbers, throws on overflow.
|
||||
*/
|
||||
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
||||
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
|
||||
// benefit is lost if 'b' is also tested.
|
||||
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
|
||||
if (a == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
c = a * b;
|
||||
assert(c / a == b);
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Integer division of two numbers, truncating the quotient.
|
||||
*/
|
||||
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
// assert(b > 0); // Solidity automatically throws when dividing by 0
|
||||
// uint256 c = a / b;
|
||||
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
|
||||
*/
|
||||
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
assert(b <= a);
|
||||
return a - b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Adds two numbers, throws on overflow.
|
||||
*/
|
||||
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
||||
c = a + b;
|
||||
assert(c >= a);
|
||||
return c;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue