Skip to content

Commit

Permalink
Merge 130359d into 45eab4a
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVicente committed Sep 12, 2018
2 parents 45eab4a + 130359d commit 8aa1f56
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 40 deletions.
36 changes: 23 additions & 13 deletions CLI/commands/ST20Generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async function step_ticker_reg(){

if (!alreadyRegistered) {
await step_approval(tickerRegistryAddress, regFee);
let registerTickerAction = tickerRegistry.methods.registerTicker(Issuer.address, tokenSymbol, "", web3.utils.asciiToHex(""));
let registerTickerAction = tickerRegistry.methods.registerTicker(Issuer.address, tokenSymbol, "");
await common.sendTransaction(Issuer, registerTickerAction, defaultGasPrice);
}
}
Expand Down Expand Up @@ -365,7 +365,7 @@ async function cappedSTO_launch() {
process.exit(0);
} else {
let transferAction = polyToken.methods.transfer(securityToken._address, new BigNumber(transferAmount));
let receipt = await common.sendTransaction(Issuer, transferAction, defaultGasPrice);
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))}`)
}
Expand Down Expand Up @@ -407,13 +407,13 @@ async function cappedSTO_launch() {

let raiseType;
if (typeof _stoConfig !== 'undefined' && _stoConfig.hasOwnProperty('raiseType')) {
raiseType = _stoConfig.raiseType;
raiseType = [_stoConfig.raiseType];
} else {
raiseType = readlineSync.question('Enter' + chalk.green(` P `) + 'for POLY raise or leave empty for Ether raise (E):');
if (raiseType.toUpperCase() == 'P' ) {
raiseType = 1;
raiseType = [1];
} else {
raiseType = 0;
raiseType = [0];
}
}

Expand Down Expand Up @@ -442,8 +442,8 @@ async function cappedSTO_launch() {
type: 'uint256',
name: '_rate'
},{
type: 'uint8',
name: '_fundRaiseType'
type: 'uint8[]',
name: '_fundRaiseTypes'
},{
type: 'address',
name: '_fundsReceiver'
Expand All @@ -467,15 +467,25 @@ async function cappedSTO_status() {
let displayRate = await currentSTO.methods.rate().call();
let displayCap = await currentSTO.methods.cap().call();
let displayWallet = await currentSTO.methods.wallet().call();
let displayRaiseType = await currentSTO.methods.fundRaiseType(0).call() ? 'ETH' : 'POLY';
let displayFundsRaised = await currentSTO.methods.fundsRaised().call();
let displayTokensSold = await currentSTO.methods.tokensSold().call();
let displayRaiseType;
let displayFundsRaised;
let displayWalletBalance;
let raiseType = await currentSTO.methods.fundRaiseType(0).call();
if (raiseType) {
displayRaiseType = 'ETH';
displayFundsRaised = await currentSTO.methods.fundsRaisedETH().call();
displayWalletBalance = web3.utils.fromWei(await web3.eth.getBalance(displayWallet));
} else {
displayRaiseType = 'POLY';
displayFundsRaised = await currentSTO.methods.fundsRaisedPOLY().call();
displayWalletBalance = await currentBalance(displayWallet);
}
let displayTokensSold = await currentSTO.methods.totalTokensSold().call();
let displayInvestorCount = await currentSTO.methods.investorCount().call();
let displayTokenSymbol = await securityToken.methods.symbol().call();

let displayWalletBalance = web3.utils.fromWei(await web3.eth.getBalance(displayWallet),"ether");
let formattedCap = BigNumber(web3.utils.fromWei(displayCap,"ether"));
let formattedSold = BigNumber(web3.utils.fromWei(displayTokensSold,"ether"));
let formattedCap = BigNumber(web3.utils.fromWei(displayCap));
let formattedSold = BigNumber(web3.utils.fromWei(displayTokensSold));

let now = Math.floor(Date.now()/1000);
let timeTitle;
Expand Down
5 changes: 2 additions & 3 deletions CLI/commands/TickerRollForward.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ let polyToken;
let tickerRegistry;
let tickerRegistryAddress;

function Ticker(_owner, _symbol, _name, _swarmHash) {
function Ticker(_owner, _symbol, _name) {
this.owner = _owner;
this.symbol = _symbol;
this.name = _name;
this.swarmHash = _swarmHash;
}

function FailedRegistration(_ticker, _error) {
Expand Down Expand Up @@ -115,7 +114,7 @@ async function registerTickers() {

if (valid) {
try {
let registerTickerAction = tickerRegistry.methods.registerTicker(owner, ticker_data[i].symbol, ticker_data[i].name, ticker_data[i].swarmHash);
let registerTickerAction = tickerRegistry.methods.registerTicker(owner, ticker_data[i].symbol, ticker_data[i].name);
let receipt = await common.sendTransaction(Issuer, registerTickerAction, defaultGasPrice);
registered_tickers.push(ticker_data[i]);
console.log(ticker_data[i]);
Expand Down
4 changes: 2 additions & 2 deletions CLI/commands/dividends_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ async function start_explorer(){
}

async function mintTokens(address, amount){
if (await securityToken.methods.finishedIssuerMinting().call()) {
console.log(chalk.red("Minting is not possible - Minting has been permanently disabled by issuer"));
if (await securityToken.methods.mintingFrozen().call()) {
console.log(chalk.red("Minting is not possible - Minting has been permanently frozen by issuer"));
} else {
let result = await securityToken.methods.getModule(3, 0).call();
let isSTOAttached = result[1] != "0x0000000000000000000000000000000000000000";
Expand Down
5 changes: 5 additions & 0 deletions CLI/commands/helpers/contract_abis.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let polymathRegistryABI;
let tickerRegistryABI;
let securityTokenRegistryABI;
let featureRegistryABI;
let securityTokenABI;
let cappedSTOABI;
let usdTieredSTOABI;
Expand All @@ -15,6 +16,7 @@ try {
polymathRegistryABI = JSON.parse(require('fs').readFileSync('./build/contracts/PolymathRegistry.json').toString()).abi;
tickerRegistryABI = JSON.parse(require('fs').readFileSync('./build/contracts/TickerRegistry.json').toString()).abi;
securityTokenRegistryABI = JSON.parse(require('fs').readFileSync('./build/contracts/SecurityTokenRegistry.json').toString()).abi;
featureRegistryABI = JSON.parse(require('fs').readFileSync('./build/contracts/FeatureRegistry.json').toString()).abi;
securityTokenABI = JSON.parse(require('fs').readFileSync('./build/contracts/SecurityToken.json').toString()).abi;
cappedSTOABI = JSON.parse(require('fs').readFileSync('./build/contracts/CappedSTO.json').toString()).abi;
usdTieredSTOABI = JSON.parse(require('fs').readFileSync('./build/contracts/USDTieredSTO.json').toString()).abi;
Expand All @@ -39,6 +41,9 @@ module.exports = {
securityTokenRegistry: function () {
return securityTokenRegistryABI;
},
featureRegistry: function () {
return featureRegistryABI;
},
securityToken: function () {
return securityTokenABI;
},
Expand Down
4 changes: 4 additions & 0 deletions CLI/commands/helpers/contract_addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ module.exports = {
let polymathRegistry = await getPolymathRegistry();
return await polymathRegistry.methods.getAddress("ModuleRegistry").call();
},
featureRegistry: async function() {
let polymathRegistry = await getPolymathRegistry();
return await polymathRegistry.methods.getAddress("FeatureRegistry").call();
},
polyToken: async function() {
let polymathRegistry = await getPolymathRegistry();
return await polymathRegistry.methods.getAddress("PolyToken").call();
Expand Down
35 changes: 17 additions & 18 deletions CLI/commands/module_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ async function iterateModules(_moduleType) {
}

async function selectAction() {
let options = ['Add a module','Pause / unpause a module','Remove a module','Change module budget','Whitelist an address for a year','Mint tokens','End minting for Issuer','End minting for STO','Exit'];
let options = ['Add a module','Pause / unpause a module','Remove a module','Change module budget','Whitelist an address for a year','Mint tokens','Freeze minting permanently','Exit'];
let index = readlineSync.keyInSelect(options, chalk.yellow('What do you want to do?'), {cancel: false});
console.log("\nSelected:",options[index]);
switch (index) {
Expand All @@ -226,12 +226,9 @@ async function selectAction() {
await mintTokens();
break;
case 6:
await endMintingForIssuer();
await freezeMinting();
break;
case 7:
await endMintingForSTO();
break;
case 8:
process.exit();
}
displayModules()
Expand Down Expand Up @@ -325,9 +322,8 @@ async function whitelist() {
}

async function mintTokens() {
let _flag = await securityToken.methods.finishedIssuerMinting().call();
if (_flag) {
console.log(chalk.red("Minting is not possible - Minting has been permanently disabled by issuer"));
if (await securityToken.methods.mintingFrozen().call()) {
console.log(chalk.red("Minting is not possible - Minting has been permanently frozen by issuer"));
return;
}
let result = await securityToken.methods.getModule(3, 0).call();
Expand All @@ -354,17 +350,20 @@ async function mintTokens() {
backToMenu()
}

async function endMintingForSTO() {
let finishMintingSTOAction = securityToken.methods.finishMintingSTO();
await common.sendTransaction(Issuer, finishMintingSTOAction, defaultGasPrice);
console.log(chalk.green(`\nEnd minting for STO was successful.`));
backToMenu();
}
async function freezeMinting() {
let featureRegistryAddress = await contracts.featureRegistry();
let featureRegistryABI = abis.featureRegistry();
let featureRegistry = new web3.eth.Contract(featureRegistryABI, featureRegistryAddress);
featureRegistry.setProvider(web3.currentProvider);

if (await featureRegistry.methods.getFeatureStatus('freezeMintingAllowed').call()) {
let freezeMintingAction = securityToken.methods.freezeMinting();
await common.sendTransaction(Issuer, freezeMintingAction, defaultGasPrice);
console.log(chalk.green(`\nFreeze minting was successful.`));
} else {
console.log(chalk.red(`\nFreeze minting is not allowed by Polymath.`));
}

async function endMintingForIssuer() {
let finishMintingIssuerAction = securityToken.methods.finishMintingIssuer();
await common.sendTransaction(Issuer, finishMintingIssuerAction, defaultGasPrice);
console.log(chalk.green(`\nEnd minting for Issuer was successful.`));
backToMenu();
}

Expand Down
5 changes: 2 additions & 3 deletions CLI/commands/strMigrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ async function step_get_deployed_tokens(securityTokenRegistry) {
let tokenSymbol = await token.methods.symbol().call();
let tokenOwner = event.returnValues._owner;//await token.methods.owner().call();
let tokenDetails = await token.methods.tokenDetails().call();
let tokenSwarmHash = '';

tokens.push({ name: tokenName, symbol: tokenSymbol, owner: tokenOwner, details: tokenDetails, address: tokenAddress, swarmHash: tokenSwarmHash });
tokens.push({ name: tokenName, symbol: tokenSymbol, owner: tokenOwner, details: tokenDetails, address: tokenAddress });
}
}

Expand All @@ -124,7 +123,7 @@ async function step_add_Custom_STs(tokens, toStr) {
console.log(`Token address: ${t.address}`);
console.log(`\n`);
try {
let addCustomSTAction = toStr.methods.addCustomSecurityToken(t.name, t.symbol, t.owner, t.address, t.details, web3.utils.asciiToHex(t.swarmHash));
let addCustomSTAction = toStr.methods.addCustomSecurityToken(t.name, t.symbol, t.owner, t.address, t.details);
let receipt = await common.sendTransaction(Issuer, addCustomSTAction, defaultGasPrice);
totalGas = totalGas.add(new web3.utils.BN(receipt.gasUsed));
succeed.push(t);
Expand Down
2 changes: 1 addition & 1 deletion test/o_security_token.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ contract('SecurityToken', accounts => {
try {
await I_SecurityToken.freezeMinting({from: account_temp});
} catch(error) {
console.log(` tx revert -> finishMintingIssuer only be called by the owner of the SecurityToken`.grey);
console.log(` tx revert -> freezeMinting only be called by the owner of the SecurityToken`.grey);
errorThrown = true;
ensureException(error);
}
Expand Down

0 comments on commit 8aa1f56

Please sign in to comment.