Skip to content

Conversation

@adamdossa
Copy link
Contributor

@adamdossa adamdossa commented Oct 3, 2018

Support modules having multiple types.

To Do: Add proof-of-concept module for testing multiple types

Includes lots of refactoring in SecurityToken to manage contract size limitations.

@VictorVicente I checked the CLI code and couldn't see any impact.

# Conflicts:
#	contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol
#	contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol
#	contracts/tokens/SecurityToken.sol
# Conflicts:
#	contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol
#	contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol
#	contracts/tokens/SecurityToken.sol
@adamdossa adamdossa changed the title WIP: Support multiple module types Support multiple module types Oct 3, 2018
@adamdossa adamdossa requested review from maxsam4, pabloruiz55 and satyamakgec and removed request for maxsam4 October 3, 2018 22:23
@VictorVicente
Copy link
Contributor

Agreed. It doesn't affect CLI.

Copy link
Contributor

@maxsam4 maxsam4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic seems sound to me but I don't really know the exact requirements. I have listed some minor possible optimizations below. @satyamakgec and @pabloruiz55 can take over from here.


function _removeModuleWithIndex(uint8 _type, uint256 _index) internal {
uint256 length = modules[_type].length;
modules[_type][_index] = modules[_type][length - 1];
Copy link
Contributor

@maxsam4 maxsam4 Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modules[_type][_index] = modules[_type][length - 1]; can be moved to the if block below and length-- can be done after the if statement. Very minor change that can save some gas when length - 1 == index.

@satyamakgec
Copy link
Contributor

satyamakgec commented Oct 4, 2018

Logic is good @adamdossa but we can also move the investor related functions into the library. It does make sense to move them as not many other functions depend on it. It will save up to .30 KB and also doesn't introduce too much complexity in the code.

I did some changes regarding that check here https://github.com/PolymathNetwork/polymath-core/blob/some-changes-adampr/contracts/libraries/TokenLib.sol

If you think that these changes are worth to add then we can merge these changes into yours.

@maxsam4
Copy link
Contributor

maxsam4 commented Oct 4, 2018

Just some handy stats.
Gas used for deploying ST (this branch): 7411740
Gas used for deploying ST (satyam's branch): 7378646

@satyamakgec satyamakgec merged commit 6ab03f1 into development-1.5.0 Oct 4, 2018
@adamdossa adamdossa deleted the support_multiple_module_types branch October 4, 2018 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants