Skip to content

Commit bba2546

Browse files
authored
Merge pull request #626 from PolymathNetwork/CLI-gtm-multiversion
[CLI] Keep transfer_manager compatible with GTM v1.0.0
2 parents c4b537d + 5b4f429 commit bba2546

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

CLI/commands/transfer_manager.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,34 +304,49 @@ async function addTransferManagerModule() {
304304
async function generalTransferManager() {
305305
console.log('\n', chalk.blue(`General Transfer Manager at ${currentTransferManager.options.address}`), '\n');
306306

307+
let moduleFactoryABI = abis.moduleFactory();
308+
let factoryAddress = await currentTransferManager.methods.factory().call();
309+
let moduleFactory = new web3.eth.Contract(moduleFactoryABI, factoryAddress);
310+
let moduleVersion = await moduleFactory.methods.version().call();
311+
307312
// Show current data
308313
let displayIssuanceAddress = await currentTransferManager.methods.issuanceAddress().call();
309314
let displaySigningAddress = await currentTransferManager.methods.signingAddress().call();
310315
let displayAllowAllTransfers = await currentTransferManager.methods.allowAllTransfers().call();
311316
let displayAllowAllWhitelistTransfers = await currentTransferManager.methods.allowAllWhitelistTransfers().call();
312317
let displayAllowAllWhitelistIssuances = await currentTransferManager.methods.allowAllWhitelistIssuances().call();
313318
let displayAllowAllBurnTransfers = await currentTransferManager.methods.allowAllBurnTransfers().call();
314-
let displayDefaults = await currentTransferManager.methods.defaults().call();
315-
let displayInvestors = await currentTransferManager.methods.getInvestors().call();
316-
319+
let displayDefaults;
320+
let displayInvestors;
321+
if (moduleVersion != '1.0.0') {
322+
displayDefaults = await currentTransferManager.methods.defaults().call();
323+
displayInvestors = await currentTransferManager.methods.getInvestors().call();
324+
}
317325
console.log(`- Issuance address: ${displayIssuanceAddress}`);
318326
console.log(`- Signing address: ${displaySigningAddress}`);
319327
console.log(`- Allow all transfers: ${displayAllowAllTransfers ? `YES` : `NO`}`);
320328
console.log(`- Allow all whitelist transfers: ${displayAllowAllWhitelistTransfers ? `YES` : `NO`}`);
321329
console.log(`- Allow all whitelist issuances: ${displayAllowAllWhitelistIssuances ? `YES` : `NO`}`);
322330
console.log(`- Allow all burn transfers: ${displayAllowAllBurnTransfers ? `YES` : `NO`}`);
323-
console.log(`- Default times:`);
324-
console.log(` - From time: ${displayDefaults.fromTime} (${moment.unix(displayDefaults.fromTime).format('MMMM Do YYYY, HH:mm:ss')})`);
325-
console.log(` - To time: ${displayDefaults.toTime} (${moment.unix(displayDefaults.toTime).format('MMMM Do YYYY, HH:mm:ss')})`);
326-
console.log(`- Investors: ${displayInvestors.length}`);
331+
if (displayDefaults) {
332+
console.log(`- Default times:`);
333+
console.log(` - From time: ${displayDefaults.fromTime} (${moment.unix(displayDefaults.fromTime).format('MMMM Do YYYY, HH:mm:ss')})`);
334+
console.log(` - To time: ${displayDefaults.toTime} (${moment.unix(displayDefaults.toTime).format('MMMM Do YYYY, HH:mm:ss')})`);
335+
}
336+
if (displayInvestors) {
337+
console.log(`- Investors: ${displayInvestors.length}`);
338+
}
327339
// ------------------
328340

329341
let options = [];
330-
if (displayInvestors.length > 0) {
342+
if (displayInvestors && displayInvestors.length > 0) {
331343
options.push(`Show investors`, `Show whitelist data`);
332344
}
333-
options.push('Modify whitelist', 'Modify whitelist from CSV', /*'Modify Whitelist Signed',*/
334-
'Change the default times used when they are zero', `Change issuance address`, 'Change signing address');
345+
options.push('Modify whitelist', 'Modify whitelist from CSV') /*'Modify Whitelist Signed',*/
346+
if (displayDefaults) {
347+
options.push('Change the default times used when they are zero');
348+
}
349+
options.push(`Change issuance address`, 'Change signing address');
335350

336351
if (displayAllowAllTransfers) {
337352
options.push('Disallow all transfers');
@@ -401,8 +416,12 @@ async function generalTransferManager() {
401416
let canBuyFromSTO = readlineSync.keyInYNStrict('Can the investor buy from security token offerings?');
402417
let modifyWhitelistAction = currentTransferManager.methods.modifyWhitelist(investor, fromTime, toTime, expiryTime, canBuyFromSTO);
403418
let modifyWhitelistReceipt = await common.sendTransaction(modifyWhitelistAction);
404-
let modifyWhitelistEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyWhitelistReceipt.logs, 'ModifyWhitelist');
405-
console.log(chalk.green(`${modifyWhitelistEvent._investor} has been whitelisted sucessfully!`));
419+
if (moduleVersion != '1.0.0') {
420+
let modifyWhitelistEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyWhitelistReceipt.logs, 'ModifyWhitelist');
421+
console.log(chalk.green(`${modifyWhitelistEvent._investor} has been whitelisted sucessfully!`));
422+
} else {
423+
console.log(chalk.green(`${investor} has been whitelisted sucessfully!`));
424+
}
406425
break;
407426
case 'Modify whitelist from CSV':
408427
await modifyWhitelistInBatch();

0 commit comments

Comments
 (0)