Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Support multiple Stable Coins #453

Merged
merged 6 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions CLI/commands/common/common_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Tx = require('ethereumjs-tx');
const permissionsList = require('./permissions_list');
const abis = require('../helpers/contract_abis');

async function connect(abi, address) {
function connect(abi, address) {
contractRegistry = new web3.eth.Contract(abi, address);
contractRegistry.setProvider(web3.currentProvider);
return contractRegistry
Expand All @@ -15,7 +15,7 @@ async function checkPermission(contractName, functionName, contractRegistry) {
return true
} else {
let stAddress = await contractRegistry.methods.securityToken().call();
let securityToken = await connect(abis.securityToken(), stAddress);
let securityToken = connect(abis.securityToken(), stAddress);
let stOwner = await securityToken.methods.owner().call();
if (stOwner == Issuer.address) {
return true
Expand Down Expand Up @@ -47,11 +47,11 @@ async function getGasLimit(options, action) {
}

async function checkPermissions(action) {
let contractRegistry = await connect(action._parent.options.jsonInterface, action._parent._address);
let contractRegistry = connect(action._parent.options.jsonInterface, action._parent._address);
//NOTE this is a condition to verify if the transaction comes from a module or not.
if (contractRegistry.methods.hasOwnProperty('factory')) {
let moduleAddress = await contractRegistry.methods.factory().call();
let moduleRegistry = await connect(abis.moduleFactory(), moduleAddress);
let moduleRegistry = connect(abis.moduleFactory(), moduleAddress);
let parentModule = await moduleRegistry.methods.getName().call();
let result = await checkPermission(web3.utils.hexToUtf8(parentModule), action._method.name, contractRegistry);
if (!result) {
Expand Down Expand Up @@ -146,6 +146,9 @@ module.exports = {
let filteredLogs = logs.filter(l => l.topics.includes(eventJsonInterface.signature));
return filteredLogs.map(l => web3.eth.abi.decodeLog(eventJsonInterface.inputs, l.data, l.topics.slice(1)));
},
connect: function (abi, address) {
return connect(abi, address)
},
splitIntoBatches: function (data, batchSize) {
let allBatches = [];
for (let index = 0; index < data.length; index += batchSize) {
Expand Down
2 changes: 1 addition & 1 deletion CLI/commands/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = Object.freeze({
FUND_RAISE_TYPES: {
ETH: 0,
POLY: 1,
DAI: 2
STABLE: 2
},
DEFAULT_BATCH_SIZE: 75,
ADDRESS_ZERO: '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
Expand Up @@ -21,6 +21,7 @@ let ownableABI;
let iSTOABI;
let iTransferManagerABI;
let moduleFactoryABI;
let erc20;

try {
polymathRegistryABI = JSON.parse(require('fs').readFileSync('./build/contracts/PolymathRegistry.json').toString()).abi;
Expand All @@ -46,6 +47,7 @@ try {
iSTOABI = JSON.parse(require('fs').readFileSync('./build/contracts/ISTO.json').toString()).abi
iTransferManagerABI = JSON.parse(require('fs').readFileSync('./build/contracts/ITransferManager.json').toString()).abi
moduleFactoryABI = JSON.parse(require('fs').readFileSync('./build/contracts/ModuleFactory.json').toString()).abi;
erc20ABI = JSON.parse(require('fs').readFileSync('./build/contracts/DetailedERC20.json').toString()).abi;
} catch (err) {
console.log('\x1b[31m%s\x1b[0m', "Couldn't find contracts' artifacts. Make sure you ran truffle compile first");
throw err;
Expand Down Expand Up @@ -120,5 +122,8 @@ module.exports = {
},
moduleFactory: function () {
return moduleFactoryABI;
},
erc20: function () {
return erc20ABI;
}
}
Loading