Skip to content

Commit 9348598

Browse files
committed
DS deployment
1 parent af7bd20 commit 9348598

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

contracts/datastore/DataStore.sol

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,6 @@ import "../interfaces/IOwnable.sol";
55
import "./DataStoreStorage.sol";
66

77
contract DataStore is DataStoreStorage {
8-
ISecurityToken public associatedToken;
9-
10-
mapping (bytes32 => uint256) internal uintData;
11-
mapping (bytes32 => bytes32) internal bytes32Data;
12-
mapping (bytes32 => address) internal addressData;
13-
mapping (bytes32 => string) internal stringData;
14-
mapping (bytes32 => bytes) internal bytesData;
15-
mapping (bytes32 => bool) internal boolData;
16-
mapping (bytes32 => uint256[]) internal uintArrayData;
17-
mapping (bytes32 => bytes32[]) internal bytes32ArrayData;
18-
mapping (bytes32 => address[]) internal addressArrayData;
19-
mapping (bytes32 => bool[]) internal boolArrayData;
20-
21-
uint8 constant DATA_KEY = 10;
228

239
modifier onlyDataModuleWithValidKey(bytes32 _key) {
2410
require(_key != bytes32(0), "Missing key");

contracts/proxy/DataStoreProxy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pragma solidity ^0.5.0;
22

33
import "./OwnedProxy.sol";
4-
import "../DataStore/DataStoreStorage.sol";
4+
import "../datastore/DataStoreStorage.sol";
55

66
/**
77
* @title DataStoreProxy Proxy

contracts/tokens/STFactory.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ pragma solidity ^0.5.0;
22

33
import "./SecurityToken.sol";
44
import "../interfaces/ISTFactory.sol";
5+
import "../datastore/DataStoreFactory.sol";
56

67
/**
78
* @title Proxy for deploying SecurityToken instances
89
*/
910
contract STFactory is ISTFactory {
1011
address public transferManagerFactory;
12+
DataStoreFactory public dataStoreFactory;
1113

12-
constructor(address _transferManagerFactory) public {
14+
constructor(address _transferManagerFactory, address _dataStoreFactory) public {
1315
transferManagerFactory = _transferManagerFactory;
16+
dataStoreFactory = DataStoreFactory(_dataStoreFactory);
1417
}
1518

1619
/**
@@ -38,6 +41,7 @@ contract STFactory is ISTFactory {
3841
_polymathRegistry
3942
);
4043
newSecurityToken.addModule(transferManagerFactory, "", 0, 0);
44+
newSecurityToken.setDataStore(dataStoreFactory.generateDataStore(address(newSecurityToken)));
4145
newSecurityToken.transferOwnership(_issuer);
4246
return address(newSecurityToken);
4347
}

contracts/tokens/SecurityToken.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
4646
uint8 constant MINT_KEY = 3;
4747
uint8 constant CHECKPOINT_KEY = 4;
4848
uint8 constant BURN_KEY = 5;
49+
uint8 constant DATA_KEY = 10;
4950

5051
uint256 public granularity;
5152

@@ -64,6 +65,8 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
6465
// Address whitelisted by issuer as controller
6566
address public controller;
6667

68+
address public dataStore;
69+
6770
// Records added modules - module list should be order agnostic!
6871
mapping(uint8 => address[]) modules;
6972

@@ -207,6 +210,11 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
207210
securityTokenVersion = SemanticVersion(2, 0, 0);
208211
}
209212

213+
function setDataStore(address _dataStore) public {
214+
require(_dataStore != address(0), "Invalid address");
215+
dataStore = _dataStore;
216+
}
217+
210218
/**
211219
* @notice Attachs a module to the SecurityToken
212220
* @dev E.G.: On deployment (through the STR) ST gets a TransferManager module attached to it

migrations/2_deploy_contracts.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const MockOracle = artifacts.require("./MockOracle.sol");
2828
const TokenLib = artifacts.require("./TokenLib.sol");
2929
const SecurityToken = artifacts.require("./tokens/SecurityToken.sol");
3030
const STRGetter = artifacts.require('./STRGetter.sol');
31-
31+
const DataStoreLogic = artifacts.require('./DataStore.sol');
32+
const DataStoreFactory = artifacts.require('./DataStoreFactory.sol');
3233

3334
const Web3 = require("web3");
3435
let BN = Web3.utils.BN;
@@ -246,6 +247,14 @@ module.exports = function(deployer, network, accounts) {
246247
// manager attach with the securityToken contract at the time of deployment)
247248
return deployer.deploy(CappedSTOLogic, nullAddress, nullAddress, { from: PolymathAccount });
248249
})
250+
.then(() => {
251+
// B) Deploy the DataStoreLogic Contract
252+
return deployer.deploy(DataStoreLogic, { from: PolymathAccount });
253+
})
254+
.then(() => {
255+
// B) Deploy the DataStoreFactory Contract
256+
return deployer.deploy(DataStoreFactory, DataStoreLogic.address, { from: PolymathAccount });
257+
})
249258
.then(() => {
250259
// B) Deploy the GeneralTransferManagerFactory Contract (Factory used to generate the GeneralTransferManager contract and this
251260
// manager attach with the securityToken contract at the time of deployment)
@@ -297,7 +306,7 @@ module.exports = function(deployer, network, accounts) {
297306
})
298307
.then(() => {
299308
// H) Deploy the STVersionProxy001 Contract which contains the logic of deployment of securityToken.
300-
return deployer.deploy(STFactory, GeneralTransferManagerFactory.address, { from: PolymathAccount });
309+
return deployer.deploy(STFactory, GeneralTransferManagerFactory.address, DataStoreFactory.address, { from: PolymathAccount });
301310
})
302311
.then(() => {
303312
// K) Deploy the FeatureRegistry contract to control feature switches

0 commit comments

Comments
 (0)