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

Tokenlib function visibility updated #678

Merged
merged 1 commit into from
May 31, 2019
Merged
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
39 changes: 20 additions & 19 deletions contracts/libraries/TokenLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ library TokenLib {
return keccak256(abi.encode(ACK_TYPEHASH, keccak256(bytes(_ack.text))));
}

function recoverFreezeIssuanceAckSigner(bytes memory _signature) public view returns (address) {
function recoverFreezeIssuanceAckSigner(bytes calldata _signature) external view returns (address) {
Acknowledgment memory ack = Acknowledgment("I acknowledge that freezing Issuance is a permanent and irrevocable change");
return extractSigner(ack, _signature);
}

function recoverDisableControllerAckSigner(bytes memory _signature) public view returns (address) {
function recoverDisableControllerAckSigner(bytes calldata _signature) external view returns (address) {
Acknowledgment memory ack = Acknowledgment("I acknowledge that disabling controller is a permanent and irrevocable change");
return extractSigner(ack, _signature);
}
Expand Down Expand Up @@ -126,7 +126,7 @@ library TokenLib {
* @notice Archives a module attached to the SecurityToken
* @param _moduleData Storage data
*/
function archiveModule(SecurityTokenStorage.ModuleData storage _moduleData) public {
function archiveModule(SecurityTokenStorage.ModuleData storage _moduleData) external {
require(!_moduleData.isArchived, "Module archived");
require(_moduleData.module != address(0), "Module missing");
/*solium-disable-next-line security/no-block-members*/
Expand All @@ -138,7 +138,7 @@ library TokenLib {
* @notice Unarchives a module attached to the SecurityToken
* @param _moduleData Storage data
*/
function unarchiveModule(address _moduleRegistry, SecurityTokenStorage.ModuleData storage _moduleData) public {
function unarchiveModule(address _moduleRegistry, SecurityTokenStorage.ModuleData storage _moduleData) external {
require(_moduleData.isArchived, "Module unarchived");
/*solium-disable-next-line security/no-block-members*/
// Check the version is still valid - can only be false if token was upgraded between unarchive / archive
Expand All @@ -151,7 +151,7 @@ library TokenLib {
* @notice Upgrades a module attached to the SecurityToken
* @param _moduleData Storage data
*/
function upgradeModule(address _moduleRegistry, SecurityTokenStorage.ModuleData storage _moduleData) public {
function upgradeModule(address _moduleRegistry, SecurityTokenStorage.ModuleData storage _moduleData) external {
require(_moduleData.module != address(0), "Module missing");
//Check module is verified and within version bounds
IModuleRegistry(_moduleRegistry).useModule(_moduleData.moduleFactory, true);
Expand All @@ -170,7 +170,7 @@ library TokenLib {
mapping(address => SecurityTokenStorage.ModuleData) storage _modulesToData,
mapping(bytes32 => address[]) storage _names
)
public
external
{
require(_modulesToData[_module].isArchived, "Not archived");
require(_modulesToData[_module].module != address(0), "Module missing");
Expand Down Expand Up @@ -234,7 +234,7 @@ library TokenLib {
address _polyToken,
mapping(address => SecurityTokenStorage.ModuleData) storage _modulesToData
)
public
external
{
require(_modulesToData[_module].module != address(0), "Module missing");
uint256 currentAllowance = IPoly(_polyToken).allowance(address(this), _module);
Expand All @@ -256,7 +256,7 @@ library TokenLib {
* @param _currentValue is the Current value of checkpoint
* @return uint256
*/
function getValueAt(SecurityTokenStorage.Checkpoint[] storage _checkpoints, uint256 _checkpointId, uint256 _currentValue) public view returns(uint256) {
function getValueAt(SecurityTokenStorage.Checkpoint[] storage _checkpoints, uint256 _checkpointId, uint256 _currentValue) external view returns(uint256) {
//Checkpoint id 0 is when the token is first created - everyone has a zero balance
if (_checkpointId == 0) {
return 0;
Expand Down Expand Up @@ -295,7 +295,7 @@ library TokenLib {
* @param _checkpoints is the affected checkpoint object array
* @param _newValue is the new value that needs to be stored
*/
function adjustCheckpoints(SecurityTokenStorage.Checkpoint[] storage _checkpoints, uint256 _newValue, uint256 _currentCheckpointId) public {
function adjustCheckpoints(SecurityTokenStorage.Checkpoint[] storage _checkpoints, uint256 _newValue, uint256 _currentCheckpointId) external {
//No checkpoints set yet
if (_currentCheckpointId == 0) {
return;
Expand Down Expand Up @@ -327,15 +327,16 @@ library TokenLib {
uint256 _balanceFrom,
address _dataStore
)
public
external
returns(uint256)
{
uint256 holderCount = _holderCount;
if ((_value == 0) || (_from == _to)) {
return _holderCount;
return holderCount;
}
// Check whether receiver is a new token holder
if ((_balanceTo == 0) && (_to != address(0))) {
_holderCount = _holderCount.add(1);
holderCount = holderCount.add(1);
IDataStore dataStore = IDataStore(_dataStore);
if (!_isExistingInvestor(_to, dataStore)) {
dataStore.insertAddress(INVESTORSKEY, _to);
Expand All @@ -345,10 +346,10 @@ library TokenLib {
}
// Check whether sender is moving all of their tokens
if (_value == _balanceFrom) {
_holderCount = _holderCount.sub(1);
holderCount = holderCount.sub(1);
}

return _holderCount;
return holderCount;
}

/**
Expand All @@ -362,10 +363,10 @@ library TokenLib {
bytes32[] storage docNames,
mapping(bytes32 => uint256) storage docIndexes,
bytes32 name,
string memory uri,
string calldata uri,
bytes32 documentHash
)
public
external
{
require(name != bytes32(0), "Bad name");
require(bytes(uri).length > 0, "Bad uri");
Expand All @@ -388,7 +389,7 @@ library TokenLib {
mapping(bytes32 => uint256) storage docIndexes,
bytes32 name
)
public
external
{
require(document[name].lastModified != uint256(0), "Not existed");
uint256 index = docIndexes[name] - 1;
Expand Down Expand Up @@ -422,7 +423,7 @@ library TokenLib {
bytes memory data,
bool transfersFrozen
)
public
public //Marked public to avoid stack too deep error
view
returns(bool, bytes32)
{
Expand Down Expand Up @@ -462,7 +463,7 @@ library TokenLib {
uint256 value,
uint256 balanceOfFrom
)
public
external
pure
returns (bool, byte, bytes32)
{
Expand Down