Skip to content

Commit

Permalink
tag 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SatyamSB committed Apr 9, 2018
2 parents 8005ad0 + 9d84401 commit 3c35a07
Show file tree
Hide file tree
Showing 24 changed files with 681 additions and 175 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file.

## [Unreleased](https://github.com/PolymathNetwork/polymath-core/compare/npm-publish-2...master)

[__0.4.0__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __09-04-18__

## Added
* Issuer can see the list of lock and unlocked modules by accessing the public mapping **modulesLocked**.

## Changed
* Now `IModuleFactory` contract takes PolyToken address to intialize the contract. So each and every module factory takes polytoken address to intialize there constructor.
* No modules will be replacable now. Terminology got changed, In this release we make the module lockable. So owner of the modules can
make the module locable with a boolean value. `True` signifies the lock it means that module can't be unlocked or no one can change that module. `False` represent the module could be changed if issuer wants.

***

[__0.3.1__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __06-04-18__

## Added
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.com/PolymathNetwork/polymath-core.svg?token=rqsL7PsbwLxrskjYAHpq&branch=master)](https://travis-ci.com/PolymathNetwork/polymath-core)
[![Build Status](https://travis-ci.org/PolymathNetwork/polymath-core.svg?branch=master)](https://travis-ci.org/PolymathNetwork/polymath-core)
<a href="https://t.me/polymathnetwork"><img src="https://img.shields.io/badge/50k+-telegram-blue.svg" target="_blank"></a>

![Polymath](Polymath.png)
Expand Down Expand Up @@ -170,8 +170,8 @@ http://solidity.readthedocs.io/en/develop/style-guide.html

# Links

[Polymath](https://polymath.network)
[Ethereum](https://www.ethereum.org/)
[Solidity](https://solidity.readthedocs.io/en/develop/)
[Truffle](http://truffleframework.com/)
[Testrpc](https://github.com/ethereumjs/testrpc)
- [Polymath Website](https://polymath.network)
- [Ethereum Project](https://www.ethereum.org/)
- [Solidity Docs](https://solidity.readthedocs.io/en/develop/)
- [Truffle Framework](http://truffleframework.com/)
- [Ganache CLI / TestRPC](https://github.com/trufflesuite/ganache-cli)
2 changes: 1 addition & 1 deletion contracts/TickerRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ contract TickerRegistry is ITickerRegistry, Ownable, Util {
}

/**
* @dev To re-intialize the token symbol details if symbol validity expires
* @dev To re-initialize the token symbol details if symbol validity expires
* @param _symbol token symbol
*/
function expiryCheck(string _symbol) internal returns(bool) {
Expand Down
4 changes: 4 additions & 0 deletions contracts/interfaces/IModuleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ contract IModuleFactory is Ownable {

ERC20 public polyToken;

function IModuleFactory(address _polyAddress) public {
polyToken = ERC20(_polyAddress);
}

//Should create an instance of the Module, or throw
function deploy(bytes _data) external returns(address);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import "../../interfaces/IModuleFactory.sol";

contract GeneralPermissionManagerFactory is IModuleFactory {

function GeneralPermissionManagerFactory(address _polyAddress) public
IModuleFactory(_polyAddress)
{

}

function deploy(bytes /* _data */) external returns(address) {
//polyToken.transferFrom(msg.sender, owner, getCost());
polyToken.transferFrom(msg.sender, owner, getCost());
return address(new GeneralPermissionManager(msg.sender));
}

Expand Down
8 changes: 7 additions & 1 deletion contracts/modules/STO/CappedSTOFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ import "../../interfaces/IModule.sol";

contract CappedSTOFactory is IModuleFactory {

function CappedSTOFactory(address _polyAddress) public
IModuleFactory(_polyAddress)
{

}

function deploy(bytes _data) external returns(address) {
//polyToken.transferFrom(msg.sender, owner, getCost());
polyToken.transferFrom(msg.sender, owner, getCost());
//Check valid bytes - can only call module init function
CappedSTO cappedSTO = new CappedSTO(msg.sender);
//Checks that _data is valid (not calling anything it shouldn't)
Expand Down
9 changes: 8 additions & 1 deletion contracts/modules/STO/DummySTOFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import "../../interfaces/IModule.sol";

contract DummySTOFactory is IModuleFactory {

function DummySTOFactory(address _polyAddress) public
IModuleFactory(_polyAddress)
{

}


function deploy(bytes _data) external returns(address) {
//polyToken.transferFrom(msg.sender, owner, getCost());
polyToken.transferFrom(msg.sender, owner, getCost());
//Check valid bytes - can only call module init function
DummySTO dummySTO = new DummySTO(msg.sender);
//Checks that _data is valid (not calling anything it shouldn't)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import "../../interfaces/IModuleFactory.sol";

contract ExchangeTransferManagerFactory is IModuleFactory {

function ExchangeTransferManagerFactory(address _polyAddress) public
IModuleFactory(_polyAddress)
{

}

function deploy(bytes _data) external returns(address) {
//polyToken.transferFrom(msg.sender, owner, getCost());
polyToken.transferFrom(msg.sender, owner, getCost());
ExchangeTransferManager exchangeTransferManager = new ExchangeTransferManager(msg.sender);
require(getSig(_data) == exchangeTransferManager.getInitFunction());
require(address(exchangeTransferManager).call(_data));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import "../../interfaces/IModuleFactory.sol";

contract GeneralTransferManagerFactory is IModuleFactory {

function GeneralTransferManagerFactory(address _polyAddress) public
IModuleFactory(_polyAddress)
{

}

function deploy(bytes /* _data */) external returns(address) {
//polyToken.transferFrom(msg.sender, owner, getCost());
polyToken.transferFrom(msg.sender, owner, getCost());
return address(new GeneralTransferManager(msg.sender));
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/tokens/STVersionProxy001.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ contract STVersionProxy001 is ISTProxy {
);

if (addPermissionManager) {
SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, true);
SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false);
}
if (addTransferManager) {
SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, true);
SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false);
}

SecurityToken(newSecurityTokenAddress).transferOwnership(_issuer);
Expand Down
4 changes: 2 additions & 2 deletions contracts/tokens/STVersionProxy002.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ contract STVersionProxy002 is ISTProxy {
);

if (addPermissionManager) {
SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, true);
SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false);
}
if (addTransferManager) {
SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, true);
SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false);
}

SecurityToken(newSecurityTokenAddress).transferOwnership(_issuer);
Expand Down
29 changes: 14 additions & 15 deletions contracts/tokens/SecurityToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 {
struct ModuleData {
bytes32 name;
address moduleAddress;
bool replaceable;
}

address public moduleRegistry;
Expand All @@ -43,6 +42,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 {

// Module list should be order agnostic!
mapping (uint8 => ModuleData[]) public modules;
mapping (uint8 => bool) public modulesLocked;

uint8 public constant MAX_MODULES = 10;

Expand Down Expand Up @@ -96,9 +96,9 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 {
bytes _data,
uint256 _maxCost,
uint256 _budget,
bool _replaceable
bool _locked
) external onlyOwner {
_addModule(_moduleFactory, _data, _maxCost, _budget, _replaceable);
_addModule(_moduleFactory, _data, _maxCost, _budget, _locked);
}

/**
Expand All @@ -108,30 +108,29 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 {
* @param _moduleFactory is the address of the module factory to be added
* @param _data is data packed into bytes used to further configure the module (See STO usage)
* @param _maxCost max amount of POLY willing to pay to module. (WIP)
* @param _replaceable whether or not the module is supposed to be replaceable
* @param _locked whether or not the module is supposed to be locked
*/
//You are allowed to add a new moduleType if:
// - there is no existing module of that type yet added
// - the last member of the module list is replacable
function _addModule(address _moduleFactory, bytes _data, uint256 _maxCost, uint256 _budget, bool _replaceable) internal {
function _addModule(address _moduleFactory, bytes _data, uint256 _maxCost, uint256 _budget, bool _locked) internal {
//Check that module exists in registry - will throw otherwise
IModuleRegistry(moduleRegistry).useModule(_moduleFactory);
IModuleFactory moduleFactory = IModuleFactory(_moduleFactory);
require(modules[moduleFactory.getType()].length < MAX_MODULES);
uint256 moduleCost = moduleFactory.getCost();
require(moduleCost <= _maxCost);
//Check that this module has not already been set as non-replaceable
if (modules[moduleFactory.getType()].length != 0) {
require(modules[moduleFactory.getType()][modules[moduleFactory.getType()].length - 1].replaceable);
}
//Check that this module has not already been set as locked
require(!modulesLocked[moduleFactory.getType()]);
//Approve fee for module
require(polyToken.approve(_moduleFactory, moduleCost));
//Creates instance of module from factory
address module = moduleFactory.deploy(_data);
//Approve ongoing budget
require(polyToken.approve(module, _budget));
//Add to SecurityToken module map
modules[moduleFactory.getType()].push(ModuleData(moduleFactory.getName(), module, _replaceable));
modules[moduleFactory.getType()].push(ModuleData(moduleFactory.getName(), module));
modulesLocked[moduleFactory.getType()] = _locked;
//Emit log event
emit LogModuleAdded(moduleFactory.getType(), moduleFactory.getName(), _moduleFactory, module, moduleCost, _budget, now);
}
Expand All @@ -144,7 +143,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 {
function removeModule(uint8 _moduleType, uint8 _moduleIndex) external onlyOwner {
require(_moduleIndex < modules[_moduleType].length);
require(modules[_moduleType][_moduleIndex].moduleAddress != address(0));
require(modules[_moduleType][_moduleIndex].replaceable);
require(!modulesLocked[_moduleType]);
//Take the last member of the list, and replace _moduleIndex with this, then shorten the list by one
emit LogModuleRemoved(_moduleType, modules[_moduleType][_moduleIndex].moduleAddress, now);
modules[_moduleType][_moduleIndex] = modules[_moduleType][modules[_moduleType].length - 1];
Expand All @@ -156,7 +155,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 {
return (
modules[_moduleType][_index].name,
modules[_moduleType][_index].moduleAddress,
modules[_moduleType][_index].replaceable
modulesLocked[_moduleType]
);
}else {
return ("", address(0), false);
Expand All @@ -173,7 +172,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 {
}

/**
* @dev allows owner to approve more POLY to one of the modules
* @dev allows owner to approve more POLY to one of the modules
*/
function changeModuleBudget(uint8 _moduleType, uint8 _moduleIndex, uint256 _budget) public onlyOwner {
require(_moduleType != 0);
Expand All @@ -183,15 +182,15 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 {
}

/**
* @dev Overladed version of the transfer function
* @dev Overloaded version of the transfer function
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(verifyTransfer(msg.sender, _to, _value));
return super.transfer(_to, _value);
}

/**
* @dev Overladed version of the transferFrom function
* @dev Overloaded version of the transferFrom function
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(verifyTransfer(_from, _to, _value));
Expand Down
2 changes: 1 addition & 1 deletion demo/ST20Generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ async function step_STO_Launch(){
}, [startTime, endTime, web3.utils.toWei(cap, 'ether'), rate,0,0,wallet]);

try{
await securityToken.methods.addModule(cappedSTOFactoryAddress, bytesSTO, 0,0, false).send({ from: Issuer, gas:2500000, gasPrice:DEFAULT_GAS_PRICE})
await securityToken.methods.addModule(cappedSTOFactoryAddress, bytesSTO, 0,0, true).send({ from: Issuer, gas:2500000, gasPrice:DEFAULT_GAS_PRICE})
.on('transactionHash', function(hash){
console.log(`
Your transaction is being processed. Please wait...
Expand Down
11 changes: 4 additions & 7 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ var BigNumber = require('bignumber.js');

const Web3 = require('web3');
var web3;



const zero = "0x0000000000000000000000000000000000000000";
const totalSupply = 100000;
const name = "TEST POLY";
Expand Down Expand Up @@ -51,8 +48,8 @@ module.exports = function (deployer, network, accounts) {
return deployer.deploy(PolyTokenFaucet).then(() => {
return deployer.deploy(ModuleRegistry, {from: PolymathAccount}).then(() => {
return ModuleRegistry.deployed().then((moduleRegistry) => {
return deployer.deploy(GeneralTransferManagerFactory, {from: PolymathAccount}).then(() => {
return deployer.deploy(GeneralPermissionManagerFactory, {from: PolymathAccount}).then(() => {
return deployer.deploy(GeneralTransferManagerFactory, PolyTokenFaucet.address, {from: PolymathAccount}).then(() => {
return deployer.deploy(GeneralPermissionManagerFactory, PolyTokenFaucet.address, {from: PolymathAccount}).then(() => {
return deployer.deploy(PolyToken).then(() => {
return moduleRegistry.registerModule(GeneralTransferManagerFactory.address, {from: PolymathAccount}).then(() => {
return moduleRegistry.registerModule(GeneralPermissionManagerFactory.address, {from: PolymathAccount}).then(() => {
Expand All @@ -64,9 +61,9 @@ module.exports = function (deployer, network, accounts) {
return TickerRegistry.deployed().then((tickerRegistry) => {
return tickerRegistry.setTokenRegistry(SecurityTokenRegistry.address, {from: PolymathAccount}).then(() => {
return moduleRegistry.setTokenRegistry(SecurityTokenRegistry.address, {from: PolymathAccount}).then(() => {
return deployer.deploy(DummySTOFactory, {from: PolymathAccount}).then(() => {
return deployer.deploy(DummySTOFactory, PolyTokenFaucet.address, {from: PolymathAccount}).then(() => {
return moduleRegistry.registerModule(DummySTOFactory.address, {from: PolymathAccount}).then(() => {
return deployer.deploy(CappedSTOFactory, {from: PolymathAccount}).then(() => {
return deployer.deploy(CappedSTOFactory, PolyTokenFaucet.address, {from: PolymathAccount}).then(() => {
return moduleRegistry.registerModule(CappedSTOFactory.address, {from: PolymathAccount}).then(() => {
console.log("\n")
console.log("----- Polymath Core Contracts -----");
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polymath-core",
"version": "0.3.1",
"version": "0.4.0",
"description": "Polymath Network Core Smart Contracts",
"main": "truffle.js",
"directories": {
Expand Down Expand Up @@ -53,6 +53,7 @@
"bignumber.js": "^6.0.0",
"readline-sync": "^1.4.9",
"truffle-contract": "^3.0.4",
"truffle-hdwallet-provider": "0.0.3",
"truffle-hdwallet-provider-privkey": "^0.1.0",
"web3": "^1.0.0-beta.33",
"zeppelin-solidity": "1.7.0"
Expand Down

0 comments on commit 3c35a07

Please sign in to comment.