/* Copyright 2017-2019 Phillip A. Elsasser Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity 0.5.2; import "./UpgradeableTarget.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol"; /// @title Upgradeable Token /// @notice allows for us to update some of the needed functionality in our tokens post deployment. Inspiration taken /// from Golems migrate functionality. /// @author Phil Elsasser contract UpgradeableToken is Ownable, ERC20Burnable { address public upgradeableTarget; // contract address handling upgrade uint256 public totalUpgraded; // total token amount already upgraded event Upgraded(address indexed from, address indexed to, uint256 value); /* // EXTERNAL METHODS - TOKEN UPGRADE SUPPORT */ /// @notice Update token to the new upgraded token /// @param value The amount of token to be migrated to upgraded token function upgrade(uint256 value) external { require(upgradeableTarget != address(0), "cannot upgrade with no target"); burn(value); // burn tokens as we migrate them. totalUpgraded = totalUpgraded.add(value); UpgradeableTarget(upgradeableTarget).upgradeFrom(msg.sender, value); emit Upgraded(msg.sender, upgradeableTarget, value); } /// @notice Set address of upgrade target process. /// @param upgradeAddress The address of the UpgradeableTarget contract. function setUpgradeableTarget(address upgradeAddress) external onlyOwner { upgradeableTarget = upgradeAddress; } }