convert TokenVesting to initializers
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../Initializable.sol";
|
||||
import "../token/ERC20/SafeERC20.sol";
|
||||
import "../ownership/Ownable.sol";
|
||||
import "../math/SafeMath.sol";
|
||||
@ -13,7 +14,7 @@ import "../math/SafeMath.sol";
|
||||
* typical vesting scheme, with a cliff and vesting period. Optionally revocable by the
|
||||
* owner.
|
||||
*/
|
||||
contract TokenVesting is Ownable {
|
||||
contract TokenVesting is Initializable, Ownable {
|
||||
using SafeMath for uint256;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
@ -42,7 +43,7 @@ contract TokenVesting is Ownable {
|
||||
* @param duration duration in seconds of the period in which the tokens will vest
|
||||
* @param revocable whether the vesting is revocable or not
|
||||
*/
|
||||
constructor(
|
||||
function initialize(
|
||||
address beneficiary,
|
||||
uint256 start,
|
||||
uint256 cliffDuration,
|
||||
@ -50,7 +51,10 @@ contract TokenVesting is Ownable {
|
||||
bool revocable
|
||||
)
|
||||
public
|
||||
initializer
|
||||
{
|
||||
Ownable.initialize();
|
||||
|
||||
require(beneficiary != address(0));
|
||||
require(cliffDuration <= duration);
|
||||
|
||||
|
||||
22
contracts/mocks/TokenVestingMock.sol
Normal file
22
contracts/mocks/TokenVestingMock.sol
Normal file
@ -0,0 +1,22 @@
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../Initializable.sol";
|
||||
import "../drafts/TokenVesting.sol";
|
||||
|
||||
contract TokenVestingMock is Initializable, TokenVesting {
|
||||
constructor(
|
||||
address beneficiary,
|
||||
uint256 start,
|
||||
uint256 cliffDuration,
|
||||
uint256 duration,
|
||||
bool revocable
|
||||
) public {
|
||||
TokenVesting.initialize(
|
||||
beneficiary,
|
||||
start,
|
||||
cliffDuration,
|
||||
duration,
|
||||
revocable
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -10,8 +10,8 @@ require('chai')
|
||||
.use(require('chai-bignumber')(BigNumber))
|
||||
.should();
|
||||
|
||||
const ERC20Mintable = artifacts.require('ERC20Mintable');
|
||||
const TokenVesting = artifacts.require('TokenVesting');
|
||||
const ERC20Mintable = artifacts.require('ERC20MintableMock');
|
||||
const TokenVesting = artifacts.require('TokenVestingMock');
|
||||
|
||||
contract('TokenVesting', function ([_, owner, beneficiary]) {
|
||||
const amount = new BigNumber(1000);
|
||||
|
||||
Reference in New Issue
Block a user