Skip to content

Commit

Permalink
Merge 19649f1 into fac8a4a
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVicente committed Sep 6, 2018
2 parents fac8a4a + 19649f1 commit 784d6ce
Show file tree
Hide file tree
Showing 9 changed files with 3,033 additions and 802 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/build
/CLI/node_modules
.npm-debug.log
*.DS_Store
privKey
Expand Down
74 changes: 38 additions & 36 deletions CLI/commands/ST20Generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,25 @@ async function cappedSTO_launch() {
console.log("\n");
console.log('\x1b[34m%s\x1b[0m',"Token Creation - Capped STO in No. of Tokens");

let stoFee = cappedSTOFee;
let contractBalance = await polyToken.methods.balanceOf(securityToken._address).call();
let requiredAmount = web3.utils.toWei(stoFee.toString(), "ether");
if (parseInt(contractBalance) < parseInt(requiredAmount)) {
let transferAmount = parseInt(requiredAmount) - parseInt(contractBalance);
let ownerBalance = await polyToken.methods.balanceOf(Issuer.address).call();
if(parseInt(ownerBalance) < transferAmount) {
console.log(chalk.red(`\n**************************************************************************************************************************************************`));
console.log(chalk.red(`Not enough balance to pay the CappedSTO fee, Requires ${(new BigNumber(transferAmount).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY but have ${(new BigNumber(ownerBalance).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY. Access POLY faucet to get the POLY to complete this txn`));
console.log(chalk.red(`**************************************************************************************************************************************************\n`));
process.exit(0);
} else {
let transferAction = polyToken.methods.transfer(securityToken._address, new BigNumber(transferAmount));
let receipt = await common.sendTransaction(Issuer, transferAction, defaultGasPrice);
let event = common.getEventFromLogs(polyToken._jsonInterface, receipt.logs, 'Transfer');
console.log(`Number of POLY sent: ${web3.utils.fromWei(new web3.utils.BN(event._value))}`)
}
}

let cap;
if (typeof _stoConfig !== 'undefined' && _stoConfig.hasOwnProperty('cap')) {
cap = _stoConfig.cap.toString();
Expand Down Expand Up @@ -432,24 +451,6 @@ async function cappedSTO_launch() {
]
}, [startTime, endTime, web3.utils.toWei(cap, 'ether'), rate, raiseType, wallet]);

let stoFee = cappedSTOFee;
let contractBalance = await polyToken.methods.balanceOf(securityToken._address).call();
let requiredAmount = web3.utils.toWei(stoFee.toString(), "ether");
if (parseInt(contractBalance) < parseInt(requiredAmount)) {
let transferAmount = parseInt(requiredAmount) - parseInt(contractBalance);
let ownerBalance = await polyToken.methods.balanceOf(Issuer.address).call();
if(parseInt(ownerBalance) < transferAmount) {
console.log(chalk.red(`\n**************************************************************************************************************************************************`));
console.log(chalk.red(`Not enough balance to pay the CappedSTO fee, Requires ${(new BigNumber(transferAmount).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY but have ${(new BigNumber(ownerBalance).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY. Access POLY faucet to get the POLY to complete this txn`));
console.log(chalk.red(`**************************************************************************************************************************************************\n`));
process.exit(0);
} else {
let transferAction = polyToken.methods.transfer(securityToken._address, new BigNumber(transferAmount));
let receipt = await common.sendTransaction(Issuer, transferAction, defaultGasPrice);
let event = common.getEventFromLogs(polyToken._jsonInterface, receipt.logs, 'Transfer');
console.log(`Number of POLY sent: ${web3.utils.fromWei(new web3.utils.BN(event._value))}`)
}
}
let addModuleAction = securityToken.methods.addModule(cappedSTOFactoryAddress, bytesSTO, new BigNumber(stoFee).times(new BigNumber(10).pow(18)), 0);
let receipt = await common.sendTransaction(Issuer, addModuleAction, defaultGasPrice);
let event = common.getEventFromLogs(securityToken._jsonInterface, receipt.logs, 'LogModuleAdded');
Expand Down Expand Up @@ -724,6 +725,25 @@ async function usdTieredSTO_launch() {
console.log("\n");
console.log('\x1b[34m%s\x1b[0m',"Token Creation - USD Tiered STO");

let stoFee = usdTieredSTOFee;
let contractBalance = await polyToken.methods.balanceOf(securityToken._address).call();
let requiredAmount = web3.utils.toWei(stoFee.toString(), "ether");
if (parseInt(contractBalance) < parseInt(requiredAmount)) {
let transferAmount = parseInt(requiredAmount) - parseInt(contractBalance);
let ownerBalance = await polyToken.methods.balanceOf(Issuer.address).call();
if(parseInt(ownerBalance) < transferAmount) {
console.log(chalk.red(`\n**************************************************************************************************************************************************`));
console.log(chalk.red(`Not enough balance to pay the ${selectedSTO} fee, Requires ${(new BigNumber(transferAmount).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY but have ${(new BigNumber(ownerBalance).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY. Access POLY faucet to get the POLY to complete this txn`));
console.log(chalk.red(`**************************************************************************************************************************************************\n`));
process.exit(0);
} else {
let transferAction = polyToken.methods.transfer(securityToken._address, new BigNumber(transferAmount));
let receipt = await common.sendTransaction(Issuer, transferAction, defaultGasPrice, 0, 1.5);
let event = common.getEventFromLogs(polyToken._jsonInterface, receipt.logs, 'Transfer');
console.log(`Number of POLY sent: ${web3.utils.fromWei(new web3.utils.BN(event._value))}`)
}
}

let funding = fundingConfigUSDTieredSTO();
let addresses = addressesConfigUSDTieredSTO();
let tiers = tiersConfigUSDTieredSTO(funding.raiseType.includes(1));
Expand Down Expand Up @@ -782,24 +802,6 @@ async function usdTieredSTO_launch() {
addresses.reserveWallet
]);

let stoFee = usdTieredSTOFee;
let contractBalance = await polyToken.methods.balanceOf(securityToken._address).call();
let requiredAmount = web3.utils.toWei(stoFee.toString(), "ether");
if (parseInt(contractBalance) < parseInt(requiredAmount)) {
let transferAmount = parseInt(requiredAmount) - parseInt(contractBalance);
let ownerBalance = await polyToken.methods.balanceOf(Issuer.address).call();
if(parseInt(ownerBalance) < transferAmount) {
console.log(chalk.red(`\n**************************************************************************************************************************************************`));
console.log(chalk.red(`Not enough balance to pay the ${selectedSTO} fee, Requires ${(new BigNumber(transferAmount).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY but have ${(new BigNumber(ownerBalance).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY. Access POLY faucet to get the POLY to complete this txn`));
console.log(chalk.red(`**************************************************************************************************************************************************\n`));
process.exit(0);
} else {
let transferAction = polyToken.methods.transfer(securityToken._address, new BigNumber(transferAmount));
let receipt = await common.sendTransaction(Issuer, transferAction, defaultGasPrice, 0, 1.5);
let event = common.getEventFromLogs(polyToken._jsonInterface, receipt.logs, 'Transfer');
console.log(`Number of POLY sent: ${web3.utils.fromWei(new web3.utils.BN(event._value))}`)
}
}
let addModuleAction = securityToken.methods.addModule(usdTieredSTOFactoryAddress, bytesSTO, new BigNumber(stoFee).times(new BigNumber(10).pow(18)), 0);
let receipt = await common.sendTransaction(Issuer, addModuleAction, defaultGasPrice);
let event = common.getEventFromLogs(securityToken._jsonInterface, receipt.logs, 'LogModuleAdded');
Expand Down
Loading

0 comments on commit 784d6ce

Please sign in to comment.