Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit ac142f7

Browse files
committed
merge subcribe functions into new master
2 parents 6cfff3e + 7a65961 commit ac142f7

31 files changed

+1069
-554
lines changed

.travis.yml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
##language: node_js
2-
##node_js:
3-
## - '8'
4-
#install:
5-
# - npm install
6-
#env:
7-
# - CI="true"
8-
#cache:
9-
# directories:
10-
# - "node_modules"
11-
#script:
12-
#- npm run ci
13-
#notifications:
14-
# slack:
15-
# template:
16-
# - "%{repository} (%{commit}) : %{message}"
17-
# - "Build details: %{build_url}"
18-
# secure: fbW2WBx95rA3G/gubh4olbaCMcvK0YNnp3cSbLOAuvrdAt710jvPGLrLFmBphAuzKgkvl5hfpid/iUgpXGt494+VHx6oDHMMN6WX7BfQm0hI2x4hyzsFd0FXCfk1valXjNgkEC6+cbhbEPYPMVqaiPEpowbq96pjUoj+6y/gGEY/kh/kEfnMxgQLzI+ExQifx8j1EFtlIjoODS7N8qx5+N4XqHzuQy9QJ0xwFrcg4MLukZcaTkGM2B+XSMCl22qh5PId9TJVWN5rpKZpmOEVdEOOqVigp0/oYdrBCeM/qXtCIryFLWJcQBKJfWRJAAWBPt3iR6RX14DJJACDG/dI2Jc4GLUfVgLPwn1lBMwXuas9GzlPYd1WkCRjnilYzRmNmxa2yYylJvfZBQ7c6b/J2UbRZIAZxLd8+LEqqu0PkAq/HYowFUvxG5yaTlOgMDC/pKNcKHtRAFb35AYjtSJ/1T9ktRtuf2fckR4c2usXeDNxMDp0yhCTjgmS1axxCyOTBELM4qJEYQYyOKt4Sd8TB1AH+2if9XRgvpwZU6BnWhI6LME/m9ci6Yf49QBCIts51kYejyGizUylFBkGDSEjuj3tt16a6QIU/l90DOIlQxYKI58uf5d2OnP8t695fO0clSd+DLGJRXInD2d3Ir0jge69br/njql4NUvFPK6kVBs=
19-
# email: false
20-
# on_success: always
21-
#branches:
22-
# only:
23-
# - master
24-
25-
261
install:
272
- yarn install
283
env:
@@ -42,4 +17,6 @@ before_script:
4217
- sleep 1
4318

4419
script:
20+
- yarn compile
21+
- yarn migrate-testrpc
4522
- yarn ci

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[![Build Status](https://travis-ci.org/PolymathNetwork/polymath.js.svg?branch=master)](https://travis-ci.org/PolymathNetwork/polymath.js)
2-
32
<a href="https://t.me/polymathnetwork"><img src="https://img.shields.io/badge/50k+-telegram-blue.svg" target="_blank"></a>
43

54
<!--img src="https://img.shields.io/badge/bounties-1,000,000-green.svg" href="/issues-->

contracts/Compliance.sol

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,21 @@ contract Compliance is ICompliance {
4848

4949
Customers public PolyCustomers; // Instance of the Compliance contract
5050
uint256 public constant MINIMUM_VESTING_PERIOD = 60 * 60 * 24 * 100; // 100 Day minimum vesting period for POLY earned
51-
51+
5252
// Notifications
5353
event LogTemplateCreated(address indexed _creator, address _template, string _offeringType);
54-
event LogNewTemplateProposal(address indexed _securityToken, address _template, address _delegate);
55-
event LogNewContractProposal(address indexed _securityToken, address _offeringContract, address _delegate);
54+
event LogNewTemplateProposal(address indexed _securityToken, address _template, address _delegate, uint _templateProposalIndex);
55+
event LogCancelTemplateProposal(address indexed _securityToken, address _template, uint _templateProposalIndex);
56+
event LogNewContractProposal(address indexed _securityToken, address _offeringContract, address _delegate, uint _offeringProposalIndex);
57+
event LogCancelContractProposal(address indexed _securityToken, address _offeringContract, uint _offeringProposalIndex);
5658

5759
/* @param _polyCustomersAddress The address of the Polymath Customers contract */
5860
function Compliance(address _polyCustomersAddress) public {
5961
PolyCustomers = Customers(_polyCustomersAddress);
6062
}
6163

6264
/**
63-
* @dev `setRegsitrarAddress` This function set the SecurityTokenRegistrar contract address.
65+
* @dev `setRegsitrarAddress` This function set the SecurityTokenRegistrar contract address.
6466
* @param _STRegistrar It is the `this` reference of STR contract
6567
* @return bool
6668
*/
@@ -69,7 +71,7 @@ contract Compliance is ICompliance {
6971
require(STRegistrar == address(0));
7072
STRegistrar = SecurityTokenRegistrar(_STRegistrar);
7173
return true;
72-
}
74+
}
7375

7476
/**
7577
* @dev `createTemplate` is a simple function to create a new compliance template
@@ -132,7 +134,7 @@ contract Compliance is ICompliance {
132134
{
133135
// Verifying that provided _securityToken is generated by securityTokenRegistrar only
134136
var (totalSupply, owner,,) = STRegistrar.getSecurityTokenData(_securityToken);
135-
require(totalSupply > 0 && owner != address(0));
137+
require(totalSupply > 0 && owner != address(0));
136138
// Require that template has not expired, that the caller is the
137139
// owner of the template and that the template has been finalized
138140
require(templates[_template].expires > now);
@@ -144,7 +146,7 @@ contract Compliance is ICompliance {
144146

145147
//Get a reference of the template contract and add it to the templateProposals array
146148
templateProposals[_securityToken].push(_template);
147-
LogNewTemplateProposal(_securityToken, _template, msg.sender);
149+
LogNewTemplateProposal(_securityToken, _template, msg.sender,templateProposals[_securityToken].length -1);
148150
return true;
149151
}
150152

@@ -164,6 +166,8 @@ contract Compliance is ICompliance {
164166
var (chosenTemplate,,,,) = ISecurityToken(_securityToken).getTokenDetails();
165167
require(chosenTemplate != proposedTemplate);
166168
templateProposals[_securityToken][_templateProposalIndex] = address(0);
169+
LogCancelTemplateProposal(_securityToken, proposedTemplate, _templateProposalIndex);
170+
167171
return true;
168172
}
169173

@@ -206,15 +210,15 @@ contract Compliance is ICompliance {
206210
{
207211
// Verifying that provided _securityToken is generated by securityTokenRegistrar only
208212
var (totalSupply, owner,,) = STRegistrar.getSecurityTokenData(_securityToken);
209-
require(totalSupply > 0 && owner != address(0));
213+
require(totalSupply > 0 && owner != address(0));
210214

211215
var (,,,,KYC) = ISecurityToken(_securityToken).getTokenDetails();
212216
var (,,, verified, expires) = PolyCustomers.getCustomer(KYC, offerings[_stoContract].auditor);
213217
require(offerings[_stoContract].auditor == msg.sender);
214218
require(verified);
215219
require(expires > now);
216220
offeringProposals[_securityToken].push(_stoContract);
217-
LogNewContractProposal(_securityToken, _stoContract, msg.sender);
221+
LogNewContractProposal(_securityToken, _stoContract, msg.sender,offeringProposals[_securityToken].length -1);
218222
return true;
219223
}
220224

@@ -234,6 +238,8 @@ contract Compliance is ICompliance {
234238
var (,,,,chosenOffering) = ISecurityToken(_securityToken).getTokenDetails();
235239
require(chosenOffering != proposedOffering);
236240
offeringProposals[_securityToken][_offeringProposalIndex] = address(0);
241+
LogCancelContractProposal(_securityToken, proposedOffering, _offeringProposalIndex);
242+
237243
return true;
238244
}
239245

@@ -273,6 +279,15 @@ contract Compliance is ICompliance {
273279
return templateProposals[_securityTokenAddress][_templateIndex];
274280
}
275281

282+
/**
283+
* @dev Get an array containing the address of all template proposals for a given ST
284+
* @param _securityTokenAddress The security token ethereum address
285+
* @return Template proposals array
286+
*/
287+
function getAllTemplateProposals(address _securityTokenAddress) view public returns (address[]){
288+
return templateProposals[_securityTokenAddress];
289+
}
290+
276291
/**
277292
* @dev Get security token offering smart contract details by the proposal index
278293
* @param _securityTokenAddress The security token ethereum address
@@ -296,4 +311,13 @@ contract Compliance is ICompliance {
296311
);
297312
}
298313

314+
/**
315+
* @dev Get an array containing the address of all offering proposals for a given ST
316+
* @param _securityTokenAddress The security token ethereum address
317+
* @return Offering proposals array
318+
*/
319+
function getAllOfferingProposals(address _securityTokenAddress) view public returns (address[]){
320+
return offeringProposals[_securityTokenAddress];
321+
}
322+
299323
}

contracts/Customers.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pragma solidity ^0.4.18;
77
tokens based on their verifications by providers.
88
*/
99

10-
import './PolyToken.sol';
10+
import './interfaces/IERC20.sol';
1111
import './interfaces/ICustomers.sol';
1212

1313
/**
@@ -19,7 +19,7 @@ contract Customers is ICustomers {
1919

2020
string public VERSION = "1";
2121

22-
PolyToken POLY; // Instance of the POLY token
22+
IERC20 POLY; // Instance of the POLY token
2323

2424
struct Customer { // Structure use to store the details of the customers
2525
bytes32 countryJurisdiction; // Customers country jurisdiction as ex - ISO3166
@@ -57,7 +57,7 @@ contract Customers is ICustomers {
5757
* @dev Constructor
5858
*/
5959
function Customers(address _polyTokenAddress) public {
60-
POLY = PolyToken(_polyTokenAddress);
60+
POLY = IERC20(_polyTokenAddress);
6161
}
6262

6363
/**

contracts/Ownable.sol

Lines changed: 0 additions & 49 deletions
This file was deleted.

contracts/PolyToken.sol renamed to contracts/PolyTokenMock.sol

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
pragma solidity ^0.4.18;
22

3+
import './SafeMath.sol';
4+
import './interfaces/IERC20.sol';
5+
36
/*
47
POLY token faucet is only used on testnet for testing purposes
58
!!!! NOT INTENDED TO BE USED ON MAINNET !!!
69
*/
710

8-
import './SafeMath.sol';
9-
import './interfaces/IERC20.sol';
10-
11-
contract PolyToken is IERC20 {
11+
contract PolyTokenMock is IERC20 {
1212

1313
using SafeMath for uint256;
1414
uint256 public totalSupply = 1000000;
@@ -33,7 +33,7 @@ contract PolyToken is IERC20 {
3333
* @dev send `_value` token to `_to` from `msg.sender`
3434
* @param _to The address of the recipient
3535
* @param _value The amount of token to be transferred
36-
* @return Whether the transfer was successful or not
36+
* @return Whether the transfer was successful or not
3737
*/
3838
function transfer(address _to, uint256 _value) public returns (bool) {
3939
balances[msg.sender] = balances[msg.sender].sub(_value);
@@ -42,12 +42,12 @@ contract PolyToken is IERC20 {
4242
return true;
4343
}
4444

45-
/**
45+
/**
4646
* @dev send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
4747
* @param _from The address of the sender
4848
* @param _to The address of the recipient
4949
* @param _value The amount of token to be transferred
50-
* @return Whether the transfer was successful or not
50+
* @return Whether the transfer was successful or not
5151
*/
5252
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
5353
require(_to != address(0));
@@ -64,31 +64,32 @@ contract PolyToken is IERC20 {
6464
/**
6565
* @dev `balanceOf` function to get the balance of token holders
6666
* @param _owner The address from which the balance will be retrieved
67-
* @return The balance
67+
* @return The balance
6868
*/
6969
function balanceOf(address _owner) public view returns (uint256 balance) {
7070
return balances[_owner];
7171
}
7272

73-
/**
73+
/**
7474
* @dev `msg.sender` approves `_spender` to spend `_value` tokens
7575
* @param _spender The address of the account able to transfer the tokens
7676
* @param _value The amount of tokens to be approved for transfer
77-
* @return Whether the approval was successful or not
77+
* @return Whether the approval was successful or not
7878
*/
7979
function approve(address _spender, uint256 _value) public returns (bool) {
8080
allowed[msg.sender][_spender] = _value;
8181
Approval(msg.sender, _spender, _value);
8282
return true;
8383
}
8484

85-
/**
85+
/**
8686
* @param _owner The address of the account owning tokens
8787
* @param _spender The address of the account able to transfer the tokens
88-
* @return Amount of remaining tokens allowed to spent
88+
* @return Amount of remaining tokens allowed to spent
8989
*/
9090
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
9191
return allowed[_owner][_spender];
9292
}
9393

9494
}
95+

contracts/SecurityTokenRegistrar.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pragma solidity ^0.4.18;
77
*/
88

99
import './interfaces/ISTRegistrar.sol';
10-
import './PolyToken.sol';
10+
import './interfaces/IERC20.sol';
1111
import './SecurityToken.sol';
1212
import './Compliance.sol';
1313

@@ -36,7 +36,6 @@ contract SecurityTokenRegistrar is ISTRegistrar {
3636
mapping(string => address) tickers; // Mapping of ticker name to Security Token
3737

3838
event LogNewSecurityToken(string ticker, address securityTokenAddress, address owner, address host, uint256 fee, uint8 _type);
39-
event LogSecurityToken(address securityToken);
4039
/**
4140
* @dev Constructor use to set the essentials addresses to facilitate
4241
* the creation of the security token
@@ -89,7 +88,7 @@ contract SecurityTokenRegistrar is ISTRegistrar {
8988
require(_lockupPeriod >= now);
9089
require(_owner != address(0) && _host != address(0));
9190
require(bytes(_name).length > 0 && bytes(_ticker).length > 0);
92-
PolyToken POLY = PolyToken(polyTokenAddress);
91+
IERC20 POLY = IERC20(polyTokenAddress);
9392
POLY.transferFrom(msg.sender, _host, _fee);
9493
address newSecurityTokenAddress = initialiseSecurityToken(_name, _ticker, _totalSupply, _decimals, _owner, _maxPoly, _type, _lockupPeriod, _quorum);
9594
LogNewSecurityToken(_ticker, newSecurityTokenAddress, _owner, _host, _fee, _type);

contracts/interfaces/ISTO.sol

Lines changed: 0 additions & 17 deletions
This file was deleted.

migrations/2_deploy_contracts.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
const PolyToken = artifacts.require('./PolyToken.sol');
21
const Compliance = artifacts.require('./Compliance.sol');
32
const Customers = artifacts.require('./Customers.sol');
4-
const SecurityTokenRegistrar = artifacts.require(
5-
'./SecurityTokenRegistrar.sol'
6-
);
3+
const SecurityTokenRegistrar = artifacts.require('./SecurityTokenRegistrar.sol');
4+
5+
const PolyToken = artifacts.require('./PolyTokenMock.sol');;
76

87
module.exports = (deployer, network) => {
98
console.log(`Deploying Polymath Network Smart contracts to ${network}...`);

0 commit comments

Comments
 (0)