diff options
author | Brandon Millman <brandon@0xproject.com> | 2017-12-22 02:16:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-22 02:16:25 +0800 |
commit | cb3582289ff94857d5956bbd71dbf68ee3f42ecf (patch) | |
tree | 62c94cba698834e33cf284c084c04e30766190e8 /packages/0x.js/test | |
parent | 734d220d6050ad7b9fa66e5e0695b848501eeff6 (diff) | |
parent | 2d53b7d9a499e4fb5791fe34cae5ef118bdfc0ce (diff) | |
download | dexon-0x-contracts-cb3582289ff94857d5956bbd71dbf68ee3f42ecf.tar dexon-0x-contracts-cb3582289ff94857d5956bbd71dbf68ee3f42ecf.tar.gz dexon-0x-contracts-cb3582289ff94857d5956bbd71dbf68ee3f42ecf.tar.bz2 dexon-0x-contracts-cb3582289ff94857d5956bbd71dbf68ee3f42ecf.tar.lz dexon-0x-contracts-cb3582289ff94857d5956bbd71dbf68ee3f42ecf.tar.xz dexon-0x-contracts-cb3582289ff94857d5956bbd71dbf68ee3f42ecf.tar.zst dexon-0x-contracts-cb3582289ff94857d5956bbd71dbf68ee3f42ecf.zip |
Merge pull request #285 from 0xProject/fix/underscorePrivate
Add new underscore-privates rule to @0xproject/tslint-config and fix …
Diffstat (limited to 'packages/0x.js/test')
4 files changed, 46 insertions, 46 deletions
diff --git a/packages/0x.js/test/exchange_transfer_simulator_test.ts b/packages/0x.js/test/exchange_transfer_simulator_test.ts index dbd1e99bd..c7e3cde06 100644 --- a/packages/0x.js/test/exchange_transfer_simulator_test.ts +++ b/packages/0x.js/test/exchange_transfer_simulator_test.ts @@ -65,7 +65,7 @@ describe('ExchangeTransferSimulator', () => { await exchangeTransferSimulator.transferFromAsync( exampleTokenAddress, sender, recipient, transferAmount, TradeSide.Taker, TransferType.Trade, ); - const store = (exchangeTransferSimulator as any).store; + const store = (exchangeTransferSimulator as any)._store; const senderBalance = await store.getBalanceAsync(exampleTokenAddress, sender); const recipientBalance = await store.getBalanceAsync(exampleTokenAddress, recipient); const senderProxyAllowance = await store.getProxyAllowanceAsync(exampleTokenAddress, sender); @@ -81,7 +81,7 @@ describe('ExchangeTransferSimulator', () => { await exchangeTransferSimulator.transferFromAsync( exampleTokenAddress, sender, recipient, transferAmount, TradeSide.Taker, TransferType.Trade, ); - const store = (exchangeTransferSimulator as any).store; + const store = (exchangeTransferSimulator as any)._store; const senderBalance = await store.getBalanceAsync(exampleTokenAddress, sender); const recipientBalance = await store.getBalanceAsync(exampleTokenAddress, recipient); const senderProxyAllowance = await store.getProxyAllowanceAsync(exampleTokenAddress, sender); diff --git a/packages/0x.js/test/utils/fill_scenarios.ts b/packages/0x.js/test/utils/fill_scenarios.ts index 5f3e89906..8f28ee503 100644 --- a/packages/0x.js/test/utils/fill_scenarios.ts +++ b/packages/0x.js/test/utils/fill_scenarios.ts @@ -11,24 +11,24 @@ import {constants} from './constants'; const INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS = new BigNumber(100); export class FillScenarios { - private zeroEx: ZeroEx; - private userAddresses: string[]; - private tokens: Token[]; - private coinbase: string; - private zrxTokenAddress: string; - private exchangeContractAddress: string; + private _zeroEx: ZeroEx; + private _userAddresses: string[]; + private _tokens: Token[]; + private _coinbase: string; + private _zrxTokenAddress: string; + private _exchangeContractAddress: string; constructor(zeroEx: ZeroEx, userAddresses: string[], tokens: Token[], zrxTokenAddress: string, exchangeContractAddress: string) { - this.zeroEx = zeroEx; - this.userAddresses = userAddresses; - this.tokens = tokens; - this.coinbase = userAddresses[0]; - this.zrxTokenAddress = zrxTokenAddress; - this.exchangeContractAddress = exchangeContractAddress; + this._zeroEx = zeroEx; + this._userAddresses = userAddresses; + this._tokens = tokens; + this._coinbase = userAddresses[0]; + this._zrxTokenAddress = zrxTokenAddress; + this._exchangeContractAddress = exchangeContractAddress; } public async initTokenBalancesAsync() { - const web3Wrapper = (this.zeroEx as any)._web3Wrapper as Web3Wrapper; - for (const token of this.tokens) { + const web3Wrapper = (this._zeroEx as any)._web3Wrapper as Web3Wrapper; + for (const token of this._tokens) { if (token.symbol !== 'ZRX' && token.symbol !== 'WETH') { const contractInstance = web3Wrapper.getContractInstance( artifacts.DummyTokenArtifact.abi, token.address, @@ -36,10 +36,10 @@ export class FillScenarios { const defaults = {}; const dummyToken = new DummyTokenContract(contractInstance, defaults); const tokenSupply = ZeroEx.toBaseUnitAmount(INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS, token.decimals); - const txHash = await dummyToken.setBalance.sendTransactionAsync(this.coinbase, tokenSupply, { - from: this.coinbase, + const txHash = await dummyToken.setBalance.sendTransactionAsync(this._coinbase, tokenSupply, { + from: this._coinbase, }); - await this.zeroEx.awaitTransactionMinedAsync(txHash); + await this._zeroEx.awaitTransactionMinedAsync(txHash); } } } @@ -60,7 +60,7 @@ export class FillScenarios { fillableAmount: BigNumber, feeRecepient: string, expirationUnixTimestampSec?: BigNumber, ): Promise<SignedOrder> { - return this.createAsymmetricFillableSignedOrderWithFeesAsync( + return this._createAsymmetricFillableSignedOrderWithFeesAsync( makerTokenAddress, takerTokenAddress, makerFee, takerFee, makerAddress, takerAddress, fillableAmount, fillableAmount, feeRecepient, expirationUnixTimestampSec, ); @@ -72,7 +72,7 @@ export class FillScenarios { const makerFee = new BigNumber(0); const takerFee = new BigNumber(0); const feeRecepient = constants.NULL_ADDRESS; - return this.createAsymmetricFillableSignedOrderWithFeesAsync( + return this._createAsymmetricFillableSignedOrderWithFeesAsync( makerTokenAddress, takerTokenAddress, makerFee, takerFee, makerAddress, takerAddress, makerFillableAmount, takerFillableAmount, feeRecepient, expirationUnixTimestampSec, ); @@ -80,18 +80,18 @@ export class FillScenarios { public async createPartiallyFilledSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string, takerAddress: string, fillableAmount: BigNumber, partialFillAmount: BigNumber) { - const [makerAddress] = this.userAddresses; + const [makerAddress] = this._userAddresses; const signedOrder = await this.createAsymmetricFillableSignedOrderAsync( makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, fillableAmount, ); const shouldThrowOnInsufficientBalanceOrAllowance = false; - await this.zeroEx.exchange.fillOrderAsync( + await this._zeroEx.exchange.fillOrderAsync( signedOrder, partialFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, ); return signedOrder; } - private async createAsymmetricFillableSignedOrderWithFeesAsync( + private async _createAsymmetricFillableSignedOrderWithFeesAsync( makerTokenAddress: string, takerTokenAddress: string, makerFee: BigNumber, takerFee: BigNumber, makerAddress: string, takerAddress: string, @@ -99,39 +99,39 @@ export class FillScenarios { feeRecepient: string, expirationUnixTimestampSec?: BigNumber): Promise<SignedOrder> { await Promise.all([ - this.increaseBalanceAndAllowanceAsync(makerTokenAddress, makerAddress, makerFillableAmount), - this.increaseBalanceAndAllowanceAsync(takerTokenAddress, takerAddress, takerFillableAmount), + this._increaseBalanceAndAllowanceAsync(makerTokenAddress, makerAddress, makerFillableAmount), + this._increaseBalanceAndAllowanceAsync(takerTokenAddress, takerAddress, takerFillableAmount), ]); await Promise.all([ - this.increaseBalanceAndAllowanceAsync(this.zrxTokenAddress, makerAddress, makerFee), - this.increaseBalanceAndAllowanceAsync(this.zrxTokenAddress, takerAddress, takerFee), + this._increaseBalanceAndAllowanceAsync(this._zrxTokenAddress, makerAddress, makerFee), + this._increaseBalanceAndAllowanceAsync(this._zrxTokenAddress, takerAddress, takerFee), ]); - const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx, + const signedOrder = await orderFactory.createSignedOrderAsync(this._zeroEx, makerAddress, takerAddress, makerFee, takerFee, makerFillableAmount, makerTokenAddress, takerFillableAmount, takerTokenAddress, - this.exchangeContractAddress, feeRecepient, expirationUnixTimestampSec); + this._exchangeContractAddress, feeRecepient, expirationUnixTimestampSec); return signedOrder; } - private async increaseBalanceAndAllowanceAsync( + private async _increaseBalanceAndAllowanceAsync( tokenAddress: string, address: string, amount: BigNumber): Promise<void> { if (amount.isZero() || address === ZeroEx.NULL_ADDRESS) { return; // noop } await Promise.all([ - this.increaseBalanceAsync(tokenAddress, address, amount), - this.increaseAllowanceAsync(tokenAddress, address, amount), + this._increaseBalanceAsync(tokenAddress, address, amount), + this._increaseAllowanceAsync(tokenAddress, address, amount), ]); } - private async increaseBalanceAsync( + private async _increaseBalanceAsync( tokenAddress: string, address: string, amount: BigNumber): Promise<void> { - await this.zeroEx.token.transferAsync(tokenAddress, this.coinbase, address, amount); + await this._zeroEx.token.transferAsync(tokenAddress, this._coinbase, address, amount); } - private async increaseAllowanceAsync( + private async _increaseAllowanceAsync( tokenAddress: string, address: string, amount: BigNumber): Promise<void> { - const oldMakerAllowance = await this.zeroEx.token.getProxyAllowanceAsync(tokenAddress, address); + const oldMakerAllowance = await this._zeroEx.token.getProxyAllowanceAsync(tokenAddress, address); const newMakerAllowance = oldMakerAllowance.plus(amount); - await this.zeroEx.token.setProxyAllowanceAsync( + await this._zeroEx.token.setProxyAllowanceAsync( tokenAddress, address, newMakerAllowance, ); } diff --git a/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts b/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts index 059163f2e..d502ca34e 100644 --- a/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts +++ b/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts @@ -9,16 +9,16 @@ import {JSONRPCPayload} from '../../../src/types'; * Source: https://github.com/MetaMask/provider-engine/blob/master/subproviders/subprovider.js */ export class FakeGasEstimateSubprovider { - private constantGasAmount: number; + private _constantGasAmount: number; constructor(constantGasAmount: number) { - this.constantGasAmount = constantGasAmount; + this._constantGasAmount = constantGasAmount; } // This method needs to be here to satisfy the interface but linter wants it to be static. // tslint:disable-next-line:prefer-function-over-method public handleRequest(payload: JSONRPCPayload, next: () => void, end: (err: Error|null, result: any) => void) { switch (payload.method) { case 'eth_estimateGas': - end(null, this.constantGasAmount); + end(null, this._constantGasAmount); return; default: diff --git a/packages/0x.js/test/utils/token_utils.ts b/packages/0x.js/test/utils/token_utils.ts index 7da7f466c..48b5e1798 100644 --- a/packages/0x.js/test/utils/token_utils.ts +++ b/packages/0x.js/test/utils/token_utils.ts @@ -6,26 +6,26 @@ const PROTOCOL_TOKEN_SYMBOL = 'ZRX'; const WETH_TOKEN_SYMBOL = 'WETH'; export class TokenUtils { - private tokens: Token[]; + private _tokens: Token[]; constructor(tokens: Token[]) { - this.tokens = tokens; + this._tokens = tokens; } public getProtocolTokenOrThrow(): Token { - const zrxToken = _.find(this.tokens, {symbol: PROTOCOL_TOKEN_SYMBOL}); + const zrxToken = _.find(this._tokens, {symbol: PROTOCOL_TOKEN_SYMBOL}); if (_.isUndefined(zrxToken)) { throw new Error(InternalZeroExError.ZrxNotInTokenRegistry); } return zrxToken; } public getWethTokenOrThrow(): Token { - const wethToken = _.find(this.tokens, {symbol: WETH_TOKEN_SYMBOL}); + const wethToken = _.find(this._tokens, {symbol: WETH_TOKEN_SYMBOL}); if (_.isUndefined(wethToken)) { throw new Error(InternalZeroExError.WethNotInTokenRegistry); } return wethToken; } public getDummyTokens(): Token[] { - const dummyTokens = _.filter(this.tokens, token => { + const dummyTokens = _.filter(this._tokens, token => { return !_.includes([PROTOCOL_TOKEN_SYMBOL, WETH_TOKEN_SYMBOL], token.symbol); }); return dummyTokens; |