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/kovan-faucets | |
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/kovan-faucets')
-rw-r--r-- | packages/kovan-faucets/src/ts/handler.ts | 36 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/zrx_request_queue.ts | 6 |
2 files changed, 21 insertions, 21 deletions
diff --git a/packages/kovan-faucets/src/ts/handler.ts b/packages/kovan-faucets/src/ts/handler.ts index d31d1478d..071eb8ba0 100644 --- a/packages/kovan-faucets/src/ts/handler.ts +++ b/packages/kovan-faucets/src/ts/handler.ts @@ -18,25 +18,25 @@ import {ZRXRequestQueue} from './zrx_request_queue'; import * as Web3 from 'web3'; export class Handler { - private etherRequestQueue: EtherRequestQueue; - private zrxRequestQueue: ZRXRequestQueue; - private web3: Web3; + private _etherRequestQueue: EtherRequestQueue; + private _zrxRequestQueue: ZRXRequestQueue; + private _web3: Web3; constructor() { // Setup provider engine to talk with RPC node - const providerObj = this.createProviderEngine(configs.RPC_URL); - this.web3 = new Web3(providerObj); + const providerObj = this._createProviderEngine(configs.RPC_URL); + this._web3 = new Web3(providerObj); - this.etherRequestQueue = new EtherRequestQueue(this.web3); - this.zrxRequestQueue = new ZRXRequestQueue(this.web3); + this._etherRequestQueue = new EtherRequestQueue(this._web3); + this._zrxRequestQueue = new ZRXRequestQueue(this._web3); } public dispenseEther(req: express.Request, res: express.Response) { const recipientAddress = req.params.recipient; - if (_.isUndefined(recipientAddress) || !this.isValidEthereumAddress(recipientAddress)) { + if (_.isUndefined(recipientAddress) || !this._isValidEthereumAddress(recipientAddress)) { res.status(400).send('INVALID_REQUEST'); return; } const lowerCaseRecipientAddress = recipientAddress.toLowerCase(); - const didAddToQueue = this.etherRequestQueue.add(lowerCaseRecipientAddress); + const didAddToQueue = this._etherRequestQueue.add(lowerCaseRecipientAddress); if (!didAddToQueue) { res.status(503).send('QUEUE_IS_FULL'); return; @@ -46,12 +46,12 @@ export class Handler { } public dispenseZRX(req: express.Request, res: express.Response) { const recipientAddress = req.params.recipient; - if (_.isUndefined(recipientAddress) || !this.isValidEthereumAddress(recipientAddress)) { + if (_.isUndefined(recipientAddress) || !this._isValidEthereumAddress(recipientAddress)) { res.status(400).send('INVALID_REQUEST'); return; } const lowerCaseRecipientAddress = recipientAddress.toLowerCase(); - const didAddToQueue = this.zrxRequestQueue.add(lowerCaseRecipientAddress); + const didAddToQueue = this._zrxRequestQueue.add(lowerCaseRecipientAddress); if (!didAddToQueue) { res.status(503).send('QUEUE_IS_FULL'); return; @@ -63,18 +63,18 @@ export class Handler { res.setHeader('Content-Type', 'application/json'); const payload = JSON.stringify({ ether: { - full: this.etherRequestQueue.isFull(), - size: this.etherRequestQueue.size(), + full: this._etherRequestQueue.isFull(), + size: this._etherRequestQueue.size(), }, zrx: { - full: this.zrxRequestQueue.isFull(), - size: this.zrxRequestQueue.size(), + full: this._zrxRequestQueue.isFull(), + size: this._zrxRequestQueue.size(), }, }); res.status(200).send(payload); } // tslint:disable-next-line:prefer-function-over-method - private createProviderEngine(rpcUrl: string) { + private _createProviderEngine(rpcUrl: string) { const engine = new ProviderEngine(); engine.addProvider(new NonceSubprovider()); engine.addProvider(new HookedWalletSubprovider(idManagement)); @@ -84,8 +84,8 @@ export class Handler { engine.start(); return engine; } - private isValidEthereumAddress(address: string): boolean { + private _isValidEthereumAddress(address: string): boolean { const lowercaseAddress = address.toLowerCase(); - return this.web3.isAddress(lowercaseAddress); + return this._web3.isAddress(lowercaseAddress); } } diff --git a/packages/kovan-faucets/src/ts/zrx_request_queue.ts b/packages/kovan-faucets/src/ts/zrx_request_queue.ts index 717adc3c4..630991e3b 100644 --- a/packages/kovan-faucets/src/ts/zrx_request_queue.ts +++ b/packages/kovan-faucets/src/ts/zrx_request_queue.ts @@ -17,20 +17,20 @@ const DISPENSE_AMOUNT_ZRX = new BigNumber(0.1); const QUEUE_INTERVAL_MS = 5000; export class ZRXRequestQueue extends RequestQueue { - private zeroEx: ZeroEx; + private _zeroEx: ZeroEx; constructor(web3: Web3) { super(web3); this.queueIntervalMs = QUEUE_INTERVAL_MS; const zeroExConfig = { networkId: configs.KOVAN_NETWORK_ID, }; - this.zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig); + this._zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig); } protected async processNextRequestFireAndForgetAsync(recipientAddress: string) { utils.consoleLog(`Processing ZRX ${recipientAddress}`); const baseUnitAmount = ZeroEx.toBaseUnitAmount(DISPENSE_AMOUNT_ZRX, 18); try { - await this.zeroEx.token.transferAsync( + await this._zeroEx.token.transferAsync( configs.ZRX_TOKEN_ADDRESS, configs.DISPENSER_ADDRESS, recipientAddress, baseUnitAmount, ); utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ZRX} ZRX to ${recipientAddress}`); |