// Copyright (C) 2020 Energi Core // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity = 0.5.16; import { IERC20Storage } from "./IERC20Storage.sol"; contract ERC20Storage is IERC20Storage { address public pairsERC20; mapping (address => uint) private balance; mapping (address => mapping (address => uint)) private allowance; uint private totalSupply; mapping(address => uint) private nonce; modifier requirePairsERC20 { require(msg.sender == pairsERC20, "ERC20Storage: FORBIDDEN, not pairsERC20"); _; } constructor(address _pairsERC20) public { pairsERC20 = _pairsERC20; } // Self-destruct function kill() external requirePairsERC20 { selfdestruct(msg.sender); } // Update pairsERC20 implementation address function setPairsERC20(address _newPairsERC20) external requirePairsERC20 { pairsERC20 = _newPairsERC20; } // ERC20 functions function setBalance(address _owner, uint _amount) external requirePairsERC20 { balance[_owner] = _amount; } function setAllowance(address _owner, address _spender, uint _amount) external requirePairsERC20 { allowance[_owner][_spender] = _amount; } function setTotalSupply(uint _amount) external requirePairsERC20 { totalSupply = _amount; } function setNonce(address _owner, uint _nonce) external requirePairsERC20 { nonce[_owner] = _nonce; } function getBalance(address _account) external view returns(uint _balance) { _balance = balance[_account]; } function getAllowance(address _owner, address _spender) external view returns(uint _allowance) { _allowance = allowance[_owner][_spender]; } function getTotalSupply() external view returns(uint _totalSupply){ _totalSupply = totalSupply; } function getNonce(address _account) external view returns(uint _nonce) { _nonce = nonce[_account]; } }