Skip to content

Commit

Permalink
Merge pull request #2 from PolymathNetwork/development-1.5.0
Browse files Browse the repository at this point in the history
Development 1.5.0
  • Loading branch information
glitch003 authored Sep 28, 2018
2 parents 706a464 + 2907cd6 commit 6421e09
Show file tree
Hide file tree
Showing 83 changed files with 4,720 additions and 2,882 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ cache:
- node_modules
matrix:
fast_finish: true
before_install:
- echo -ne '\n' | sudo add-apt-repository ppa:ethereum/ethereum
- sudo apt-get -y update
- sudo apt-get -y install solc
before_script:
- truffle version
script:
- npm run test
- npm run docs
notifications:
slack:
secure: W4FZSabLrzF74f317hutolEHnlq2GBlQxU6b85L5XymrjgLEhlgE16c5Qz7Emoyt6le6PXL+sfG2ujJc3XYys/6hppgrHSAasuJnKCdQNpmMZ9BNyMs6WGkmB3enIf3K/FLXb26AQdwpQdIXuOeJUTf879u+YoiZV0eZH8d3+fsIOyovq9N6X5pKOpDM9iT8gGB4t7fie7xf51s+iUaHxyO9G7jDginZ4rBXHcU7mxCub9z+Z1H8+kCTnPWaF+KKVEXx4Z0nI3+urboD7E4OIP02LwrThQls2CppA3X0EoesTcdvj/HLErY/JvsXIFiFEEHZzB1Wi+k2TiOeLcYwEuHIVij+HPxxlJNX/j8uy01Uk8s4rd+0EhvfdKHJqUKqxH4YN2npcKfHEss7bU3y7dUinXQfYShW5ZewHdvc7pnnxBTfhvmdi64HdNrXAPq+s1rhciH7MmnU+tsm4lhrpr+FBuHzUMA9fOCr7b0SQytZEgWpiUls88gdbh3yG8TjyZxmZJGx09cwEP0q7VoH0UwFh7mIu5XmYdd5tWUhavTiO7YV8cUPn7MvwMsTltB3YBpF/fB26L7ka8zBhCsjm9prW6SVYU/dyO3m91VeZtO/zJFHRDA6Q58JGVW2rgzO39z193qC1EGRXqTie96VwAAtNg8+hRb+bI/CWDVzSPc=
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
[__1.5.0__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __15-08-18__

## Added
* Added `getTokensByOwner` to STR
* Added withholding tax to ether & erc20 dividends
* Generalised MakerDAO oracle to allow different instances referencing different currencies
* Added DAI as a fundraising currency to USDTieredSTO
* `transferTickerOwnership()` function is introduced in `TickerRegistry` to transfer the ticker ownership after the registeration #191.
Expand All @@ -22,9 +24,10 @@ All notable changes to this project will be documented in this file.
## Fixed
* Generalize the STO varaible names and added them in `ISTO.sol` to use the common standard in all STOs.
* Generalize the event when any new token get registered with the polymath ecosystem. `LogNewSecurityToken` should emit _ticker, _name, _securityTokenAddress, _owner, _addedAt, _registrant respectively. #230

## Removed
* Remove `swarmHash` from the `registerTicker(), addCustomTicker(), generateSecurityToken(), addCustomSecurityToken()` functions of TickerRegistry.sol and SecurityTokenRegistry.sol. #230

## Removed
* Remove `swarmHash` from the `registerTicker(), addCustomTicker(), generateSecurityToken(), addCustomSecurityToken()` functions of TickerRegistry.sol and SecurityTokenRegistry.sol. #230
* Remove `Log` prefix from all the event present in the ecosystem.

======

Expand Down
424 changes: 204 additions & 220 deletions CLI/commands/ST20Generator.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion CLI/commands/TickerRollForward.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ var abis = require('./helpers/contract_abis');
let remoteNetwork = process.argv.slice(2)[0]; //batch size

///////////////////////// GLOBAL VARS /////////////////////////
const REG_FEE_KEY = 'tickerRegFee';

let ticker_data = [];
let registered_tickers = [];
let failed_tickers = [];
Expand Down Expand Up @@ -78,7 +80,7 @@ async function readFile() {
async function registerTickers() {
// Poly approval for registration fees
let polyBalance = BigNumber(await polyToken.methods.balanceOf(Issuer.address).call());
let fee = await securityTokenRegistry.methods.getUintValues(web3.utils.toHex('tickerRegFee')).call();
let fee = web3.utils.fromWei(await securityTokenRegistry.methods.getUintValues(web3.utils.soliditySha3(REG_FEE_KEY)).call());
let totalFee = BigNumber(ticker_data.length).mul(fee);

if (totalFee.gt(polyBalance)) {
Expand Down
7 changes: 2 additions & 5 deletions CLI/commands/common/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ module.exports = {
Issuer = await web3.eth.accounts.privateKeyToAccount("0x" + privKey);
} else {
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
let accounts = await web3.eth.getAccounts();
Issuer = {
address: accounts[0],
privateKey: require('fs').readFileSync('./privKeyLocal').toString()
};
let privKeyLocal = require('fs').readFileSync('./privKeyLocal').toString()
Issuer = await web3.eth.accounts.privateKeyToAccount("0x" + privKeyLocal);
}
defaultGasPrice = getGasPrice(await web3.eth.net.getId());
}
Expand Down
208 changes: 208 additions & 0 deletions CLI/commands/contract_manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
const duration = {
seconds: function (val) { return val; },
minutes: function (val) { return val * this.seconds(60); },
hours: function (val) { return val * this.minutes(60); },
days: function (val) { return val * this.hours(24); },
weeks: function (val) { return val * this.days(7); },
years: function (val) { return val * this.days(365); },
};
var readlineSync = require('readline-sync');
var chalk = require('chalk');
var common = require('./common/common_functions');
var global = require('./common/global');
var contracts = require('./helpers/contract_addresses');
var abis = require('./helpers/contract_abis');

const OWNER_KEY = 'owner';
const REG_FEE_KEY = 'tickerRegFee';
const LAUNCH_FEE_KEY = 'stLaunchFee';
const EXPIRY_LIMIT_KEY = 'expiryLimit';

// App flow
let currentContract = null;

async function executeApp(remoteNetwork) {
await global.initialize(remoteNetwork);

common.logAsciiBull();
console.log("*********************************************");
console.log("Welcome to the Command-Line Contract Manager.");
console.log("*********************************************");
console.log("Issuer Account: " + Issuer.address + "\n");

//await setup();
try {
await selectContract();
} catch (err) {
console.log(err);
return;
}
};

async function selectContract() {
console.log('\n\x1b[34m%s\x1b[0m',"Contract Manager - Contract selection");
let contractList = ['PolymathRegistry', 'FeatureRegistry', 'SecurityTokenRegistry', 'ModuleRegistry'];

while (!currentContract) {
let index = readlineSync.keyInSelect(contractList, `Select a contract: `);
let selected = index == -1 ? 'CANCEL' : contractList[index];
switch (selected) {
case 'PolymathRegistry':
console.log(chalk.red(`
*********************************
This option is not yet available.
*********************************`));
break;
case 'FeatureRegistry':
console.log(chalk.red(`
*********************************
This option is not yet available.
*********************************`));
break;
case 'SecurityTokenRegistry':
let strAdress = await contracts.securityTokenRegistry();
let strABI = abis.securityTokenRegistry();
currentContract = new web3.eth.Contract(strABI, strAdress);
await strActions();
break;
case 'ModuleRegistry':
console.log(chalk.red(`
*********************************
This option is not yet available.
*********************************`));
break;
case 'CANCEL':
process.exit(0);
}
}
}

async function strActions() {
console.log('\n\x1b[34m%s\x1b[0m',"Security Token Registry - Main menu");
let contractOwner = await currentContract.methods.getAddressValues(web3.utils.soliditySha3(OWNER_KEY)).call();

if (contractOwner != Issuer.address) {
console.log(chalk.red(`You are not the owner of this contract. Current owner is ${contractOwner}`));
currentContract = null;
} else {
let actions = ['Modify Ticker', 'Remove Ticker', 'Modify SecurityToken', 'Change Expiry Limit', 'Change registration fee', 'Change ST launch fee'];
let index = readlineSync.keyInSelect(actions, 'What do you want to do? ');
let selected = index == -1 ? 'CANCEL' : actions[index];
switch (selected) {
case 'Modify Ticker':
let tickerToModify = readlineSync.question('Enter the token symbol that you want to add or modify: ');
let tickerToModifyDetails = await currentContract.methods.getTickerDetails(tickerToModify).call();
if (tickerToModifyDetails[1] == 0) {
console.log(chalk.yellow(`${ticker} is not registered.`));
} else {
console.log(`\n-- Current Ticker details --`);
console.log(` Owner: ${tickerToModifyDetails[0]}`);
console.log(` Registration date: ${tickerToModifyDetails[1]}`);
console.log(` Expiry date: ${tickerToModifyDetails[2]}`);
console.log(` Token name: ${tickerToModifyDetails[3]}`);
console.log(` Status: ${tickerToModifyDetails[4] ? 'Deployed' : 'Not deployed'}\n`);
}
let tickerOwner = readlineSync.question(`Enter the token owner: `, {
limit: function(input) {
return web3.utils.isAddress(input);
},
limitMessage: "Must be a valid address"
});
let tickerSTName = readlineSync.question(`Enter the token name: `);
let tickerRegistrationDate = readlineSync.question(`Enter the Unix Epoch time on which ticker get registered: `);
let tickerExpiryDate = readlineSync.question(`Enter the Unix Epoch time on wich the ticker will expire: `);
let tickerStatus = readlineSync.keyInYNStrict(`Is the token deployed?`);
let modifyTickerAction = currentContract.methods.modifyTicker(tickerOwner, tickerToModify, tickerSTName, tickerRegistrationDate, tickerExpiryDate, tickerStatus);
await common.sendTransaction(Issuer, modifyTickerAction, defaultGasPrice, 0, 1.5);
console.log(chalk.green(`Ticker has been updated successfuly`));
break;
case 'Remove Ticker':
let tickerToRemove = readlineSync.question('Enter the token symbol that you want to add or modify: ');
let tickerToRemoveDetails = await currentContract.methods.getTickerDetails(tickerToRemove).call();
if (tickerToRemoveDetails[1] == 0) {
console.log(chalk.yellow(`${ticker} does not exist.`));
} else {
let removeTickerAction = currentContract.methods.removeTicker(tickerToRemove);
await common.sendTransaction(Issuer, removeTickerAction, defaultGasPrice, 0, 3);
console.log(chalk.green(`Ticker has been removed successfuly`));
}
break;
case 'Modify SecurityToken':
let stAddress = readlineSync.question('Enter the security token address that you want to add or modify: ', {
limit: function(input) {
return web3.utils.isAddress(input);
},
limitMessage: "Must be a valid address"
});
let ticker;
let stData = await currentContract.methods.getSecurityTokenData(stAddress).call();
if (stData[1] == '0x0000000000000000000000000000000000000000') {
console.log(chalk.yellow(`Currently there are no security token registered at ${stAddress}`));
ticker = readlineSync.question('Enter the token symbol that you want to register: ');
} else {
ticker = stData[0];
console.log(`\n-- Current Security Token data --`);
console.log(` Ticker: ${stData[0]}`);
console.log(` Token details: ${stData[2]}`);
console.log(` Deployed at: ${stData[3]}`);
}
let tickerDetails = await currentContract.methods.getTickerDetails(ticker).call();
if (tickerDetails[1] == 0) {
console.log(chalk.yellow(`${ticker} is not registered.`));
} else {
console.log(`-- Current Ticker details --`);
console.log(` Owner: ${tickerDetails[0]}`);
console.log(` Token name: ${tickerDetails[3]}\n`);
}
let name = readlineSync.question(`Enter the token name: `);
let owner = readlineSync.question(`Enter the token owner: `, {
limit: function(input) {
return web3.utils.isAddress(input);
},
limitMessage: "Must be a valid address"
});
let tokenDetails = readlineSync.question(`Enter the token details: `);
let deployedAt = readlineSync.questionInt(`Enter the Unix Epoch timestamp at which security token was deployed: `);
let modifySTAction = currentContract.methods.modifySecurityToken(name, ticker, owner, stAddress, tokenDetails, deployedAt);
await common.sendTransaction(Issuer, modifySTAction, defaultGasPrice, 0, 1.5);
console.log(chalk.green(`Security Token has been updated successfuly`));
break;
case 'Change Expiry Limit':
let currentExpiryLimit = await currentContract.methods.getUintValues(web3.utils.soliditySha3(EXPIRY_LIMIT_KEY)).call();
console.log(chalk.yellow(`Current expiry limit is ${Math.floor(parseInt(currentExpiryLimit)/60/60/24)} days`));
let newExpiryLimit = duration.days(readlineSync.questionInt('Enter a new value in days for expiry limit: '));
let changeExpiryLimitAction = currentContract.methods.changeExpiryLimit(newExpiryLimit);
let changeExpiryLimitReceipt = await common.sendTransaction(Issuer, changeExpiryLimitAction, defaultGasPrice);
let changeExpiryLimitEvent = common.getEventFromLogs(currentContract._jsonInterface, changeExpiryLimitReceipt.logs, 'LogChangeExpiryLimit');
console.log(chalk.green(`Expiry limit was changed successfuly. New limit is ${Math.floor(parseInt(changeExpiryLimitEvent._newExpiry)/60/60/24)} days\n`));
break;
case 'Change registration fee':
let currentRegFee = web3.utils.fromWei(await currentContract.methods.getUintValues(web3.utils.soliditySha3(REG_FEE_KEY)).call());
console.log(chalk.yellow(`\nCurrent ticker registration fee is ${currentRegFee} POLY`));
let newRegFee = web3.utils.toWei(readlineSync.questionInt('Enter a new value in POLY for ticker registration fee: ').toString());
let changeRegFeeAction = currentContract.methods.changeTickerRegistrationFee(newRegFee);
let changeRegFeeReceipt = await common.sendTransaction(Issuer, changeRegFeeAction, defaultGasPrice);
let changeRegFeeEvent = common.getEventFromLogs(currentContract._jsonInterface, changeRegFeeReceipt.logs, 'LogChangeTickerRegistrationFee');
console.log(chalk.green(`Fee was changed successfuly. New fee is ${web3.utils.fromWei(changeRegFeeEvent._newFee)} POLY\n`));
break;
case 'Change ST launch fee':
let currentLaunchFee = web3.utils.fromWei(await currentContract.methods.getUintValues(web3.utils.soliditySha3(LAUNCH_FEE_KEY)).call());
console.log(chalk.yellow(`\nCurrent ST launch fee is ${currentLaunchFee} POLY`));
let newLaunchFee = web3.utils.toWei(readlineSync.questionInt('Enter a new value in POLY for ST launch fee: ').toString());
let changeLaunchFeeAction = currentContract.methods.changeSecurityLaunchFee(newLaunchFee);
let changeLaunchFeeReceipt = await common.sendTransaction(Issuer, changeLaunchFeeAction, defaultGasPrice);
let changeLaunchFeeEvent = common.getEventFromLogs(currentContract._jsonInterface, changeLaunchFeeReceipt.logs, 'LogChangeSecurityLaunchFee');
console.log(chalk.green(`Fee was changed successfuly. New fee is ${web3.utils.fromWei(changeLaunchFeeEvent._newFee)} POLY\n`));
break;
case 'CANCEL':
process.exit(0);
}
}
currentContract = null;
}

module.exports = {
executeApp: async function(remoteNetwork) {
return executeApp(remoteNetwork);
}
}
1 change: 0 additions & 1 deletion CLI/commands/dividends_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const STO_KEY = 3;
let tokenSymbol;
let securityToken;
let polyToken;
let tickerRegistry;
let securityTokenRegistry;
let generalTransferManager;
let currentDividendsModule;
Expand Down
18 changes: 17 additions & 1 deletion CLI/commands/faucet.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var chalk = require('chalk');
////////////////////////
// App flow
let polyToken;
let usdToken;

async function executeApp(beneficiary, amount, remoteNetwork) {
await global.initialize(remoteNetwork);
Expand All @@ -29,6 +30,10 @@ async function setup(){
let polytokenABI = abis.polyToken();
polyToken = new web3.eth.Contract(polytokenABI, polytokenAddress);
polyToken.setProvider(web3.currentProvider);

let usdTokenAddress = await contracts.usdToken();
usdToken = new web3.eth.Contract(polytokenABI, usdTokenAddress);
usdToken.setProvider(web3.currentProvider);
} catch (err) {
console.log(err)
console.log('\x1b[31m%s\x1b[0m',"There was a problem getting the contracts. Make sure they are deployed to the selected network.");
Expand All @@ -41,7 +46,8 @@ async function send_poly(beneficiary, amount) {
console.log(chalk.blue(`Hello user you have '${(new BigNumber(issuerBalance).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY'\n`))

if (typeof beneficiary === 'undefined' && typeof amount === 'undefined') {
let options = ['250 POLY for ticker registration','500 POLY for token launch + ticker reg', '20K POLY for CappedSTO Module', '20.5K POLY for Ticker + Token + CappedSTO', '100.5K POLY for Ticker + Token + USDTieredSTO','As many POLY as you want'];
let options = ['250 POLY for ticker registration','500 POLY for token launch + ticker reg', '20K POLY for CappedSTO Module',
'20.5K POLY for Ticker + Token + CappedSTO', '100.5K POLY for Ticker + Token + USDTieredSTO','As many POLY as you want', '10K USD Tokens'];
index = readlineSync.keyInSelect(options, 'What do you want to do?');
console.log("Selected:", index != -1 ? options[index] : 'Cancel');
switch (index) {
Expand Down Expand Up @@ -69,6 +75,16 @@ async function send_poly(beneficiary, amount) {
beneficiary = readlineSync.question(`Enter beneficiary of transfer ('${Issuer.address}'): `);
amount = readlineSync.questionInt(`Enter the no. of POLY Tokens: `).toString();
break;
case 6:
beneficiary = readlineSync.question(`Enter beneficiary 10K USD Tokens ('${Issuer.address}'): `);
if (beneficiary == "") beneficiary = Issuer.address;
let getTokensAction = usdToken.methods.getTokens(web3.utils.toWei('10000'), beneficiary);
await common.sendTransaction(Issuer, getTokensAction, defaultGasPrice);
let balance = await usdToken.methods.balanceOf(beneficiary).call();
let balanceInPoly = new BigNumber(balance).dividedBy(new BigNumber(10).pow(18));
console.log(chalk.green(`Congratulations! balance of ${beneficiary} address is ${balanceInPoly.toNumber()} USD Tokens`));
process.exit(0);
break;
case -1:
process.exit(0);
}
Expand Down
Loading

0 comments on commit 6421e09

Please sign in to comment.