From 987d78e12126fa1a9087005616ea4d84be08b6b2 Mon Sep 17 00:00:00 2001 From: Adam0000 Date: Mon, 12 Feb 2018 16:42:39 -0500 Subject: [PATCH 1/3] Move web3 wrapper from devDependencies to dependencies. Add Compliance and SecurityTokenRegistrar to the Polymath class. Remove SecurityTokenRegistrar's dependency on a SecurityToken. --- package.json | 2 +- src/contract_wrappers/Compliance.js | 6 ------ src/contract_wrappers/Customers.js | 2 +- src/contract_wrappers/SecurityTokenRegistrar.js | 7 ------- src/index.js | 10 +++++++++- test/Compliance_test.js | 1 - test/SecurityToken_test.js | 1 - test/util/make_examples.js | 6 ++---- 8 files changed, 13 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index d4b4659..bd28b7e 100644 --- a/package.json +++ b/package.json @@ -59,12 +59,12 @@ "mnemonic": "age drama cover door helmet mechanic wine lesson vote inflict will keep" }, "dependencies": { + "@0xproject/web3-wrapper": "0.1.2", "truffle-contract": "3.0.1", "uuid": "3.1.0", "web3": "0.20.1" }, "devDependencies": { - "@0xproject/web3-wrapper": "0.1.2", "babel-cli": "6.26.0", "babel-core": "6.26.0", "babel-eslint": "8.1.2", diff --git a/src/contract_wrappers/Compliance.js b/src/contract_wrappers/Compliance.js index 8c9b05e..f043ffc 100644 --- a/src/contract_wrappers/Compliance.js +++ b/src/contract_wrappers/Compliance.js @@ -5,8 +5,6 @@ import Web3 from 'web3'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import ContractWrapper from './ContractWrapper'; -import Customers from './Customers'; -import SecurityTokenRegistrar from './SecurityTokenRegistrar'; import complianceArtifact from '../artifacts/Compliance.json'; import type { @@ -28,13 +26,9 @@ export default class Compliance extends ContractWrapper { */ constructor( web3Wrapper: Web3Wrapper, - customers: Customers, deployedAddress?: string, ) { super(web3Wrapper, complianceArtifact, deployedAddress); - - this.customers = customers; - this.securityTokenRegistrar = SecurityTokenRegistrar; } /** diff --git a/src/contract_wrappers/Customers.js b/src/contract_wrappers/Customers.js index b39a83c..eb76dc9 100644 --- a/src/contract_wrappers/Customers.js +++ b/src/contract_wrappers/Customers.js @@ -30,7 +30,7 @@ type LogCustomerVerifiedArgsUnprocessed = { * Wrapper for the Customers Solidity contract */ export default class Customers extends ContractWrapper { - // polyToken: PolyToken; + polyToken: PolyToken; /** * @hideconstructor diff --git a/src/contract_wrappers/SecurityTokenRegistrar.js b/src/contract_wrappers/SecurityTokenRegistrar.js index 7ccd572..1cc5f2a 100644 --- a/src/contract_wrappers/SecurityTokenRegistrar.js +++ b/src/contract_wrappers/SecurityTokenRegistrar.js @@ -4,8 +4,6 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { BigNumber } from 'bignumber.js'; import ContractWrapper from './ContractWrapper'; import securityTokenRegistrarArtifact from '../artifacts/SecurityTokenRegistrar.json'; -import SecurityToken from './SecurityToken'; -import Compliance from './Compliance'; import type { BlockRange, SecurityTokenRegistrarEventArgs, @@ -24,14 +22,9 @@ export default class SecurityTokenRegistrar extends ContractWrapper { */ constructor( web3Wrapper: Web3Wrapper, - securityToken: SecurityToken, - compliance: Compliance, deployedAddress?: string, ) { super(web3Wrapper, securityTokenRegistrarArtifact, deployedAddress); - - this.securityToken = securityToken; - this.compliance = compliance; } /** diff --git a/src/index.js b/src/index.js index 5fec855..d31849c 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper'; // import { ContractNotFoundError } from './types'; -import { Customers, PolyToken } from './contract_wrappers'; +import { Compliance, Customers, PolyToken, SecurityTokenRegistrar } from './contract_wrappers'; import type { Web3Provider } from './types'; export * from './contract_wrappers'; @@ -21,6 +21,8 @@ export class Polymath { polyToken: PolyToken; customers: Customers; + compliance: Compliance; + securityTokenRegistrar: SecurityTokenRegistrar; constructor(web3Provider: Web3Provider) { this._web3Wrapper = new Web3Wrapper(web3Provider); @@ -33,6 +35,12 @@ export class Polymath { this.customers = new Customers(this._web3Wrapper, this.polyToken); initializePromises.push(this.customers.initialize()); + this.compliance = new Compliance(this._web3Wrapper); + initializePromises.push(this.compliance.initialize()); + + this.securityTokenRegistrar = new SecurityTokenRegistrar(this._web3Wrapper); + initializePromises.push(this.securityTokenRegistrar.initialize()); + this.initializedPromise = Promise.all(initializePromises); } } diff --git a/test/Compliance_test.js b/test/Compliance_test.js index 2ef3c42..992b821 100644 --- a/test/Compliance_test.js +++ b/test/Compliance_test.js @@ -54,7 +54,6 @@ describe('Compliance wrapper', () => { polyToken, customers, compliance, - securityToken, accounts[0], accounts[1], expiryTime, diff --git a/test/SecurityToken_test.js b/test/SecurityToken_test.js index c542a72..e2a430d 100644 --- a/test/SecurityToken_test.js +++ b/test/SecurityToken_test.js @@ -53,7 +53,6 @@ describe('SecurityToken wrapper', () => { polyToken, customers, compliance, - securityToken, accounts[0], accounts[1], expiryTime, diff --git a/test/util/make_examples.js b/test/util/make_examples.js index 3cf622e..b0dd5fa 100644 --- a/test/util/make_examples.js +++ b/test/util/make_examples.js @@ -235,7 +235,6 @@ export async function makeSecurityTokenRegistrar( polyToken: PolyToken, customers: Customers, compliance: Compliance, - securityToken: SecurityToken, account: string, ) { const contractTemplate = contract(securityTokenRegistrarArtifact); @@ -250,7 +249,7 @@ export async function makeSecurityTokenRegistrar( from: account, }, ); - const registrar = new SecurityTokenRegistrar(web3Wrapper, securityToken, compliance, instance.address); + const registrar = new SecurityTokenRegistrar(web3Wrapper, instance.address); await registrar.initialize(); return registrar; @@ -312,7 +311,6 @@ export async function makeSecurityTokenThroughRegistrar( polyToken: PolyToken, customers: Customers, compliance: Compliance, - securityToken: SecurityToken, account: string, hostAccount: string, currentBlockTime: number, @@ -329,7 +327,7 @@ export async function makeSecurityTokenThroughRegistrar( from: account, }, ); - const registrar = new SecurityTokenRegistrar(web3Wrapper, securityToken, compliance, instance.address); + const registrar = new SecurityTokenRegistrar(web3Wrapper, instance.address); await registrar.initialize(); From 537c06a4813a3f66d51cea7ce0c2e9091031cd4a Mon Sep 17 00:00:00 2001 From: David Kajpust Date: Tue, 13 Feb 2018 12:02:00 -0500 Subject: [PATCH 2/3] test travis fix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 96c2ab2..97fe035 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ install: - - yarn install + - yarn prepack env: - CI="true" From 50d9709cde3830c2dd9d6eb5601e6b1de0ac3ae8 Mon Sep 17 00:00:00 2001 From: Adam0000 Date: Tue, 13 Feb 2018 13:44:42 -0500 Subject: [PATCH 3/3] Add functions to instantiate SecurityToken and Template. Fix test errors. Remove unused properties from SecurityToken. --- src/contract_wrappers/Compliance.js | 32 +++++++++++++----- src/contract_wrappers/SecurityToken.js | 11 ------- .../SecurityTokenRegistrar.js | 33 +++++++++++++++++-- test/Compliance_test.js | 17 +++++----- test/SecurityTokenRegistrar_test.js | 6 ++-- test/SecurityToken_test.js | 24 +++++++------- test/util/make_examples.js | 26 ++++----------- 7 files changed, 83 insertions(+), 66 deletions(-) diff --git a/src/contract_wrappers/Compliance.js b/src/contract_wrappers/Compliance.js index f043ffc..dc1275d 100644 --- a/src/contract_wrappers/Compliance.js +++ b/src/contract_wrappers/Compliance.js @@ -5,7 +5,7 @@ import Web3 from 'web3'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import ContractWrapper from './ContractWrapper'; - +import Template from './Template'; import complianceArtifact from '../artifacts/Compliance.json'; import type { BlockRange, @@ -81,7 +81,7 @@ export default class Compliance extends ContractWrapper { * @param fee Amount of POLY to use the template (held in escrow until issuance) * @param quorum Minimum percent of shareholders which need to vote to freeze * @param vestingPeriod Length of time to vest funds - * @return The address of the created template + * @return The created template */ async createTemplate( legalDelegateAddress: string, @@ -94,7 +94,7 @@ export default class Compliance extends ContractWrapper { fee: BigNumber, quorum: BigNumber, vestingPeriod: BigNumber, - ): Promise { + ): Promise