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

Migrating data to datastore #548

Merged
merged 27 commits into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ All notable changes to this project will be documented in this file.
* Fixed event `ModuleAdded` to also emit `_label`.
* Fixed function `getModule` to also return the respective module label.
* Added datastore that is used to store data like investor list that is shared among modules.
* `getInvestorCount()` now returns length of investor array that is everyone who ever held some st or has kyc data attached.
* `holderCount()` returns the number of current st holders.
* Added flags for Investors. Accredited and canbuyfromsto are now flags

## STR
* Introduce new contract `STRGetter.sol`. It only contains the getter functions of the STR.
Expand All @@ -21,7 +24,7 @@ All notable changes to this project will be documented in this file.

## GeneralTransferManager
* `modifyWhitelist()` function renamed to `modifyKYCData()`.
* Added flags for Investors.
* Added functions to modify and get flags

## Generalize
* Removed `_polyAddress` parameter from constructors of all modules and module factories.
Expand Down
18 changes: 11 additions & 7 deletions contracts/datastore/DataStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@ contract DataStore is DataStoreStorage, IDataStore {
event SecurityTokenChanged(address indexed _oldSecurityToken, address indexed _newSecurityToken);

modifier onlyAuthorized() {
bool isOwner = msg.sender == IOwnable(address(securityToken)).owner();
require(isOwner ||
securityToken.isModule(msg.sender, DATA_KEY) ||
securityToken.checkPermission(msg.sender, address(this), MANAGEDATA),
_isAuthorized();
_;
}

function _isAuthorized() internal view {

Choose a reason for hiding this comment

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

ok lov u

require(msg.sender == address(securityToken) ||
msg.sender == IOwnable(address(securityToken)).owner() ||
securityToken.checkPermission(msg.sender, address(this), MANAGEDATA) ||
securityToken.isModule(msg.sender, DATA_KEY),
"Unauthorized"
);
_;
}

modifier validKey(bytes32 _key) {
require(_key != bytes32(0), "Missing key");
require(_key != bytes32(0), "bad key");
_;
}

modifier validArrayLength(uint256 _keyLength, uint256 _dataLength) {
require(_keyLength == _dataLength, "Array length mismatch");
require(_keyLength == _dataLength, "bad length");
_;
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/datastore/DataStoreStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ contract DataStoreStorage {
mapping (bytes32 => address[]) internal addressArrayData;
mapping (bytes32 => bool[]) internal boolArrayData;

uint8 constant DATA_KEY = 6;
bytes32 public constant MANAGEDATA = "MANAGEDATA";
uint8 internal constant DATA_KEY = 6;
bytes32 internal constant MANAGEDATA = "MANAGEDATA";

Choose a reason for hiding this comment

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

then this two variables won't be accessible

}
2 changes: 1 addition & 1 deletion contracts/storage/USDTieredSTOStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract USDTieredSTOStorage {
uint256 mintedDiscountPoly;
}

mapping(address => uint256) nonAccreditedLimitUSDOverride;
mapping(address => uint256) public nonAccreditedLimitUSDOverride;

Choose a reason for hiding this comment

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

The mapping address is wrong D:

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean ?


mapping(bytes32 => mapping(bytes32 => string)) oracleKeys;

Expand Down
6 changes: 3 additions & 3 deletions contracts/tokens/SecurityToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
event DisableController();

function _isModule(address _module, uint8 _type) internal view returns(bool) {
require(modulesToData[_module].module == _module, "Wrong address");
require(!modulesToData[_module].isArchived, "Module archived");
if (modulesToData[_module].module != _module || modulesToData[_module].isArchived)
return false;
for (uint256 i = 0; i < modulesToData[_module].moduleTypes.length; i++) {
if (modulesToData[_module].moduleTypes[i] == _type) {
return true;
Expand Down Expand Up @@ -434,7 +434,7 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater

/**
* @notice generates subset of investors
* NB - can be used in batches if investor list is large
* NB - can be used in batches if investor list is large. start and end both are included in array.
* @param _start Position of investor to start iteration from
* @param _end Position of investor to stop iteration at
* @return list of investors
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 @@ -449,11 +449,11 @@ contract("CountTransferManager", async (accounts) => {

it("Should allow add a new token holder while transfer all the tokens at one go", async () => {
let amount = await I_SecurityToken2.balanceOf(account_investor2);
let investorCount = await I_SecurityToken2.getInvestorCount({ from: account_investor2 });
let investorCount = await I_SecurityToken2.holderCount({ from: account_investor2 });
console.log("current investor count is " + investorCount);
await I_SecurityToken2.transfer(account_investor4, amount, { from: account_investor2 });
assert((await I_SecurityToken2.balanceOf(account_investor4)).toString(), amount.toString(), { from: account_investor2 });
assert(await I_SecurityToken2.getInvestorCount({ from: account_investor2 }), investorCount);
assert(await I_SecurityToken2.holderCount({ from: account_investor2 }), investorCount);
});
});

Expand Down
Loading