Created
March 30, 2018 18:00
-
-
Save kirillsurkov/d4fea649687df0ac372b4e95d9b20a1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let FaceterToken = artifacts.require("./FaceterToken.sol"); | |
| let FaceterTokenLockV2 = artifacts.require("./FaceterTokenLockV2.sol"); | |
| let toNumber = (value, decimals) => value.slice(0, value.length-decimals) + "." + value.slice(value.length-decimals); | |
| let getTime = () => new Promise(next => web3.eth.getBlock("latest", (err, block) => next(block.timestamp))); | |
| let incTime = seconds => new Promise(next => | |
| web3.currentProvider.sendAsync({jsonrpc: "2.0", method: "evm_increaseTime", params: [seconds], id: 0}, () => | |
| web3.currentProvider.sendAsync({jsonrpc: "2.0", method: "evm_mine", id: 0}, next) | |
| ) | |
| ); | |
| const THREE_MONTHS = 7948800; | |
| module.exports = function(deployer, network, accounts) { | |
| const buffer = accounts[0]; | |
| deployer.deploy(FaceterToken, buffer).then(() => FaceterToken.deployed()).then(async faceterToken => { | |
| const decimals = parseInt((await faceterToken.decimals()).toString()); | |
| let faceterTokenLock = FaceterTokenLockV2.at(await faceterToken.holder()); | |
| let unlock = async () => { | |
| console.log("time: " + await getTime()); | |
| console.log("step: " + await faceterTokenLock.unlockStep()); | |
| console.log("trying to unlock"); | |
| try { | |
| await faceterTokenLock.unlock(); | |
| console.log("success"); | |
| } catch(e) { | |
| console.log("failed"); | |
| } | |
| console.log("buffer balance: " + (await faceterToken.balanceOf(buffer)).div("1" + Array(decimals).fill("0").join("")).toString()); | |
| console.log(); | |
| }; | |
| for (let i = 0; i < 9; i++) { | |
| await unlock(); | |
| await incTime(THREE_MONTHS); | |
| } | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment