Skip to content

Commit a87995f

Browse files
authored
Merge branch 'dev-3.0.0' into upgradable-modules
2 parents e7873d2 + 3613255 commit a87995f

File tree

9 files changed

+831
-160
lines changed

9 files changed

+831
-160
lines changed

CHANGELOG.md

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ All notable changes to this project will be documented in this file.
3535

3636
[__2.1.0__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __13-09-18__
3737

38-
## CappedSTO 2.0.1
38+
39+
## CappedSTO 2.1.0
3940
* `rate` is now accepted as multiplied by 10^18 to allow settting higher price than 1ETH/POLY per token.
4041
* Indivisble tokens are now supported. When trying to buy partial tokens, allowed full units of tokens will be purchased and remaining funds will be returned.
4142

4243
## USDTieredSTO 2.1.0
44+
* Added `stableCoinsRaised` function that returns amount of individual stable coin raised when address of that stable coin is passed.
45+
* Added support for multiple stable coins in USDTSTO.
4346
* Added `buyTokensView` and `getTokensMintedByTier` to USDTSTO.
4447
* Added `getSTODetails` to USDTSTO.
4548
* Added an Array of Tiers that will hold data about every tier in USDTSTO.
@@ -48,27 +51,68 @@ All notable changes to this project will be documented in this file.
4851
* Removed individual mappings for tier data removed in UDSTSTO.
4952
* Removed the old Proxy deployment method of USDTieredSTO and adopt the new inherited proxy deployment approach.
5053
* Bump the version to `2.1.0`
54+
* Added `getAccreditedData` to return accredited & non-accredited investor data.
55+
* Event `TokenPurchase` has uint256 tier instead of uint8 tier.
56+
* Event `SetAddresses` has non-indexed array of address of `_usdTokens` rather than single indexed address.
57+
* Added `getUsdTokens()` function that returns array of accepted stable coin (usd token) addresses.
58+
* Pass an array of `_usdToken` address in `configure` function instead of singleton address. This will require changes in bytes data generation when deploying a usdtsto through factory.
5159

5260
## GeneralTransferManager
5361
* `getInvestors`, `getAllInvestorsData`, `getInvestorsData` added to GTM to allow easy data queries.
54-
* `modifyDefaults(uint64 _defaultFromTime, uint64 _defaultToTime)` added which sets a default timestamp used when `fromTime` or `toTime` are 0
62+
* `changeDefaults(uint64 _defaultFromTime, uint64 _defaultToTime)` added which sets a default timestamp used when `fromTime` or `toTime` are 0.
5563
* Add `address[] public investors` to record a list of all addresses that have been added to the whitelist (`getInvestors`).
56-
* General Transfer Manager: Fix for when `allowAllWhitelistIssuances` is FALSE
57-
* General Transfer Manager: Make GTM a Proxy based implementation to reduce deployment gas costs
64+
* Fix for when `allowAllWhitelistIssuances` is FALSE
65+
* Make GTM a Proxy based implementation to reduce deployment gas costs
5866
* Changed the version of `GeneralTransferManagerFactory` from `1.0.0` to `2.1.0`.
67+
* `_investor` and `_addedBy` is now indexed in the `ModifyWhitelist` event.
68+
* Add public variable `defaults` to get the offset timing.
5969

6070
## Manual Approval TransferManager
6171
* Removed `0x0` check for the `_from` address to `ManualApprovalTransferManager`. This allows for the Issuer/Transfer Agent to approve a one-off mint of tokens that otherwise would not be possible.
6272
* Changed the version of `ManualApprovalTransferManagerFactory` from `1.0.0` to `2.1.0`.
6373
* Deployed 2.0.1 `ManualApprovalTransferManagerFactory` to address 0x6af2afad53cb334e62b90ddbdcf3a086f654c298
74+
* Add `getActiveApprovalsToUser()` function to access all the active approvals for a user whether user is in the `from` or in `to`.
75+
* Add `getApprovalDetails()` to get the details of the approval corresponds to `_from` and `_to` address.
76+
* Add feature to modify the details of the active approval using `modifyApproval()` & `modifyApprovalMulti()`.
77+
* Add `addManualApprovalMulti()` and `revokeManualApprovalMulti()` batch function for adding and revoking the manual approval respectively.
78+
* Add `_description` parameter during the `addManualApproval()` function call. It will be a `bytes32` variable which depicts the cause of manual approval.
79+
* Remove `addManualBlocking()` , `revokeManualBlocking()` functions.
80+
* Add `getTotalApprovalsLength()` to get the number of active approvals.
81+
* Add `getAllApprovals()` to get the details of all approvals.
6482

6583
## Dividends
6684
* Changed the version of `ERC20DividendCheckpointFactory` & `EtherDividendCheckpointFactory` from `1.0.0` to `2.1.0`.
67-
* Applied proxy pattern to Dividends modules
85+
* Applied proxy pattern to Dividends modules.
86+
* During the launch of dividend module issuer need to pass the reclaimed wallet that receive the left over funds from the module.
87+
i.e pass `_wallet` in `configure()` function of dividend module. It emits `SetWallet` event for the confirmation of the same.
88+
* Add `changeWallet()` function to change the reclaimed wallet address (only be called by the owner).
89+
* Add `getDividendsData()` getter to receive the details about all the dividend.
90+
* Add `getDividendData()` getter to receive the details about the particular dividend by passing a corresponding dividend index.
91+
* Add `getDividendProgress()` getter to retrieves the list of investors and their details corresponds to particular dividend.
92+
* Add `getCheckpointData()` use to retrieves list of investors, their balances, and their current withholding tax percentage corresponds to checkpointId.
93+
* `isExcluded()` a view function added to check whether an address is excluded from claming a dividend or not.
94+
* `isClaimed()` a view function added to checks whether an address has claimed a dividend or not.
95+
* DividendIndex is indexed in the events `ERC20DividendClaimed`, `ERC20DividendReclaimed`, `ERC20DividendWithholdingWithdrawn`. Similarly for the Ether dividend module `EtherDividendClaimed`, `EtherDividendReclaimed`, `EtherDividendClaimFailed`, `EtherDividendWithholdingWithdrawn`.
96+
* `EXCLUDED_ADDRESS_LIMIT` changed from 50 to 150.
97+
98+
## Experimental modules
99+
* Remove the `SingleTradeVolumeRestrictionTMFactory.sol` and its corresponding module `SingleTradeVolumeRestrictionTM.sol`.
100+
* Add the new TM called `BlacklistTransferManager.sol` and its corresponding factory `BlacklistTransferManagerFactory.sol`.
101+
* Chnage the name of module from `LockupVolumeRestrictionTM.sol` to `LockUpTransferManager.sol`, similarly factory become `LockUpTransferManagerFactory.sol`.
102+
* Add new module called `VestingEscrowWallet.sol` and its corresponding factory `VestingEscrowWalletFactory.sol`.
103+
104+
## STR & MR
105+
* `getArrayAddress(), getArrayBytes32(), getArrayUint()` are now public getters.
106+
* `getUintValues(), getBoolValues(), getStringValues(), getAddressValues(), getBytes32Values(), getBytesValues()` rename to `getUintValue(), getBoolValue(), getStringValue(), getAddressValue(), getBytes32Value(), getBytesValue()`. #488
107+
108+
## Added
109+
* Add new module called `VolumeRestrictionTM.sol` under the TransferManager modules list. It will be used to restrict the token
110+
volume traded in a given rolling period.
68111

69112
## Changed
70113
* `getAllModulesAndPermsFromTypes()` does not take securityToken address as a parameter anymore.
71114

115+
72116
# v1.5.0 - Release Candidate
73117

74118
[__1.5.0__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __15-08-18__
@@ -107,7 +151,7 @@ All notable changes to this project will be documented in this file.
107151
* 0x0 and duplicate address in exclusions are no longer allowed in dividend modules.
108152
* All permissions are denied if no permission manager is active.
109153
* Generalize the STO varaible names and added them in `ISTO.sol` to use the common standard in all STOs.
110-
* Generalize the event when any new token get registered with the polymath ecosystem. `LogNewSecurityToken` should emit _ticker, _name, _securityTokenAddress, _owner, _addedAt, _registrant respectively. #230
154+
* Generalize the event when any new token get registered with the polymath ecosystem. `LogNewSecurityToken` should emit _ticker_, _name_, _securityTokenAddress_, _owner_, _addedAt_, _registrant_ respectively. #230
111155
* Change the function name of `withdraPoly` to `withdrawERC20` and make the function generalize to extract tokens from the ST contract. parmeters are contract address and the value need to extract from the securityToken.
112156

113157
## Removed
@@ -339,7 +383,7 @@ allowed)
339383
* __buyTokensWithPoly__ has only one argument called `_investedPoly` only. Beneficiary Address should be its msg.sender.
340384
* __getRaiseEther()__ function name changed to __getRaisedEther()__.
341385
* __getRaisePoly()__ function name changed to __getRaisedPoly()__.
342-
* `LogModuleAdded` emit one more variable called ___budget__.
386+
* `LogModuleAdded` emit one more variable called __budget__.
343387
* `modules` mapping in the securityToken contract now returns __the array of ModuleData__.
344388

345389
## Removed
@@ -351,7 +395,7 @@ allowed)
351395

352396
## Added
353397
* ModuleRegistry contract will provide the list of modules by there types.
354-
* `SecurityTokenRegistry` is now working on the basis of the proxy version of the securitytoken contract. For that SecurityTokenRegistry has one more variable in the constructor called _STVersionProxy .
398+
* `SecurityTokenRegistry` is now working on the basis of the proxy version of the securitytoken contract. For that SecurityTokenRegistry has one more variable in the constructor called _STVersionProxy_ .
355399
* `setProtocolVersion` new function added in the SecurityTokenRegistry to set the protocol version followed to generate the securityToken. Only be called by the `polymath admin`.
356400
* `SecurityToken` now have the integration with polyToken. At the time of `addModule()` SecurityToken approve the cost of the module to moduleFactory as the spender.
357401
* New function `withdrawPoly(uint256 _amount)` is added to withdrawal the unused POLY from the securityToken contract. Called only by the owner of the contract.
@@ -378,7 +422,7 @@ allowed)
378422
* Deployment of the securityToken is now performed by the proxy contracts and call being generated form the SecurityTokenRegistry.
379423
* `TickerRegistrar` renamed as `TickerRegistry`.
380424
* TickerRegistry is now Ownable contract.
381-
* `setTokenRegistrar` functio of TickerRegistry renamed to `setTokenRegistry`.
425+
* `setTokenRegistrar` function of TickerRegistry renamed to `setTokenRegistry`.
382426
* SecurityToken constructor has one change in the variable. i.e `_moduleRegistry` contract address is replaced by the `_owner` address.
383427
* Their is no `_perm` parameter in the `addModule()` function of the securityToken contract. Now only 4 parameters left.
384428
* Type of Mudules changed

contracts/STRGetter.sol

Lines changed: 82 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import "./libraries/Util.sol";
55
import "./libraries/Encoder.sol";
66
import "./interfaces/IOwnable.sol";
77
import "./libraries/VersionUtils.sol";
8+
import "./interfaces/ISecurityToken.sol";
9+
import "./modules/PermissionManager/IPermissionManager.sol";
810

911
contract STRGetter is EternalStorage {
1012

@@ -17,28 +19,33 @@ contract STRGetter is EternalStorage {
1719
* @param _owner is the address which owns the list of tickers
1820
*/
1921
function getTickersByOwner(address _owner) external view returns(bytes32[] memory) {
20-
uint counter = 0;
22+
uint256 count = 0;
2123
// accessing the data structure userTotickers[_owner].length
2224
bytes32[] memory tickers = getArrayBytes32(Encoder.getKey("userToTickers", _owner));
2325
uint i;
2426
for (i = 0; i < tickers.length; i++) {
25-
string memory ticker = Util.bytes32ToString(tickers[i]);
26-
/*solium-disable-next-line security/no-block-members*/
27-
if (getUintValue(Encoder.getKey("registeredTickers_expiryDate", ticker)) >= now || getTickerStatus(ticker)) {
28-
counter ++;
27+
if (_ownerInTicker(tickers[i])) {
28+
count++;
2929
}
3030
}
31-
bytes32[] memory tempList = new bytes32[](counter);
32-
counter = 0;
31+
bytes32[] memory result = new bytes32[](count);
32+
count = 0;
3333
for (i = 0; i < tickers.length; i++) {
34-
string memory ticker = Util.bytes32ToString(tickers[i]);
35-
/*solium-disable-next-line security/no-block-members*/
36-
if (getUintValue(Encoder.getKey("registeredTickers_expiryDate", ticker)) >= now || getTickerStatus(ticker)) {
37-
tempList[counter] = tickers[i];
38-
counter ++;
34+
if (_ownerInTicker(tickers[i])) {
35+
result[count] = tickers[i];
36+
count++;
3937
}
4038
}
41-
return tempList;
39+
return result;
40+
}
41+
42+
function _ownerInTicker(bytes32 _ticker) internal view returns (bool) {
43+
string memory ticker = Util.bytes32ToString(_ticker);
44+
/*solium-disable-next-line security/no-block-members*/
45+
if (getUintValue(Encoder.getKey("registeredTickers_expiryDate", ticker)) >= now || getBoolValue(Encoder.getKey("registeredTickers_status", ticker))) {
46+
return true;
47+
}
48+
return false;
4249
}
4350

4451
/**
@@ -54,7 +61,7 @@ contract STRGetter is EternalStorage {
5461
* @notice Returns the list of all tokens
5562
* @dev Intention is that this is called off-chain so block gas limit is not relevant
5663
*/
57-
function getTokens() external view returns(address[] memory) {
64+
function getTokens() public view returns(address[] memory) {
5865
return _getTokens(true, address(0));
5966
}
6067
/**
@@ -67,38 +74,86 @@ contract STRGetter is EternalStorage {
6774
// This ensures we find tokens, even if their owner has been modified
6875
address[] memory activeUsers = getArrayAddress(Encoder.getKey("activeUsers"));
6976
bytes32[] memory tickers;
70-
address token;
7177
uint256 count = 0;
7278
uint256 i = 0;
7379
uint256 j = 0;
7480
for (i = 0; i < activeUsers.length; i++) {
7581
tickers = getArrayBytes32(Encoder.getKey("userToTickers", activeUsers[i]));
7682
for (j = 0; j < tickers.length; j++) {
77-
token = getAddressValue(Encoder.getKey("tickerToSecurityToken", Util.bytes32ToString(tickers[j])));
78-
if (token != address(0)) {
79-
if (_allTokens || IOwnable(token).owner() == _owner) {
80-
count = count + 1;
81-
}
83+
if (address(0) != _ownerInToken(tickers[j], _allTokens, _owner)) {
84+
count++;
8285
}
8386
}
8487
}
85-
uint256 index = 0;
8688
address[] memory result = new address[](count);
89+
count = 0;
90+
address token;
8791
for (i = 0; i < activeUsers.length; i++) {
8892
tickers = getArrayBytes32(Encoder.getKey("userToTickers", activeUsers[i]));
8993
for (j = 0; j < tickers.length; j++) {
90-
token = getAddressValue(Encoder.getKey("tickerToSecurityToken", Util.bytes32ToString(tickers[j])));
91-
if (token != address(0)) {
92-
if (_allTokens || IOwnable(token).owner() == _owner) {
93-
result[index] = token;
94-
index = index + 1;
95-
}
94+
token = _ownerInToken(tickers[j], _allTokens, _owner);
95+
if (address(0) != token) {
96+
result[count] = token;
97+
count++;
9698
}
9799
}
98100
}
99101
return result;
100102
}
101103

104+
function _ownerInToken(bytes32 _ticker, bool _allTokens, address _owner) internal view returns(address) {
105+
address token = getAddressValue(Encoder.getKey("tickerToSecurityToken", Util.bytes32ToString(_ticker)));
106+
if (token != address(0)) {
107+
if (_allTokens || IOwnable(token).owner() == _owner) {
108+
return token;
109+
}
110+
}
111+
return address(0);
112+
}
113+
114+
/**
115+
* @notice Returns the list of tokens to which the delegate has some access
116+
* @param _delegate is the address for the delegate
117+
* @dev Intention is that this is called off-chain so block gas limit is not relevant
118+
*/
119+
function getTokensByDelegate(address _delegate) external view returns(address[] memory) {
120+
// Loop over all active users, then all associated tickers of those users
121+
// This ensures we find tokens, even if their owner has been modified
122+
address[] memory tokens = getTokens();
123+
uint256 count = 0;
124+
uint256 i = 0;
125+
for (i = 0; i < tokens.length; i++) {
126+
if (_delegateInToken(tokens[i], _delegate)) {
127+
count++;
128+
}
129+
}
130+
address[] memory result = new address[](count);
131+
count = 0;
132+
for (i = 0; i < tokens.length; i++) {
133+
if (_delegateInToken(tokens[i], _delegate)) {
134+
result[count] = tokens[i];
135+
count++;
136+
}
137+
}
138+
return result;
139+
}
140+
141+
function _delegateInToken(address _token, address _delegate) internal view returns(bool) {
142+
uint256 j = 0;
143+
address[] memory permissionManagers;
144+
bool isArchived;
145+
permissionManagers = ISecurityToken(_token).getModulesByType(1);
146+
for (j = 0; j < permissionManagers.length; j++) {
147+
(,,, isArchived,,) = ISecurityToken(_token).getModule(permissionManagers[j]);
148+
if (!isArchived) {
149+
if (IPermissionManager(permissionManagers[j]).checkDelegate(_delegate)) {
150+
return true;
151+
}
152+
}
153+
}
154+
return false;
155+
}
156+
102157
/**
103158
* @notice Returns the owner and timestamp for a given ticker
104159
* @param _ticker is the ticker symbol

0 commit comments

Comments
 (0)