diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2017-12-20 13:44:08 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-12-20 22:30:25 +0800 |
commit | cb11aec84df346d5180c7d5874859c1c34f0bf1c (patch) | |
tree | b959a65bdcfc3e8b01dca1bc160f93a0df8a4bf9 /packages/contracts | |
parent | 972e1675f6490bc10e8d9fd64cce2f7945cd4840 (diff) | |
download | dexon-sol-tools-cb11aec84df346d5180c7d5874859c1c34f0bf1c.tar dexon-sol-tools-cb11aec84df346d5180c7d5874859c1c34f0bf1c.tar.gz dexon-sol-tools-cb11aec84df346d5180c7d5874859c1c34f0bf1c.tar.bz2 dexon-sol-tools-cb11aec84df346d5180c7d5874859c1c34f0bf1c.tar.lz dexon-sol-tools-cb11aec84df346d5180c7d5874859c1c34f0bf1c.tar.xz dexon-sol-tools-cb11aec84df346d5180c7d5874859c1c34f0bf1c.tar.zst dexon-sol-tools-cb11aec84df346d5180c7d5874859c1c34f0bf1c.zip |
Add new underscore-privates rule to @0xproject/tslint-config and fix lint errors
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/deploy/src/compiler.ts | 80 | ||||
-rw-r--r-- | packages/contracts/deploy/src/deployer.ts | 66 | ||||
-rw-r--r-- | packages/contracts/deploy/src/utils/contract.ts | 14 | ||||
-rw-r--r-- | packages/contracts/util/balances.ts | 12 | ||||
-rw-r--r-- | packages/contracts/util/exchange_wrapper.ts | 26 | ||||
-rw-r--r-- | packages/contracts/util/multi_sig_wrapper.ts | 6 | ||||
-rw-r--r-- | packages/contracts/util/order.ts | 6 | ||||
-rw-r--r-- | packages/contracts/util/order_factory.ts | 6 | ||||
-rw-r--r-- | packages/contracts/util/token_registry_wrapper.ts | 12 |
9 files changed, 114 insertions, 114 deletions
diff --git a/packages/contracts/deploy/src/compiler.ts b/packages/contracts/deploy/src/compiler.ts index 333a2d0ce..02b8699b6 100644 --- a/packages/contracts/deploy/src/compiler.ts +++ b/packages/contracts/deploy/src/compiler.ts @@ -19,18 +19,18 @@ import {utils} from './utils/utils'; const SOLIDITY_FILE_EXTENSION = '.sol'; export class Compiler { - private contractsDir: string; - private networkId: number; - private optimizerEnabled: number; - private artifactsDir: string; - private contractSourcesIfExists?: ContractSources; - private solcErrors: Set<string>; + private _contractsDir: string; + private _networkId: number; + private _optimizerEnabled: number; + private _artifactsDir: string; + private _contractSourcesIfExists?: ContractSources; + private _solcErrors: Set<string>; /** * Recursively retrieves Solidity source code from directory. * @param dirPath Directory to search. * @return Mapping of contract name to contract source. */ - private static async getContractSourcesAsync(dirPath: string): Promise<ContractSources> { + private static async _getContractSourcesAsync(dirPath: string): Promise<ContractSources> { let dirContents: string[] = []; try { dirContents = await fsWrapper.readdirAsync(dirPath); @@ -52,7 +52,7 @@ export class Compiler { } } else { try { - const nestedSources = await Compiler.getContractSourcesAsync(contentPath); + const nestedSources = await Compiler._getContractSourcesAsync(contentPath); sources = { ...sources, ...nestedSources, @@ -69,7 +69,7 @@ export class Compiler { * @param source Source code of contract. * @return Solc compiler version. */ - private static parseSolidityVersion(source: string): string { + private static _parseSolidityVersion(source: string): string { const solcVersionMatch = source.match(/(?:solidity\s\^?)([0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,2})/); if (_.isNull(solcVersionMatch)) { throw new Error('Could not find Solidity version in source'); @@ -85,7 +85,7 @@ export class Compiler { * @param errMsg An error message from the compiled output. * @return The error message with directories truncated from the contract path. */ - private static getNormalizedErrMsg(errMsg: string): string { + private static _getNormalizedErrMsg(errMsg: string): string { const errPathMatch = errMsg.match(/(.*\.sol)/); if (_.isNull(errPathMatch)) { throw new Error('Could not find a path in error message'); @@ -101,26 +101,26 @@ export class Compiler { * @return An instance of the Compiler class. */ constructor(opts: CompilerOptions) { - this.contractsDir = opts.contractsDir; - this.networkId = opts.networkId; - this.optimizerEnabled = opts.optimizerEnabled; - this.artifactsDir = opts.artifactsDir; - this.solcErrors = new Set(); + this._contractsDir = opts.contractsDir; + this._networkId = opts.networkId; + this._optimizerEnabled = opts.optimizerEnabled; + this._artifactsDir = opts.artifactsDir; + this._solcErrors = new Set(); } /** * Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir. */ public async compileAllAsync(): Promise<void> { - await this.createArtifactsDirIfDoesNotExistAsync(); - this.contractSourcesIfExists = await Compiler.getContractSourcesAsync(this.contractsDir); + await this._createArtifactsDirIfDoesNotExistAsync(); + this._contractSourcesIfExists = await Compiler._getContractSourcesAsync(this._contractsDir); - const contractBaseNames = _.keys(this.contractSourcesIfExists); + const contractBaseNames = _.keys(this._contractSourcesIfExists); const compiledContractPromises = _.map(contractBaseNames, async (contractBaseName: string): Promise<void> => { - return this.compileContractAsync(contractBaseName); + return this._compileContractAsync(contractBaseName); }); await Promise.all(compiledContractPromises); - this.solcErrors.forEach(errMsg => { + this._solcErrors.forEach(errMsg => { utils.consoleLog(errMsg); }); } @@ -128,14 +128,14 @@ export class Compiler { * Compiles contract and saves artifact to artifactsDir. * @param contractBaseName Name of contract with '.sol' extension. */ - private async compileContractAsync(contractBaseName: string): Promise<void> { - if (_.isUndefined(this.contractSourcesIfExists)) { + private async _compileContractAsync(contractBaseName: string): Promise<void> { + if (_.isUndefined(this._contractSourcesIfExists)) { throw new Error('Contract sources not yet initialized'); } - const source = this.contractSourcesIfExists[contractBaseName]; + const source = this._contractSourcesIfExists[contractBaseName]; const contractName = path.basename(contractBaseName, SOLIDITY_FILE_EXTENSION); - const currentArtifactPath = `${this.artifactsDir}/${contractName}.json`; + const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`; let currentArtifactString: string; @@ -149,10 +149,10 @@ export class Compiler { currentArtifactString = await fsWrapper.readFileAsync(currentArtifactPath, opts); currentArtifact = JSON.parse(currentArtifactString); oldNetworks = currentArtifact.networks; - const oldNetwork: ContractData = oldNetworks[this.networkId]; + const oldNetwork: ContractData = oldNetworks[this._networkId]; shouldCompile = _.isUndefined(oldNetwork) || oldNetwork.keccak256 !== sourceHash || - oldNetwork.optimizer_enabled !== this.optimizerEnabled; + oldNetwork.optimizer_enabled !== this._optimizerEnabled; } catch (err) { shouldCompile = true; } @@ -164,7 +164,7 @@ export class Compiler { const input = { [contractBaseName]: source, }; - const solcVersion = Compiler.parseSolidityVersion(source); + const solcVersion = Compiler._parseSolidityVersion(source); const fullSolcVersion = binPaths[solcVersion]; const solcBinPath = `./../solc/solc_bin/${fullSolcVersion}`; const solcBin = require(solcBinPath); @@ -175,13 +175,13 @@ export class Compiler { sources: input, }; const compiled = solcInstance.compile(sourcesToCompile, - this.optimizerEnabled, - this.findImportsIfSourcesExist.bind(this)); + this._optimizerEnabled, + this._findImportsIfSourcesExist.bind(this)); if (!_.isUndefined(compiled.errors)) { _.each(compiled.errors, errMsg => { - const normalizedErrMsg = Compiler.getNormalizedErrMsg(errMsg); - this.solcErrors.add(normalizedErrMsg); + const normalizedErrMsg = Compiler._getNormalizedErrMsg(errMsg); + this._solcErrors.add(normalizedErrMsg); }); } @@ -192,7 +192,7 @@ export class Compiler { const contractData: ContractData = { solc_version: solcVersion, keccak256: sourceHash, - optimizer_enabled: this.optimizerEnabled, + optimizer_enabled: this._optimizerEnabled, abi, unlinked_binary, updated_at, @@ -204,14 +204,14 @@ export class Compiler { ...currentArtifact, networks: { ...oldNetworks, - [this.networkId]: contractData, + [this._networkId]: contractData, }, }; } else { newArtifact = { contract_name: contractName, networks: { - [this.networkId]: contractData, + [this._networkId]: contractData, }, }; } @@ -226,12 +226,12 @@ export class Compiler { * @param importPath Path to an imported dependency. * @return Import contents object containing source code of dependency. */ - private findImportsIfSourcesExist(importPath: string): ImportContents { - if (_.isUndefined(this.contractSourcesIfExists)) { + private _findImportsIfSourcesExist(importPath: string): ImportContents { + if (_.isUndefined(this._contractSourcesIfExists)) { throw new Error('Contract sources not yet initialized'); } const contractBaseName = path.basename(importPath); - const source = this.contractSourcesIfExists[contractBaseName]; + const source = this._contractSourcesIfExists[contractBaseName]; const importContents: ImportContents = { contents: source, }; @@ -240,10 +240,10 @@ export class Compiler { /** * Creates the artifacts directory if it does not already exist. */ - private async createArtifactsDirIfDoesNotExistAsync(): Promise<void> { - if (!fsWrapper.doesPathExistSync(this.artifactsDir)) { + private async _createArtifactsDirIfDoesNotExistAsync(): Promise<void> { + if (!fsWrapper.doesPathExistSync(this._artifactsDir)) { utils.consoleLog('Creating artifacts directory...'); - await fsWrapper.mkdirAsync(this.artifactsDir); + await fsWrapper.mkdirAsync(this._artifactsDir); } } } diff --git a/packages/contracts/deploy/src/deployer.ts b/packages/contracts/deploy/src/deployer.ts index 991504972..ea1de59d3 100644 --- a/packages/contracts/deploy/src/deployer.ts +++ b/packages/contracts/deploy/src/deployer.ts @@ -18,19 +18,19 @@ const EXTRA_GAS = 200000; export class Deployer { public web3Wrapper: Web3Wrapper; - private artifactsDir: string; - private jsonrpcPort: number; - private networkId: number; - private defaults: Partial<TxData>; + private _artifactsDir: string; + private _jsonrpcPort: number; + private _networkId: number; + private _defaults: Partial<TxData>; constructor(opts: DeployerOptions) { - this.artifactsDir = opts.artifactsDir; - this.jsonrpcPort = opts.jsonrpcPort; - this.networkId = opts.networkId; - const jsonrpcUrl = `http://localhost:${this.jsonrpcPort}`; + this._artifactsDir = opts.artifactsDir; + this._jsonrpcPort = opts.jsonrpcPort; + this._networkId = opts.networkId; + const jsonrpcUrl = `http://localhost:${this._jsonrpcPort}`; const web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl); - this.defaults = opts.defaults; - this.web3Wrapper = new Web3Wrapper(web3Provider, this.defaults); + this._defaults = opts.defaults; + this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults); } /** * Loads contract artifact and deploys contract with given arguments. @@ -39,21 +39,21 @@ export class Deployer { * @return Deployed contract instance. */ public async deployAsync(contractName: string, args: any[] = []): Promise<Web3.ContractInstance> { - const contractArtifact: ContractArtifact = this.loadContractArtifactIfExists(contractName); - const contractData: ContractData = this.getContractDataFromArtifactIfExists(contractArtifact); + const contractArtifact: ContractArtifact = this._loadContractArtifactIfExists(contractName); + const contractData: ContractData = this._getContractDataFromArtifactIfExists(contractArtifact); const data = contractData.unlinked_binary; - const from = await this.getFromAddressAsync(); - const gas = await this.getAllowableGasEstimateAsync(data); + const from = await this._getFromAddressAsync(); + const gas = await this._getAllowableGasEstimateAsync(data); const txData = { - gasPrice: this.defaults.gasPrice, + gasPrice: this._defaults.gasPrice, from, data, gas, }; const abi = contractData.abi; - const web3ContractInstance = await this.deployFromAbiAsync(abi, args, txData); + const web3ContractInstance = await this._deployFromAbiAsync(abi, args, txData); utils.consoleLog(`${contractName}.sol successfully deployed at ${web3ContractInstance.address}`); - const contractInstance = new Contract(web3ContractInstance, this.defaults); + const contractInstance = new Contract(web3ContractInstance, this._defaults); return contractInstance; } /** @@ -64,7 +64,7 @@ export class Deployer { */ public async deployAndSaveAsync(contractName: string, args: any[] = []): Promise<Web3.ContractInstance> { const contractInstance = await this.deployAsync(contractName, args); - await this.saveContractDataToArtifactAsync(contractName, contractInstance.address, args); + await this._saveContractDataToArtifactAsync(contractName, contractInstance.address, args); return contractInstance; } /** @@ -74,7 +74,7 @@ export class Deployer { * @param txData Tx options used for deployment. * @return Promise that resolves to a web3 contract instance. */ - private async deployFromAbiAsync(abi: Web3.ContractAbi, args: any[], txData: Web3.TxData): Promise<any> { + private async _deployFromAbiAsync(abi: Web3.ContractAbi, args: any[], txData: Web3.TxData): Promise<any> { const contract: Web3.Contract<Web3.ContractInstance> = this.web3Wrapper.getContractFromAbi(abi); const deployPromise = new Promise((resolve, reject) => { /** @@ -99,10 +99,10 @@ export class Deployer { * @param contractAddress Contract address to save to artifact. * @param args Contract constructor arguments that will be encoded and saved to artifact. */ - private async saveContractDataToArtifactAsync(contractName: string, - contractAddress: string, args: any[]): Promise<void> { - const contractArtifact: ContractArtifact = this.loadContractArtifactIfExists(contractName); - const contractData: ContractData = this.getContractDataFromArtifactIfExists(contractArtifact); + private async _saveContractDataToArtifactAsync(contractName: string, + contractAddress: string, args: any[]): Promise<void> { + const contractArtifact: ContractArtifact = this._loadContractArtifactIfExists(contractName); + const contractData: ContractData = this._getContractDataFromArtifactIfExists(contractArtifact); const abi = contractData.abi; const encodedConstructorArgs = encoder.encodeConstructorArgsFromAbi(args, abi); const newContractData = { @@ -114,11 +114,11 @@ export class Deployer { ...contractArtifact, networks: { ...contractArtifact.networks, - [this.networkId]: newContractData, + [this._networkId]: newContractData, }, }; const artifactString = utils.stringifyWithFormatting(newArtifact); - const artifactPath = `${this.artifactsDir}/${contractName}.json`; + const artifactPath = `${this._artifactsDir}/${contractName}.json`; await fsWrapper.writeFileAsync(artifactPath, artifactString); } /** @@ -126,8 +126,8 @@ export class Deployer { * @param contractName Name of the contract, without the extension. * @return The contract artifact. */ - private loadContractArtifactIfExists(contractName: string): ContractArtifact { - const artifactPath = `${this.artifactsDir}/${contractName}.json`; + private _loadContractArtifactIfExists(contractName: string): ContractArtifact { + const artifactPath = `${this._artifactsDir}/${contractName}.json`; try { const contractArtifact: ContractArtifact = require(artifactPath); return contractArtifact; @@ -140,8 +140,8 @@ export class Deployer { * @param contractArtifact The contract artifact. * @return Network specific contract data. */ - private getContractDataFromArtifactIfExists(contractArtifact: ContractArtifact): ContractData { - const contractData = contractArtifact.networks[this.networkId]; + private _getContractDataFromArtifactIfExists(contractArtifact: ContractArtifact): ContractData { + const contractData = contractArtifact.networks[this._networkId]; if (_.isUndefined(contractData)) { throw new Error(`Data not found in artifact for contract: ${contractArtifact.contract_name}`); } @@ -151,13 +151,13 @@ export class Deployer { * Gets the address to use for sending a transaction. * @return The default from address. If not specified, returns the first address accessible by web3. */ - private async getFromAddressAsync(): Promise<string> { + private async _getFromAddressAsync(): Promise<string> { let from: string; - if (_.isUndefined(this.defaults.from)) { + if (_.isUndefined(this._defaults.from)) { const accounts = await this.web3Wrapper.getAvailableAddressesAsync(); from = accounts[0]; } else { - from = this.defaults.from; + from = this._defaults.from; } return from; } @@ -167,7 +167,7 @@ export class Deployer { * @param data Bytecode to estimate gas for. * @return Gas estimate for transaction data. */ - private async getAllowableGasEstimateAsync(data: string): Promise<number> { + private async _getAllowableGasEstimateAsync(data: string): Promise<number> { const block = await this.web3Wrapper.getBlockAsync('latest'); let gas: number; try { diff --git a/packages/contracts/deploy/src/utils/contract.ts b/packages/contracts/deploy/src/utils/contract.ts index 7b6098cea..c386e7d1a 100644 --- a/packages/contracts/deploy/src/utils/contract.ts +++ b/packages/contracts/deploy/src/utils/contract.ts @@ -8,9 +8,9 @@ import {AbiType} from './types'; export class Contract implements Web3.ContractInstance { public address: string; public abi: Web3.ContractAbi; - private contract: Web3.ContractInstance; - private defaults: Partial<Web3.TxData>; - private validator: SchemaValidator; + private _contract: Web3.ContractInstance; + private _defaults: Partial<Web3.TxData>; + private _validator: SchemaValidator; // This class instance is going to be populated with functions and events depending on the ABI // and we don't know their types in advance [name: string]: any; @@ -23,7 +23,7 @@ export class Contract implements Web3.ContractInstance { this.populateFunctions(); this.validator = new SchemaValidator(); } - private populateFunctions(): void { + private _populateFunctions(): void { const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Function); _.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => { if (functionAbi.constant) { @@ -41,13 +41,13 @@ export class Contract implements Web3.ContractInstance { } }); } - private populateEvents(): void { + private _populateEvents(): void { const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Event); _.forEach(eventsAbi, (eventAbi: Web3.EventAbi) => { this[eventAbi.name] = this.contract[eventAbi.name]; }); } - private promisifyWithDefaultParams(fn: (...args: any[]) => void): (...args: any[]) => Promise<any> { + private _promisifyWithDefaultParams(fn: (...args: any[]) => void): (...args: any[]) => Promise<any> { const promisifiedWithDefaultParams = async (...args: any[]) => { const promise = new Promise((resolve, reject) => { const lastArg = args[args.length - 1]; @@ -74,7 +74,7 @@ export class Contract implements Web3.ContractInstance { }; return promisifiedWithDefaultParams; } - private isTxData(lastArg: any): boolean { + private _isTxData(lastArg: any): boolean { const isValid = this.validator.isValid(lastArg, schemas.txDataSchema); return isValid; } diff --git a/packages/contracts/util/balances.ts b/packages/contracts/util/balances.ts index 7f5e843a5..5800a2008 100644 --- a/packages/contracts/util/balances.ts +++ b/packages/contracts/util/balances.ts @@ -7,16 +7,16 @@ import {BalancesByOwner, ContractInstance} from './types'; bigNumberConfigs.configure(); export class Balances { - private tokenContractInstances: ContractInstance[]; - private ownerAddresses: string[]; + private _tokenContractInstances: ContractInstance[]; + private _ownerAddresses: string[]; constructor(tokenContractInstances: ContractInstance[], ownerAddresses: string[]) { - this.tokenContractInstances = tokenContractInstances; - this.ownerAddresses = ownerAddresses; + this._tokenContractInstances = tokenContractInstances; + this._ownerAddresses = ownerAddresses; } public async getAsync(): Promise<BalancesByOwner> { const balancesByOwner: BalancesByOwner = {}; - for (const tokenContractInstance of this.tokenContractInstances) { - for (const ownerAddress of this.ownerAddresses) { + for (const tokenContractInstance of this._tokenContractInstances) { + for (const ownerAddress of this._ownerAddresses) { let balance = await tokenContractInstance.balanceOf(ownerAddress); balance = new BigNumber(balance); if (_.isUndefined(balancesByOwner[ownerAddress])) { diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts index 304dcdacf..9545710cd 100644 --- a/packages/contracts/util/exchange_wrapper.ts +++ b/packages/contracts/util/exchange_wrapper.ts @@ -6,9 +6,9 @@ import {Order} from './order'; import {ContractInstance} from './types'; export class ExchangeWrapper { - private exchange: ContractInstance; + private _exchange: ContractInstance; constructor(exchangeContractInstance: ContractInstance) { - this.exchange = exchangeContractInstance; + this._exchange = exchangeContractInstance; } public async fillOrderAsync(order: Order, from: string, opts: { @@ -17,7 +17,7 @@ export class ExchangeWrapper { } = {}) { const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance; const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount); - const tx = await this.exchange.fillOrder( + const tx = await this._exchange.fillOrder( params.orderAddresses, params.orderValues, params.fillTakerTokenAmount, @@ -33,7 +33,7 @@ export class ExchangeWrapper { public async cancelOrderAsync(order: Order, from: string, opts: {cancelTakerTokenAmount?: BigNumber} = {}) { const params = order.createCancel(opts.cancelTakerTokenAmount); - const tx = await this.exchange.cancelOrder( + const tx = await this._exchange.cancelOrder( params.orderAddresses, params.orderValues, params.cancelTakerTokenAmount, @@ -46,7 +46,7 @@ export class ExchangeWrapper { opts: {fillTakerTokenAmount?: BigNumber} = {}) { const shouldThrowOnInsufficientBalanceOrAllowance = true; const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount); - const tx = await this.exchange.fillOrKillOrder( + const tx = await this._exchange.fillOrKillOrder( params.orderAddresses, params.orderValues, params.fillTakerTokenAmount, @@ -66,7 +66,7 @@ export class ExchangeWrapper { const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance; const params = formatters.createBatchFill( orders, shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmounts); - const tx = await this.exchange.batchFillOrders( + const tx = await this._exchange.batchFillOrders( params.orderAddresses, params.orderValues, params.fillTakerTokenAmounts, @@ -82,7 +82,7 @@ export class ExchangeWrapper { public async batchFillOrKillOrdersAsync(orders: Order[], from: string, opts: {fillTakerTokenAmounts?: BigNumber[]} = {}) { const params = formatters.createBatchFill(orders, undefined, opts.fillTakerTokenAmounts); - const tx = await this.exchange.batchFillOrKillOrders( + const tx = await this._exchange.batchFillOrKillOrders( params.orderAddresses, params.orderValues, params.fillTakerTokenAmounts, @@ -103,7 +103,7 @@ export class ExchangeWrapper { const params = formatters.createFillUpTo(orders, shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount); - const tx = await this.exchange.fillOrdersUpTo( + const tx = await this._exchange.fillOrdersUpTo( params.orderAddresses, params.orderValues, params.fillTakerTokenAmount, @@ -119,7 +119,7 @@ export class ExchangeWrapper { public async batchCancelOrdersAsync(orders: Order[], from: string, opts: {cancelTakerTokenAmounts?: BigNumber[]} = {}) { const params = formatters.createBatchCancel(orders, opts.cancelTakerTokenAmounts); - const tx = await this.exchange.batchCancelOrders( + const tx = await this._exchange.batchCancelOrders( params.orderAddresses, params.orderValues, params.cancelTakerTokenAmounts, @@ -131,11 +131,11 @@ export class ExchangeWrapper { public async getOrderHashAsync(order: Order): Promise<string> { const shouldThrowOnInsufficientBalanceOrAllowance = false; const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance); - const orderHash = await this.exchange.getOrderHash(params.orderAddresses, params.orderValues); + const orderHash = await this._exchange.getOrderHash(params.orderAddresses, params.orderValues); return orderHash; } public async isValidSignatureAsync(order: Order): Promise<boolean> { - const isValidSignature = await this.exchange.isValidSignature( + const isValidSignature = await this._exchange.isValidSignature( order.params.maker, order.params.orderHashHex, order.params.v, @@ -146,12 +146,12 @@ export class ExchangeWrapper { } public async isRoundingErrorAsync(numerator: BigNumber, denominator: BigNumber, target: BigNumber): Promise<boolean> { - const isRoundingError = await this.exchange.isRoundingError(numerator, denominator, target); + const isRoundingError = await this._exchange.isRoundingError(numerator, denominator, target); return isRoundingError; } public async getPartialAmountAsync(numerator: BigNumber, denominator: BigNumber, target: BigNumber): Promise<BigNumber> { - const partialAmount = new BigNumber(await this.exchange.getPartialAmount(numerator, denominator, target)); + const partialAmount = new BigNumber(await this._exchange.getPartialAmount(numerator, denominator, target)); return partialAmount; } } diff --git a/packages/contracts/util/multi_sig_wrapper.ts b/packages/contracts/util/multi_sig_wrapper.ts index 4ad970ac9..2e4174436 100644 --- a/packages/contracts/util/multi_sig_wrapper.ts +++ b/packages/contracts/util/multi_sig_wrapper.ts @@ -6,7 +6,7 @@ import * as Web3 from 'web3'; import {ContractInstance, TransactionDataParams} from './types'; export class MultiSigWrapper { - private multiSig: ContractInstance; + private _multiSig: ContractInstance; public static encodeFnArgs(name: string, abi: Web3.AbiDefinition[], args: any[]) { const abiEntity = _.find(abi, {name}) as Web3.MethodAbi; if (_.isUndefined(abiEntity)) { @@ -22,13 +22,13 @@ export class MultiSigWrapper { return funcSig + argsData.join(''); } constructor(multiSigContractInstance: ContractInstance) { - this.multiSig = multiSigContractInstance; + this._multiSig = multiSigContractInstance; } public async submitTransactionAsync(destination: string, from: string, dataParams: TransactionDataParams, value: number = 0) { const {name, abi, args = []} = dataParams; const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args); - return this.multiSig.submitTransaction(destination, value, encoded, {from}); + return this._multiSig.submitTransaction(destination, value, encoded, {from}); } } diff --git a/packages/contracts/util/order.ts b/packages/contracts/util/order.ts index ec5362b66..52d611ade 100644 --- a/packages/contracts/util/order.ts +++ b/packages/contracts/util/order.ts @@ -21,7 +21,7 @@ export class Order { if (_.isUndefined(v) || _.isUndefined(r) || _.isUndefined(s)) { throw new Error('Cannot call isValidSignature on unsigned order'); } - const orderHash = this.getOrderHash(); + const orderHash = this._getOrderHash(); const msgHash = ethUtil.hashPersonalMessage(ethUtil.toBuffer(orderHash)); try { const pubKey = ethUtil.ecrecover(msgHash, v, ethUtil.toBuffer(r), ethUtil.toBuffer(s)); @@ -32,7 +32,7 @@ export class Order { } } public async signAsync() { - const orderHash = this.getOrderHash(); + const orderHash = this._getOrderHash(); const signature = await promisify<string>(web3.eth.sign)(this.params.maker, orderHash); const {v, r, s} = ethUtil.fromRpcSig(signature); this.params = _.assign(this.params, { @@ -88,7 +88,7 @@ export class Order { }; return cancel; } - private getOrderHash(): string { + private _getOrderHash(): string { const orderHash = crypto.solSHA3([ this.params.exchangeContractAddress, this.params.maker, diff --git a/packages/contracts/util/order_factory.ts b/packages/contracts/util/order_factory.ts index 526e229a4..9d96a8394 100644 --- a/packages/contracts/util/order_factory.ts +++ b/packages/contracts/util/order_factory.ts @@ -6,9 +6,9 @@ import {Order} from './order'; import {DefaultOrderParams, OptionalOrderParams, OrderParams} from './types'; export class OrderFactory { - private defaultOrderParams: DefaultOrderParams; + private _defaultOrderParams: DefaultOrderParams; constructor(defaultOrderParams: DefaultOrderParams) { - this.defaultOrderParams = defaultOrderParams; + this._defaultOrderParams = defaultOrderParams; } public async newSignedOrderAsync(customOrderParams: OptionalOrderParams = {}) { const randomExpiration = new BigNumber(Math.floor((Date.now() + (Math.random() * 100000000000)) / 1000)); @@ -16,7 +16,7 @@ export class OrderFactory { expirationTimestampInSec: randomExpiration, salt: ZeroEx.generatePseudoRandomSalt(), taker: ZeroEx.NULL_ADDRESS, - }, this.defaultOrderParams, customOrderParams); + }, this._defaultOrderParams, customOrderParams); const order = new Order(orderParams); await order.signAsync(); return order; diff --git a/packages/contracts/util/token_registry_wrapper.ts b/packages/contracts/util/token_registry_wrapper.ts index 5e1c627cc..c10cf4f5f 100644 --- a/packages/contracts/util/token_registry_wrapper.ts +++ b/packages/contracts/util/token_registry_wrapper.ts @@ -1,12 +1,12 @@ import {ContractInstance, Token} from './types'; export class TokenRegWrapper { - private tokenReg: ContractInstance; + private _tokenReg: ContractInstance; constructor(tokenRegContractInstance: ContractInstance) { - this.tokenReg = tokenRegContractInstance; + this._tokenReg = tokenRegContractInstance; } public addTokenAsync(token: Token, from: string) { - const tx = this.tokenReg.addToken( + const tx = this._tokenReg.addToken( token.address, token.name, token.symbol, @@ -18,7 +18,7 @@ export class TokenRegWrapper { return tx; } public async getTokenMetaDataAsync(tokenAddress: string) { - const data = await this.tokenReg.getTokenMetaData(tokenAddress); + const data = await this._tokenReg.getTokenMetaData(tokenAddress); const token: Token = { address: data[0], name: data[1], @@ -30,7 +30,7 @@ export class TokenRegWrapper { return token; } public async getTokenByNameAsync(tokenName: string) { - const data = await this.tokenReg.getTokenByName(tokenName); + const data = await this._tokenReg.getTokenByName(tokenName); const token: Token = { address: data[0], name: data[1], @@ -42,7 +42,7 @@ export class TokenRegWrapper { return token; } public async getTokenBySymbolAsync(tokenSymbol: string) { - const data = await this.tokenReg.getTokenBySymbol(tokenSymbol); + const data = await this._tokenReg.getTokenBySymbol(tokenSymbol); const token: Token = { address: data[0], name: data[1], |