Skip to content

Commit

Permalink
remove safemath in ERC1155Supply
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Mar 23, 2021
1 parent 0c5a661 commit d241577
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions contracts/token/ERC1155/extensions/ERC1155Supply.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
pragma solidity ^0.8.0;

import "../ERC1155.sol";
import "../../../utils/math/SafeMath.sol";

/**
* @dev ERC1155 token with totalSupply (per id).
Expand All @@ -14,8 +13,6 @@ import "../../../utils/math/SafeMath.sol";
* same id are not going to be minted
*/
abstract contract ERC1155Supply is ERC1155 {
using SafeMath for uint256;

mapping (uint256 => uint256) private _totalSupply;

/**
Expand All @@ -34,25 +31,25 @@ abstract contract ERC1155Supply is ERC1155 {

function _mint(address account, uint256 id, uint256 amount, bytes memory data) internal virtual override {
super._mint(account, id, amount, data);
_totalSupply[id] = _totalSupply[id].add(amount);
_totalSupply[id] += amount;
}

function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual override {
super._mintBatch(to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] = _totalSupply[ids[i]].add(amounts[i]);
_totalSupply[ids[i]] += amounts[i];
}
}

function _burn(address account, uint256 id, uint256 amount) internal virtual override {
super._burn(account, id, amount);
_totalSupply[id] = _totalSupply[id].sub(amount);
_totalSupply[id] -= amount;
}

function _burnBatch(address account, uint256[] memory ids, uint256[] memory amounts) internal virtual override {
super._burnBatch(account, ids, amounts);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] = _totalSupply[ids[i]].sub(amounts[i]);
_totalSupply[ids[i]] -= amounts[i];
}
}
}

0 comments on commit d241577

Please sign in to comment.