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/util | |
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/util')
-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 |
6 files changed, 34 insertions, 34 deletions
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], |