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

Update tags, types, lower & upper bounds #725

Merged
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
12 changes: 6 additions & 6 deletions contracts/ModuleRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
bytes32 constant POLYMATHREGISTRY = 0x90eeab7c36075577c7cc5ff366e389fefa8a18289b949bab3529ab4471139d4d; //keccak256("polymathRegistry")
bytes32 constant FEATURE_REGISTRY = 0xed9ca06607835ad25ecacbcb97f2bc414d4a51ecf391b5ae42f15991227ab146; //keccak256("featureRegistry")
bytes32 constant SECURITY_TOKEN_REGISTRY = 0x12ada4f7ee6c2b7b933330be61fefa007a1f497dc8df1b349b48071a958d7a81; //keccak256("securityTokenRegistry")

///////////////
//// Modifiers
///////////////
Expand Down Expand Up @@ -155,8 +155,8 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
*/
function isCompatibleModule(address _moduleFactory, address _securityToken) public view returns(bool) {
uint8[] memory _latestVersion = ISecurityToken(_securityToken).getVersion();
uint8[] memory _lowerBound = IModuleFactory(_moduleFactory).lowerSTVersionBounds();
uint8[] memory _upperBound = IModuleFactory(_moduleFactory).upperSTVersionBounds();
uint8[] memory _lowerBound = IModuleFactory(_moduleFactory).getLowerSTVersionBounds();
uint8[] memory _upperBound = IModuleFactory(_moduleFactory).getUpperSTVersionBounds();
bool _isLowerAllowed = VersionUtils.lessThanOrEqual(_lowerBound, _latestVersion);
bool _isUpperAllowed = VersionUtils.greaterThanOrEqual(_upperBound, _latestVersion);
return (_isLowerAllowed && _isUpperAllowed);
Expand All @@ -183,7 +183,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
//Enforce type uniqueness
uint256 i;
uint256 j;
uint8[] memory moduleTypes = moduleFactory.types();
uint8[] memory moduleTypes = moduleFactory.getTypes();
for (i = 1; i < moduleTypes.length; i++) {
for (j = 0; j < i; j++) {
require(moduleTypes[i] != moduleTypes[j], "Type mismatch");
Expand Down Expand Up @@ -304,14 +304,14 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
uint256 i;
uint256 j;
for (i = 0; i < _modules.length; i++) {
counter = counter + IModuleFactory(_modules[i]).tags().length;
counter = counter + IModuleFactory(_modules[i]).getTags().length;
}
bytes32[] memory tags = new bytes32[](counter);
address[] memory modules = new address[](counter);
bytes32[] memory tempTags;
counter = 0;
for (i = 0; i < _modules.length; i++) {
tempTags = IModuleFactory(_modules[i]).tags();
tempTags = IModuleFactory(_modules[i]).getTags();
for (j = 0; j < tempTags.length; j++) {
tags[counter] = tempTags[j];
modules[counter] = _modules[i];
Expand Down
8 changes: 4 additions & 4 deletions contracts/interfaces/IModuleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ interface IModuleFactory {
/**
* @notice Type of the Module factory
*/
function types() external view returns(uint8[] memory moduleTypes);
function getTypes() external view returns(uint8[] memory moduleTypes);

/**
* @notice Get the tags related to the module factory
*/
function tags() external view returns(bytes32[] memory moduleTags);
function getTags() external view returns(bytes32[] memory moduleTags);

/**
* @notice Used to change the setup fee
Expand Down Expand Up @@ -83,13 +83,13 @@ interface IModuleFactory {
* @notice Used to get the lower bound
* @return Lower bound
*/
function lowerSTVersionBounds() external view returns(uint8[] memory lowerBounds);
function getLowerSTVersionBounds() external view returns(uint8[] memory lowerBounds);

/**
* @notice Used to get the upper bound
* @return Upper bound
*/
function upperSTVersionBounds() external view returns(uint8[] memory upperBounds);
function getUpperSTVersionBounds() external view returns(uint8[] memory upperBounds);

/**
* @notice Updates the tags of the ModuleFactory
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract MockFactory is DummySTOFactory {
/**
* @notice Type of the Module factory
*/
function types() external view returns(uint8[] memory) {
function getTypes() external view returns(uint8[] memory) {
if (!typesSwitch) {
uint8[] memory res = new uint8[](0);
return res;
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockWrongTypeFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract MockWrongTypeFactory is MockBurnFactory {
/**
* @notice Type of the Module factory
*/
function types() external view returns(uint8[] memory) {
function getTypes() external view returns(uint8[] memory) {
uint8[] memory res = new uint8[](1);
res[0] = 4;
return res;
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/TestSTOFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract TestSTOFactory is DummySTOFactory {
/**
* @notice Gets the tags related to the module factory
*/
function tags() external view returns(bytes32[] memory) {
function getTags() external view returns(bytes32[] memory) {
bytes32[] memory availableTags = new bytes32[](4);
availableTags[0] = "Test";
availableTags[1] = "Non-refundable";
Expand Down
8 changes: 4 additions & 4 deletions contracts/modules/ModuleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ contract ModuleFactory is IModuleFactory, Ownable {
/**
* @notice Type of the Module factory
*/
function types() external view returns(uint8[] memory) {
function getTypes() external view returns(uint8[] memory) {
return typesData;
}

/**
* @notice Get the tags related to the module factory
*/
function tags() external view returns(bytes32[] memory) {
function getTags() external view returns(bytes32[] memory) {
return tagsData;
}

Expand Down Expand Up @@ -154,15 +154,15 @@ contract ModuleFactory is IModuleFactory, Ownable {
* @notice Used to get the lower bound
* @return lower bound
*/
function lowerSTVersionBounds() external view returns(uint8[] memory) {
function getLowerSTVersionBounds() external view returns(uint8[] memory) {
return VersionUtils.unpack(compatibleSTVersionRange["lowerBound"]);
}

/**
* @notice Used to get the upper bound
* @return upper bound
*/
function upperSTVersionBounds() external view returns(uint8[] memory) {
function getUpperSTVersionBounds() external view returns(uint8[] memory) {
return VersionUtils.unpack(compatibleSTVersionRange["upperBound"]);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/tokens/SecurityToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ contract SecurityToken is ERC20, ReentrancyGuard, SecurityTokenStorage, IERC1594
//Check that the module factory exists in the ModuleRegistry - will throw otherwise
moduleRegistry.useModule(_moduleFactory, false);
IModuleFactory moduleFactory = IModuleFactory(_moduleFactory);
uint8[] memory moduleTypes = moduleFactory.types();
uint8[] memory moduleTypes = moduleFactory.getTypes();
uint256 moduleCost = moduleFactory.setupCostInPoly();
require(moduleCost <= _maxCost, "Invalid cost");
//Approve fee for module
Expand Down
4 changes: 2 additions & 2 deletions test/b_capped_sto.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,15 +917,15 @@ contract("CappedSTO", async (accounts) => {
it("should get the exact details of the factory", async () => {
assert.equal((await I_CappedSTOFactory.setupCost.call()).toString(), cappedSTOSetupCost.toString());
assert.equal((await I_CappedSTOFactory.setupCostInPoly.call()).toString(), cappedSTOSetupCostPOLY.toString());
assert.equal((await I_CappedSTOFactory.types.call())[0], 3);
assert.equal((await I_CappedSTOFactory.getTypes.call())[0], 3);
assert.equal(web3.utils.hexToString(await I_CappedSTOFactory.name.call()), "CappedSTO", "Wrong Module added");
assert.equal(
await I_CappedSTOFactory.description.call(),
"This smart contract creates a maximum number of tokens (i.e. hard cap) which the total aggregate of tokens acquired by all investors cannot exceed. Security tokens are sent to the investor upon reception of the funds (ETH or POLY), and any security tokens left upon termination of the offering will not be minted.",
"Wrong Module added"
);
assert.equal(await I_CappedSTOFactory.title.call(), "Capped STO", "Wrong Module added");
let tags = await I_CappedSTOFactory.tags.call();
let tags = await I_CappedSTOFactory.getTags.call();
assert.equal(web3.utils.hexToString(tags[0]), "Capped");
assert.equal(await I_CappedSTOFactory.version.call(), "3.0.0");
});
Expand Down
4 changes: 2 additions & 2 deletions test/d_count_transfer_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ contract("CountTransferManager", async (accounts) => {
describe("Test cases for the factory", async () => {
it("should get the exact details of the factory", async () => {
assert.equal(await I_CountTransferManagerFactory.setupCost.call(), 0);
assert.equal((await I_CountTransferManagerFactory.types.call())[0], 2);
assert.equal((await I_CountTransferManagerFactory.getTypes.call())[0], 2);
assert.equal(
web3.utils.toAscii(await I_CountTransferManagerFactory.name.call()).replace(/\u0000/g, ""),
"CountTransferManager",
Expand All @@ -600,7 +600,7 @@ contract("CountTransferManager", async (accounts) => {
});

it("Should get the tags of the factory", async () => {
let tags = await I_CountTransferManagerFactory.tags.call();
let tags = await I_CountTransferManagerFactory.getTags.call();
assert.equal(web3.utils.toAscii(tags[0]).replace(/\u0000/g, ""), "Count");
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/e_erc20_dividends.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ contract("ERC20DividendCheckpoint", async (accounts) => {
describe("Test cases for the ERC20DividendCheckpointFactory", async () => {
it("should get the exact details of the factory", async () => {
assert.equal((await I_ERC20DividendCheckpointFactory.setupCost.call()).toNumber(), 0);
assert.equal((await I_ERC20DividendCheckpointFactory.types.call())[0], 4);
assert.equal((await I_ERC20DividendCheckpointFactory.getTypes.call())[0], 4);
assert.equal(await I_ERC20DividendCheckpointFactory.version.call(), "3.0.0");
assert.equal(
web3.utils.toAscii(await I_ERC20DividendCheckpointFactory.name.call()).replace(/\u0000/g, ""),
Expand All @@ -1287,7 +1287,7 @@ contract("ERC20DividendCheckpoint", async (accounts) => {
"Wrong Module added"
);
assert.equal(await I_ERC20DividendCheckpointFactory.title.call(), "ERC20 Dividend Checkpoint", "Wrong Module added");
let tags = await I_ERC20DividendCheckpointFactory.tags.call();
let tags = await I_ERC20DividendCheckpointFactory.getTags.call();
assert.equal(tags.length, 3);
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/f_ether_dividends.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ contract("EtherDividendCheckpoint", async (accounts) => {
describe("Test cases for the EtherDividendCheckpointFactory", async () => {
it("should get the exact details of the factory", async () => {
assert.equal((await I_EtherDividendCheckpointFactory.setupCost.call()).toNumber(), 0);
assert.equal((await I_EtherDividendCheckpointFactory.types.call())[0], 4);
assert.equal((await I_EtherDividendCheckpointFactory.getTypes.call())[0], 4);
assert.equal(await I_EtherDividendCheckpointFactory.version.call(), "3.0.0");
assert.equal(
web3.utils.toAscii(await I_EtherDividendCheckpointFactory.name.call()).replace(/\u0000/g, ""),
Expand All @@ -1009,7 +1009,7 @@ contract("EtherDividendCheckpoint", async (accounts) => {
"Wrong Module added"
);
assert.equal(await I_EtherDividendCheckpointFactory.title.call(), "Ether Dividend Checkpoint", "Wrong Module added");
let tags = await I_EtherDividendCheckpointFactory.tags.call();
let tags = await I_EtherDividendCheckpointFactory.getTags.call();
assert.equal(tags.length, 3);
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/g_general_permission_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ contract("GeneralPermissionManager", async (accounts) => {
describe("General Permission Manager Factory test cases", async () => {
it("should get the exact details of the factory", async () => {
assert.equal(await I_GeneralPermissionManagerFactory.setupCost.call(), 0);
assert.equal((await I_GeneralPermissionManagerFactory.types.call())[0], 1);
assert.equal((await I_GeneralPermissionManagerFactory.getTypes.call())[0], 1);
assert.equal(await I_GeneralPermissionManagerFactory.version.call(), "3.0.0");
assert.equal(
web3.utils.toAscii(await I_GeneralPermissionManagerFactory.name.call()).replace(/\u0000/g, ""),
Expand All @@ -490,7 +490,7 @@ contract("GeneralPermissionManager", async (accounts) => {
});

it("Should get the tags of the factory", async () => {
let tags = await I_GeneralPermissionManagerFactory.tags.call();
let tags = await I_GeneralPermissionManagerFactory.getTags.call();
assert.equal(web3.utils.toUtf8(tags[0]), "Permission Management");
});

Expand Down
8 changes: 4 additions & 4 deletions test/h_general_transfer_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ contract("GeneralTransferManager", async (accounts) => {
describe("General Transfer Manager Factory test cases", async () => {
it("Should get the exact details of the factory", async () => {
assert.equal(await I_GeneralTransferManagerFactory.setupCost.call(), 0);
assert.equal((await I_GeneralTransferManagerFactory.types.call())[0], 2);
assert.equal((await I_GeneralTransferManagerFactory.getTypes.call())[0], 2);
assert.equal(
web3.utils.toAscii(await I_GeneralTransferManagerFactory.name.call()).replace(/\u0000/g, ""),
"GeneralTransferManager",
Expand All @@ -1269,15 +1269,15 @@ contract("GeneralTransferManager", async (accounts) => {
});

it("Should get the tags of the factory", async () => {
let tags = await I_GeneralTransferManagerFactory.tags.call();
let tags = await I_GeneralTransferManagerFactory.getTags.call();
assert.equal(web3.utils.toAscii(tags[0]).replace(/\u0000/g, ""), "General");
});
});

describe("Dummy STO Factory test cases", async () => {
it("should get the exact details of the factory", async () => {
assert.equal(await I_DummySTOFactory.setupCost.call(), 0);
assert.equal((await I_DummySTOFactory.types.call())[0], 3);
assert.equal((await I_DummySTOFactory.getTypes.call())[0], 3);
assert.equal(
web3.utils.toAscii(await I_DummySTOFactory.name.call()).replace(/\u0000/g, ""),
"DummySTO",
Expand All @@ -1288,7 +1288,7 @@ contract("GeneralTransferManager", async (accounts) => {
});

it("Should get the tags of the factory", async () => {
let tags = await I_DummySTOFactory.tags.call();
let tags = await I_DummySTOFactory.getTags.call();
assert.equal(web3.utils.toAscii(tags[0]).replace(/\u0000/g, ""), "Dummy");
});

Expand Down
4 changes: 2 additions & 2 deletions test/j_manual_approval_transfer_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ contract("ManualApprovalTransferManager", accounts => {
describe("ManualApproval Transfer Manager Factory test cases", async () => {
it("Should get the exact details of the factory", async () => {
assert.equal(await I_ManualApprovalTransferManagerFactory.setupCost.call(), 0);
assert.equal((await I_ManualApprovalTransferManagerFactory.types.call())[0], 2);
assert.equal((await I_ManualApprovalTransferManagerFactory.getTypes.call())[0], 2);
let name = web3.utils.toUtf8(await I_ManualApprovalTransferManagerFactory.name.call());
assert.equal(name, "ManualApprovalTransferManager", "Wrong Module added");
let desc = await I_ManualApprovalTransferManagerFactory.description.call();
Expand All @@ -822,7 +822,7 @@ contract("ManualApprovalTransferManager", accounts => {
});

it("Should get the tags of the factory", async () => {
let tags = await I_ManualApprovalTransferManagerFactory.tags.call();
let tags = await I_ManualApprovalTransferManagerFactory.getTags.call();
assert.equal(web3.utils.toUtf8(tags[0]), "Manual Approval");
assert.equal(web3.utils.toUtf8(tags[1]), "Transfer Restriction");
});
Expand Down
5 changes: 3 additions & 2 deletions test/k_module_registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ contract("ModuleRegistry", async (accounts) => {
it("Should fail to register the new module because msg.sender is not the owner of the module", async() => {
I_CappedSTOLogic = await CappedSTO.new(address_zero, address_zero, { from: account_polymath });
I_CappedSTOFactory3 = await CappedSTOFactory.new(new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, true, { from: account_temp });
console.log(await I_MRProxied.owner());
catchRevert(I_MRProxied.registerModule(I_CappedSTOFactory3.address, { from: token_owner }));
});

Expand Down Expand Up @@ -391,7 +392,7 @@ contract("ModuleRegistry", async (accounts) => {
// Taking the snapshot the revert the changes from here
let id = await takeSnapshot();
await I_TestSTOFactory.changeSTVersionBounds("lowerBound", [3, 1, 0], { from: account_polymath });
let _lstVersion = await I_TestSTOFactory.lowerSTVersionBounds.call();
let _lstVersion = await I_TestSTOFactory.getLowerSTVersionBounds.call();
assert.equal(_lstVersion[0], 3);
assert.equal(_lstVersion[1], 1);
assert.equal(_lstVersion[2], 0);
Expand All @@ -406,7 +407,7 @@ contract("ModuleRegistry", async (accounts) => {

it("Should failed in adding the TestSTOFactory module because not compatible with the current protocol version --upper", async () => {
await I_TestSTOFactory.changeSTVersionBounds("upperBound", [0, new BN(0), 1], { from: account_polymath });
let _ustVersion = await I_TestSTOFactory.upperSTVersionBounds.call();
let _ustVersion = await I_TestSTOFactory.getUpperSTVersionBounds.call();
assert.equal(_ustVersion[0], 0);
assert.equal(_ustVersion[2], 1);
await I_STRProxied.setProtocolFactory(I_STFactory.address, 2, new BN(0), 1);
Expand Down
4 changes: 2 additions & 2 deletions test/l_percentage_transfer_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ contract("PercentageTransferManager", async (accounts) => {
describe("Percentage Transfer Manager Factory test cases", async () => {
it("Should get the exact details of the factory", async () => {
assert.equal(await I_PercentageTransferManagerFactory.setupCost.call(), 0);
assert.equal((await I_PercentageTransferManagerFactory.types.call())[0], 2);
assert.equal((await I_PercentageTransferManagerFactory.getTypes.call())[0], 2);
assert.equal(
web3.utils.toAscii(await I_PercentageTransferManagerFactory.name.call()).replace(/\u0000/g, ""),
"PercentageTransferManager",
Expand All @@ -439,7 +439,7 @@ contract("PercentageTransferManager", async (accounts) => {
});

it("Should get the tags of the factory", async () => {
let tags = await I_PercentageTransferManagerFactory.tags.call();
let tags = await I_PercentageTransferManagerFactory.getTags.call();
assert.equal(web3.utils.toAscii(tags[0]).replace(/\u0000/g, ""), "Percentage");
});
});
Expand Down
Loading