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
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Fixed tests

  • Loading branch information...
maxsam4 committed Feb 13, 2019
commit 2dc0286f4e96241eed9603534607431a8a84ba35
@@ -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.
@@ -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.
@@ -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 {
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");
_;
}

@@ -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";
}
@@ -30,7 +30,7 @@ contract USDTieredSTOStorage {
uint256 mintedDiscountPoly;
}

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

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

@@ -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;
@@ -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
@@ -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);
});
});

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.