Skip to content

Commit 7d8728c

Browse files
kostindadamdossa
authored andcommitted
Fetch poly token from pm registry (#460)
* removed _polyAddress from Module constructor * removed _polyAddress from ModuleFactory constructor * fixed tests * reverted changes for MockOracle in tests * updated deploy(), constructor docs * removed polyToken from function params in createInstance.js * added updateFromRegistry to SecurityTokenRegistry * removed polyToken parameter for initialize() * fixed tests * updated setInPolymathRegistry * removed updatePolyTokenAddress * get rid of getPolyToken function * removed updateFromRegistry() * updated CHANGELOG.md * Update CHANGELOG.md * addition of an external function * Fixed typo * Remove duplicate code and optimise a bit
1 parent fdb8548 commit 7d8728c

File tree

67 files changed

+308
-364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+308
-364
lines changed

CHANGELOG.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ All notable changes to this project will be documented in this file.
55

66
[__3.0.0__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __10-11-18__
77

8-
## SecurityToken
9-
* Added new function `addModuleWithLabel()` which takes an extra param `_label` that used for giving the customize label to the module for display purpose. #428
10-
* Fixed `addModule` function to be backwards compatible and call the new `addModuleWithLabel` function with an empty label.
8+
## Added
9+
* Added new function `addModuleWithLabel()` which takes an extra param `_label` that used for giving the customize label to the module for display purpose. #428
10+
11+
## Fixed
12+
* Fixed `addModule` function to be backwards compatible and call the new `addModuleWithLabel` function with an empty label.
1113
* Fixed event `ModuleAdded` to also emit `_label`.
12-
* Fixed function `getModule` to also return the respective module label.
14+
* Fixed function `getModule` to also return the respective module label.
15+
* Replaced `updatePolyTokenAddress()` function with `updateFromRegistry()` in `SecurityTokenRegistry`.
16+
17+
## Removed
18+
* Removed `_polyAddress` parameter from constructors of all modules and module factories.
19+
* Removed `_polyToken` parameter from `initialize` function in `SecurityTokenRegistry`.
20+
1321

1422
# v1.5.0 - Release Candidate
1523

contracts/SecurityTokenRegistry.sol

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
55
import "./interfaces/IOwnable.sol";
66
import "./interfaces/ISTFactory.sol";
77
import "./interfaces/ISecurityTokenRegistry.sol";
8+
import "./interfaces/IPolymathRegistry.sol";
89
import "./storage/EternalStorage.sol";
910
import "./libraries/Util.sol";
1011
import "./libraries/Encoder.sol";
@@ -161,27 +162,24 @@ contract SecurityTokenRegistry is ISecurityTokenRegistry, EternalStorage {
161162
* @param _STFactory is the address of the Proxy contract for Security Tokens
162163
* @param _stLaunchFee is the fee in POLY required to launch a token
163164
* @param _tickerRegFee is the fee in POLY required to register a ticker
164-
* @param _polyToken is the address of the POLY ERC20 token
165165
* @param _owner is the owner of the STR
166166
*/
167167
function initialize(
168168
address _polymathRegistry,
169169
address _STFactory,
170170
uint256 _stLaunchFee,
171171
uint256 _tickerRegFee,
172-
address _polyToken,
173172
address _owner
174173
)
175174
external
176175
payable
177176
{
178177
require(!getBool(INITIALIZE),"already initialized");
179178
require(
180-
_STFactory != address(0) && _polyToken != address(0) && _owner != address(0) && _polymathRegistry != address(0),
179+
_STFactory != address(0) && _owner != address(0) && _polymathRegistry != address(0),
181180
"Invalid address"
182181
);
183182
require(_stLaunchFee != 0 && _tickerRegFee != 0, "Fees should not be 0");
184-
set(POLYTOKEN, _polyToken);
185183
set(STLAUNCHFEE, _stLaunchFee);
186184
set(TICKERREGFEE, _tickerRegFee);
187185
set(EXPIRYLIMIT, uint256(60 * 1 days));
@@ -190,6 +188,19 @@ contract SecurityTokenRegistry is ISecurityTokenRegistry, EternalStorage {
190188
set(POLYMATHREGISTRY, _polymathRegistry);
191189
_setProtocolVersion(_STFactory, uint8(2), uint8(0), uint8(0));
192190
set(INITIALIZE, true);
191+
_updateFromRegistry();
192+
}
193+
194+
/**
195+
* @notice Used to update the polyToken contract address
196+
*/
197+
function updateFromRegistry() external onlyOwner {
198+
_updateFromRegistry();
199+
}
200+
201+
function _updateFromRegistry() internal {
202+
address polymathRegistry = getAddress(POLYMATHREGISTRY);
203+
set(POLYTOKEN, IPolymathRegistry(polymathRegistry).getAddress("PolyToken"));
193204
}
194205

195206
/////////////////////////////
@@ -740,15 +751,6 @@ contract SecurityTokenRegistry is ISecurityTokenRegistry, EternalStorage {
740751
return VersionUtils.unpack(uint24(getUint(Encoder.getKey("latestVersion"))));
741752
}
742753

743-
/**
744-
* @notice Changes the PolyToken address. Only Polymath.
745-
* @param _newAddress is the address of the polytoken.
746-
*/
747-
function updatePolyTokenAddress(address _newAddress) external onlyOwner {
748-
require(_newAddress != address(0), "Invalid address");
749-
set(POLYTOKEN, _newAddress);
750-
}
751-
752754
/**
753755
* @notice Gets the security token launch fee
754756
* @return Fee amount

contracts/interfaces/ISecurityTokenRegistry.sol

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ interface ISecurityTokenRegistry {
169169
*/
170170
function changeSecurityLaunchFee(uint256 _stLaunchFee) external;
171171

172-
/**
173-
* @notice Change the PolyToken address
174-
* @param _newAddress Address of the polytoken
175-
*/
176-
function updatePolyTokenAddress(address _newAddress) external;
177-
178172
/**
179173
* @notice Gets the security token launch fee
180174
* @return Fee amount

contracts/interfaces/IUSDTieredSTOProxy.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ interface IUSDTieredSTOProxy {
88
/**
99
* @notice Deploys the STO.
1010
* @param _securityToken Contract address of the securityToken
11-
* @param _polyAddress Contract address of the PolyToken
12-
* @param _factoryAddress Contract address of the factory
11+
* @param _factoryAddress Contract address of the factory
1312
* @return address Address of the deployed STO
1413
*/
15-
function deploySTO(address _securityToken, address _polyAddress, address _factoryAddress) external returns (address);
14+
function deploySTO(address _securityToken, address _factoryAddress) external returns (address);
1615

1716
/**
1817
* @notice Used to get the init function signature

contracts/mocks/MockBurnFactory.sol

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import "../modules/Experimental/Burn/TrackedRedemptionFactory.sol";
99

1010
contract MockBurnFactory is TrackedRedemptionFactory {
1111

12-
/**
13-
* @notice Constructor
14-
* @param _polyAddress Address of the polytoken
15-
*/
16-
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
17-
TrackedRedemptionFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
12+
/**
13+
* @notice Constructor
14+
* @param _setupCost Setup cost of the module
15+
* @param _usageCost Usage cost of the module
16+
* @param _subscriptionCost Subscription cost of the module
17+
*/
18+
constructor (uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
19+
TrackedRedemptionFactory(_setupCost, _usageCost, _subscriptionCost)
1820
{
1921
}
2022

@@ -23,10 +25,9 @@ contract MockBurnFactory is TrackedRedemptionFactory {
2325
* @return Address Contract address of the Module
2426
*/
2527
function deploy(bytes /*_data*/) external returns(address) {
26-
if(setupCost > 0)
27-
require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Unable to pay setup cost");
28+
_takeFee();
2829
//Check valid bytes - can only call module init function
29-
MockRedemptionManager mockRedemptionManager = new MockRedemptionManager(msg.sender, address(polyToken));
30+
MockRedemptionManager mockRedemptionManager = new MockRedemptionManager(msg.sender);
3031
/*solium-disable-next-line security/no-block-members*/
3132
emit GenerateModuleFromFactory(address(mockRedemptionManager), getName(), address(this), msg.sender, setupCost, now);
3233
return address(mockRedemptionManager);

contracts/mocks/MockFactory.sol

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import "../modules/STO/DummySTOFactory.sol";
99
contract MockFactory is DummySTOFactory {
1010

1111
bool public switchTypes = false;
12-
/**
12+
13+
/**
1314
* @notice Constructor
14-
* @param _polyAddress Address of the polytoken
15+
* @param _setupCost Setup cost of the module
16+
* @param _usageCost Usage cost of the module
17+
* @param _subscriptionCost Subscription cost of the module
1518
*/
16-
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
17-
DummySTOFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
19+
constructor (uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
20+
DummySTOFactory(_setupCost, _usageCost, _subscriptionCost)
1821
{
1922

2023
}

contracts/mocks/MockRedemptionManager.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ contract MockRedemptionManager is TrackedRedemption {
1414
/**
1515
* @notice Constructor
1616
* @param _securityToken Address of the security token
17-
* @param _polyAddress Address of the polytoken
1817
*/
19-
constructor (address _securityToken, address _polyAddress) public
20-
TrackedRedemption(_securityToken, _polyAddress)
18+
constructor (address _securityToken) public
19+
TrackedRedemption(_securityToken)
2120
{
2221
}
2322

contracts/mocks/MockWrongTypeFactory.sol

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import "../libraries/Util.sol";
1010

1111
contract MockWrongTypeFactory is MockBurnFactory {
1212

13-
/**
14-
* @notice Constructor
15-
* @param _polyAddress Address of the polytoken
16-
*/
17-
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
18-
MockBurnFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
13+
/**
14+
* @notice Constructor
15+
* @param _setupCost Setup cost of the module
16+
* @param _usageCost Usage cost of the module
17+
* @param _subscriptionCost Subscription cost of the module
18+
*/
19+
constructor (uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
20+
MockBurnFactory(_setupCost, _usageCost, _subscriptionCost)
1921
{
2022
}
2123

contracts/mocks/TestSTOFactory.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ contract TestSTOFactory is DummySTOFactory {
66

77
/**
88
* @notice Constructor
9-
* @param _polyAddress Address of the polytoken
9+
* @param _setupCost Setup cost of the module
10+
* @param _usageCost Usage cost of the module
11+
* @param _subscriptionCost Subscription cost of the module
1012
*/
11-
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
12-
DummySTOFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
13+
constructor (uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
14+
DummySTOFactory(_setupCost, _usageCost, _subscriptionCost)
1315
{
1416
version = "1.0.0";
1517
name = "TestSTO";

contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ contract ERC20DividendCheckpoint is DividendCheckpoint {
4747
/**
4848
* @notice Constructor
4949
* @param _securityToken Address of the security token
50-
* @param _polyAddress Address of the polytoken
5150
*/
52-
constructor (address _securityToken, address _polyAddress) public
53-
Module(_securityToken, _polyAddress)
51+
constructor (address _securityToken) public
52+
Module(_securityToken)
5453
{
5554
}
5655

0 commit comments

Comments
 (0)