Skip to content
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
8 changes: 1 addition & 7 deletions contracts/tokens/STVersionProxy001.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import "../interfaces/ISTProxy.sol";
contract STVersionProxy001 is ISTProxy {

address public transferManagerFactory;
address public permissionManagerFactory;

//Shoud be set to false when we have more TransferManager options
bool addTransferManager = true;
bool addPermissionManager = true;

constructor (address _transferManagerFactory, address _permissionManagerFactory) public {
constructor (address _transferManagerFactory) public {
transferManagerFactory = _transferManagerFactory;
permissionManagerFactory = _permissionManagerFactory;
}
/**
* @dev deploys the token and adds default modules like permission manager and transfer manager.
Expand All @@ -32,9 +29,6 @@ contract STVersionProxy001 is ISTProxy {
msg.sender
);

if (addPermissionManager) {
SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false);
}
if (addTransferManager) {
SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false);
}
Expand Down
8 changes: 1 addition & 7 deletions contracts/tokens/STVersionProxy002.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import "../interfaces/ISTProxy.sol";
contract STVersionProxy002 is ISTProxy {

address public transferManagerFactory;
address public permissionManagerFactory;

//Shoud be set to false when we have more TransferManager options
bool addTransferManager = true;
bool addPermissionManager = true;

constructor (address _transferManagerFactory, address _permissionManagerFactory) public {
constructor (address _transferManagerFactory) public {
transferManagerFactory = _transferManagerFactory;
permissionManagerFactory = _permissionManagerFactory;
}

function deployToken(string _name, string _symbol, uint8 _decimals, bytes32 _tokenDetails, address _issuer)
Expand All @@ -30,9 +27,6 @@ contract STVersionProxy002 is ISTProxy {
msg.sender
);

if (addPermissionManager) {
SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false);
}
if (addTransferManager) {
SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false);
}
Expand Down
4 changes: 2 additions & 2 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = function (deployer, network, accounts) {
return moduleRegistry.verifyModule(GeneralPermissionManagerFactory.address, true, {from: PolymathAccount})
}).then(() => {
// H) Deploy the STVersionProxy001 Contract which contains the logic of deployment of securityToken.
return deployer.deploy(STVersionProxy001, GeneralTransferManagerFactory.address, GeneralPermissionManagerFactory.address, {from: PolymathAccount})
return deployer.deploy(STVersionProxy001, GeneralTransferManagerFactory.address, {from: PolymathAccount})
}).then(() => {
// I) Deploy the TickerRegistry Contract (It is used to store the information about the ticker)
return deployer.deploy(TickerRegistry, {from: PolymathAccount})
Expand Down Expand Up @@ -92,5 +92,5 @@ module.exports = function (deployer, network, accounts) {
})
})
})
})
})
}
24 changes: 10 additions & 14 deletions test/Issuance.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const BigNumber = require('bignumber.js');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")) // Hardcoded development port


contract('SecurityToken', accounts => {
contract('Issuance', accounts => {


// Accounts Variable declaration
Expand Down Expand Up @@ -181,7 +181,7 @@ contract('SecurityToken', accounts => {

// Step 7: Deploy the STversionProxy contract

I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath });
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath });

assert.notEqual(
I_STVersion.address.valueOf(),
Expand Down Expand Up @@ -246,12 +246,12 @@ contract('SecurityToken', accounts => {
LogAddModule.watch(function(error, log){ resolve(log);});
});

// Verify that GeneralPermissionManager module get added successfully or not
assert.equal(log.args._type.toNumber(), permissionManagerKey);
// Verify that GeneralTransferManager module get added successfully or not
assert.equal(log.args._type.toNumber(), transferManagerKey);
assert.equal(
web3.utils.toAscii(log.args._name)
.replace(/\u0000/g, ''),
"GeneralPermissionManager"
"GeneralTransferManager"
);
LogAddModule.stopWatching();
});
Expand All @@ -266,14 +266,6 @@ contract('SecurityToken', accounts => {
"GeneralTransferManager contract was not deployed",
);

moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);

assert.notEqual(
I_GeneralPermissionManager.address.valueOf(),
"0x0000000000000000000000000000000000000000",
"GeneralDelegateManager contract was not deployed",
);
});

it("POLYMATH: Should successfully attach the STO factory with the security token", async () => {
Expand All @@ -293,7 +285,7 @@ contract('SecurityToken', accounts => {
let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [(latestTime() + duration.seconds(5000)), (latestTime() + duration.days(30)), cap, rate, fundRaiseType, I_PolyFaucet.address, account_fundsReceiver]);

const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: account_polymath, gas: 2500000 });

assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed");
assert.equal(
web3.utils.toAscii(tx.logs[2].args._name)
Expand All @@ -319,6 +311,10 @@ contract('SecurityToken', accounts => {
});

it("Should add the delegate with permission", async() => {
//First attach a permission manager to the token
await I_SecurityToken.addModule(I_GeneralPermissionManagerFactory.address, "", 0, 0, false, {from: account_polymath});
let moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
// Add permission to the deletgate (A regesteration process)
await I_GeneralPermissionManager.addPermission(account_delegate, delegateDetails, { from: account_polymath});
// Providing the permission to the delegate
Expand Down
31 changes: 7 additions & 24 deletions test/capped_sto.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ contract('CappedSTO', accounts => {
const P_decimals = 18;

// Module key
const permissionManagerKey = 1;
const transferManagerKey = 2;
const stoKey = 3;
const budget = 0;
Expand Down Expand Up @@ -187,7 +186,7 @@ contract('CappedSTO', accounts => {

// Step 7: Deploy the STversionProxy contract

I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath });
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath });

assert.notEqual(
I_STVersion.address.valueOf(),
Expand Down Expand Up @@ -249,12 +248,12 @@ contract('CappedSTO', accounts => {
LogAddModule.watch(function(error, log){ resolve(log);});
});

// Verify that GeneralPermissionManager module get added successfully or not
assert.equal(log.args._type.toNumber(), permissionManagerKey);
// Verify that GeneralTransferManager module get added successfully or not
assert.equal(log.args._type.toNumber(), transferManagerKey);
assert.equal(
web3.utils.toAscii(log.args._name)
.replace(/\u0000/g, ''),
"GeneralPermissionManager"
"GeneralTransferManager"
);
LogAddModule.stopWatching();
});
Expand All @@ -269,14 +268,6 @@ contract('CappedSTO', accounts => {
"GeneralTransferManager contract was not deployed",
);

moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);

assert.notEqual(
I_GeneralPermissionManager.address.valueOf(),
"0x0000000000000000000000000000000000000000",
"GeneralDelegateManager contract was not deployed",
);
});

it("Should fail to launch the STO due to rate is 0", async () => {
Expand Down Expand Up @@ -561,12 +552,12 @@ contract('CappedSTO', accounts => {
LogAddModule.watch(function(error, log){ resolve(log);});
});

// Verify that GeneralPermissionManager module get added successfully or not
assert.equal(log.args._type.toNumber(), permissionManagerKey);
// Verify that GeneralTransferManager module get added successfully or not
assert.equal(log.args._type.toNumber(), transferManagerKey);
assert.equal(
web3.utils.toAscii(log.args._name)
.replace(/\u0000/g, ''),
"GeneralPermissionManager"
"GeneralTransferManager"
);
LogAddModule.stopWatching();
});
Expand All @@ -581,14 +572,6 @@ contract('CappedSTO', accounts => {
"GeneralTransferManager contract was not deployed",
);

moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);

assert.notEqual(
I_GeneralPermissionManager.address.valueOf(),
"0x0000000000000000000000000000000000000000",
"GeneralDelegateManager contract was not deployed",
);
});

it("POLY: Should successfully attach the STO factory with the security token", async () => {
Expand Down
16 changes: 4 additions & 12 deletions test/exchange_transfer_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ contract('ExchangeTransferManager', accounts => {

// Step 7: Deploy the STversionProxy contract

I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address);
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address);

assert.notEqual(
I_STVersion.address.valueOf(),
Expand Down Expand Up @@ -247,12 +247,12 @@ contract('ExchangeTransferManager', accounts => {
LogAddModule.watch(function(error, log){ resolve(log);});
});

// Verify that GeneralPermissionManager module get added successfully or not
assert.equal(log.args._type.toNumber(), 1);
// Verify that GeneralTransferManager module get added successfully or not
assert.equal(log.args._type.toNumber(), 2);
assert.equal(
web3.utils.toAscii(log.args._name)
.replace(/\u0000/g, ''),
"GeneralPermissionManager"
"GeneralTransferManager"
);
LogAddModule.stopWatching();
});
Expand All @@ -267,14 +267,6 @@ contract('ExchangeTransferManager', accounts => {
"GeneralTransferManager contract was not deployed",
);

moduleData = await I_SecurityToken.modules(1, 0);
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);

assert.notEqual(
I_GeneralPermissionManager.address.valueOf(),
"0x0000000000000000000000000000000000000000",
"GeneralDelegateManager contract was not deployed",
);
});

it("Should successfully attach the STO factory with the security token", async () => {
Expand Down
16 changes: 4 additions & 12 deletions test/module_registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ contract('ModuleRegistry', accounts => {
"Failed in verifying the module"
);

I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath });
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath });

assert.notEqual(
I_STVersion.address.valueOf(),
Expand Down Expand Up @@ -384,12 +384,12 @@ contract('ModuleRegistry', accounts => {
LogAddModule.watch(function(error, log){ resolve(log);});
});

// Verify that GeneralPermissionManager module get added successfully or not
assert.equal(log.args._type.toNumber(), permissionManagerKey);
// Verify that GeneralTransferManager module get added successfully or not
assert.equal(log.args._type.toNumber(), transferManagerKey);
assert.equal(
web3.utils.toAscii(log.args._name)
.replace(/\u0000/g, ''),
"GeneralPermissionManager"
"GeneralTransferManager"
);
LogAddModule.stopWatching();
});
Expand All @@ -404,14 +404,6 @@ contract('ModuleRegistry', accounts => {
"GeneralTransferManager contract was not deployed",
);

moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);

assert.notEqual(
I_GeneralPermissionManager.address.valueOf(),
"0x0000000000000000000000000000000000000000",
"GeneralDelegateManager contract was not deployed",
);
});
});

Expand Down
23 changes: 9 additions & 14 deletions test/security_token.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ contract('SecurityToken', accounts => {

// Step 7: Deploy the STversionProxy contract

I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath });
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath });

assert.notEqual(
I_STVersion.address.valueOf(),
Expand Down Expand Up @@ -251,34 +251,26 @@ contract('SecurityToken', accounts => {
LogAddModule.watch(function(error, log){ resolve(log);});
});

// Verify that GeneralPermissionManager module get added successfully or not
assert.equal(log.args._type.toNumber(), permissionManagerKey);
// Verify that GeneralTransferManager module get added successfully or not
assert.equal(log.args._type.toNumber(), transferManagerKey);
assert.equal(
web3.utils.toAscii(log.args._name)
.replace(/\u0000/g, ''),
"GeneralPermissionManager"
"GeneralTransferManager"
);
LogAddModule.stopWatching();
});

it("Should intialize the auto attached modules", async () => {
let moduleData = await I_SecurityToken.modules(transferManagerKey, 0);
I_GeneralTransferManager = GeneralTransferManager.at(moduleData[1]);
let moduleData = await I_SecurityToken.modules(transferManagerKey, 0);
I_GeneralTransferManager = GeneralTransferManager.at(moduleData[1]);

assert.notEqual(
I_GeneralTransferManager.address.valueOf(),
"0x0000000000000000000000000000000000000000",
"GeneralTransferManager contract was not deployed",
);

moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);

assert.notEqual(
I_GeneralPermissionManager.address.valueOf(),
"0x0000000000000000000000000000000000000000",
"GeneralDelegateManager contract was not deployed",
);
});

it("Should successfully attach the STO factory with the security token", async () => {
Expand Down Expand Up @@ -419,6 +411,9 @@ contract('SecurityToken', accounts => {
it("Should fail to provide the permission to the delegate to change the transfer bools", async () => {
let errorThrown = false;
// Add permission to the deletgate (A regesteration process)
await I_SecurityToken.addModule(I_GeneralPermissionManagerFactory.address, "", 0, 0, false, {from: token_owner});
let moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
try {
await I_GeneralPermissionManager.addPermission(account_delegate, delegateDetails, { from: account_temp });
} catch (error) {
Expand Down
Loading