diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2017-12-13 09:18:15 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2017-12-14 04:36:29 +0800 |
commit | 91f276d9254bba3d93fc821c4fadab2eb6fc1d65 (patch) | |
tree | 9c33a09f44f06d5f9b45da74e027012cf4dfbbb6 /packages/kovan-faucets/src | |
parent | 1e9f23ebba5e0729b64e757d6901205278871e9f (diff) | |
download | dexon-sol-tools-91f276d9254bba3d93fc821c4fadab2eb6fc1d65.tar dexon-sol-tools-91f276d9254bba3d93fc821c4fadab2eb6fc1d65.tar.gz dexon-sol-tools-91f276d9254bba3d93fc821c4fadab2eb6fc1d65.tar.bz2 dexon-sol-tools-91f276d9254bba3d93fc821c4fadab2eb6fc1d65.tar.lz dexon-sol-tools-91f276d9254bba3d93fc821c4fadab2eb6fc1d65.tar.xz dexon-sol-tools-91f276d9254bba3d93fc821c4fadab2eb6fc1d65.tar.zst dexon-sol-tools-91f276d9254bba3d93fc821c4fadab2eb6fc1d65.zip |
Cleanup kovan-faucet package
Diffstat (limited to 'packages/kovan-faucets/src')
-rw-r--r-- | packages/kovan-faucets/src/ts/configs.ts | 3 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/ether_request_queue.ts | 2 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/global.d.ts | 17 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/handler.ts | 5 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/id_management.ts | 11 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/request_queue.ts | 4 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/server.ts | 2 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/zrx_request_queue.ts | 13 |
8 files changed, 25 insertions, 32 deletions
diff --git a/packages/kovan-faucets/src/ts/configs.ts b/packages/kovan-faucets/src/ts/configs.ts index 2b130446d..f432ba66f 100644 --- a/packages/kovan-faucets/src/ts/configs.ts +++ b/packages/kovan-faucets/src/ts/configs.ts @@ -5,6 +5,7 @@ export const configs = { ROLLBAR_ACCESS_KEY: process.env.FAUCET_ROLLBAR_ACCESS_KEY, RPC_URL: process.env.FAUCET_ENVIRONMENT === 'development' ? 'http://127.0.0.1:8545' : - 'https://kovan.infura.io/T5WSC8cautR4KXyYgsRs', + `https://kovan.infura.io/${process.env.INFURA_API_KEY}`, ZRX_TOKEN_ADDRESS: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570', + KOVAN_NETWORK_ID: 42, }; diff --git a/packages/kovan-faucets/src/ts/ether_request_queue.ts b/packages/kovan-faucets/src/ts/ether_request_queue.ts index b1648ca28..0750e6170 100644 --- a/packages/kovan-faucets/src/ts/ether_request_queue.ts +++ b/packages/kovan-faucets/src/ts/ether_request_queue.ts @@ -1,4 +1,4 @@ -import promisify = require('es6-promisify'); +import {promisify} from '@0xproject/utils'; import * as _ from 'lodash'; import {configs} from './configs'; diff --git a/packages/kovan-faucets/src/ts/global.d.ts b/packages/kovan-faucets/src/ts/global.d.ts index cdfa67378..c698207dd 100644 --- a/packages/kovan-faucets/src/ts/global.d.ts +++ b/packages/kovan-faucets/src/ts/global.d.ts @@ -1,7 +1,4 @@ -declare module 'elliptic'; declare module 'rollbar'; -declare module 'ethereumjs-tx'; -declare module 'es6-promisify'; declare module 'web3-provider-engine'; declare module 'web3-provider-engine/subproviders/rpc'; declare module 'web3-provider-engine/subproviders/nonce-tracker'; @@ -13,3 +10,17 @@ declare module '*.json' { export default json; /* tslint:enable */ } + +// Ethereumjs-tx declarations +declare module 'ethereumjs-tx' { + class EthereumTx { + public raw: Buffer[]; + public r: Buffer; + public s: Buffer; + public v: Buffer; + public serialize(): Buffer; + public sign(buffer: Buffer): void; + constructor(txParams: any); + } + export = EthereumTx; +} diff --git a/packages/kovan-faucets/src/ts/handler.ts b/packages/kovan-faucets/src/ts/handler.ts index f3c6ba1f0..d76a29514 100644 --- a/packages/kovan-faucets/src/ts/handler.ts +++ b/packages/kovan-faucets/src/ts/handler.ts @@ -12,11 +12,6 @@ import {idManagement} from './id_management'; import {utils} from './utils'; import {ZRXRequestQueue} from './zrx_request_queue'; -// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang -// because they are using the wrong XHR package. -// Issue: https://github.com/trufflesuite/truffle-contract/issues/14 -delete (global as any).XMLHttpRequest; - export class Handler { private etherRequestQueue: EtherRequestQueue; private zrxRequestQueue: ZRXRequestQueue; diff --git a/packages/kovan-faucets/src/ts/id_management.ts b/packages/kovan-faucets/src/ts/id_management.ts index 2090ce58a..89d6f6fd1 100644 --- a/packages/kovan-faucets/src/ts/id_management.ts +++ b/packages/kovan-faucets/src/ts/id_management.ts @@ -1,14 +1,13 @@ -import * as EthereumTx from 'ethereumjs-tx'; +import EthereumTx = require('ethereumjs-tx'); import {configs} from './configs'; +import {utils} from './utils'; type Callback = (err: Error, accounts: any) => void; export const idManagement = { getAccounts(callback: Callback) { - /* tslint:disable */ - console.log('configs.DISPENSER_ADDRESS', configs.DISPENSER_ADDRESS); - /* tslint:enable */ + utils.consoleLog(`configs.DISPENSER_ADDRESS: ${configs.DISPENSER_ADDRESS}`); callback(null, [ configs.DISPENSER_ADDRESS, ]); @@ -17,9 +16,7 @@ export const idManagement = { callback(null, true); }, signTransaction(txData: object, callback: Callback) { - /* tslint:disable */ - let tx = new EthereumTx(txData); - /* tslint:enable */ + const tx = new EthereumTx(txData); const privateKeyBuffer = new Buffer(configs.DISPENSER_PRIVATE_KEY, 'hex'); tx.sign(privateKeyBuffer); const rawTx = `0x${tx.serialize().toString('hex')}`; diff --git a/packages/kovan-faucets/src/ts/request_queue.ts b/packages/kovan-faucets/src/ts/request_queue.ts index 98e8e381a..2a3fd4d03 100644 --- a/packages/kovan-faucets/src/ts/request_queue.ts +++ b/packages/kovan-faucets/src/ts/request_queue.ts @@ -1,10 +1,6 @@ import * as _ from 'lodash'; import * as timers from 'timers'; import * as Web3 from 'web3'; -// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang -// because they are using the wrong XHR package. -// Issue: https://github.com/trufflesuite/truffle-contract/issues/14 -delete (global as any).XMLHttpRequest; const MAX_QUEUE_SIZE = 500; const DEFAULT_QUEUE_INTERVAL_MS = 1000; diff --git a/packages/kovan-faucets/src/ts/server.ts b/packages/kovan-faucets/src/ts/server.ts index d60363ceb..fbb9caf1e 100644 --- a/packages/kovan-faucets/src/ts/server.ts +++ b/packages/kovan-faucets/src/ts/server.ts @@ -17,10 +17,8 @@ app.use((req, res, next) => { const handler = new Handler(); app.get('/ping', (req: express.Request, res: express.Response) => { res.status(200).send('pong'); }); -app.get('/rain/:recipient', handler.dispenseEther.bind(handler)); // Deprecated gracefully app.get('/ether/:recipient', handler.dispenseEther.bind(handler)); app.get('/zrx/:recipient', handler.dispenseZRX.bind(handler)); -app.get('/queue', handler.getQueueInfo.bind(handler)); // Deprecated gracefully // Log to rollbar any errors unhandled by handlers app.use(errorReporter.errorHandler()); diff --git a/packages/kovan-faucets/src/ts/zrx_request_queue.ts b/packages/kovan-faucets/src/ts/zrx_request_queue.ts index 8971f94f0..72500789c 100644 --- a/packages/kovan-faucets/src/ts/zrx_request_queue.ts +++ b/packages/kovan-faucets/src/ts/zrx_request_queue.ts @@ -1,6 +1,6 @@ import {ZeroEx} from '0x.js'; +import {promisify} from '@0xproject/utils'; import BigNumber from 'bignumber.js'; -import promisify = require('es6-promisify'); import * as _ from 'lodash'; import * as Web3 from 'web3'; @@ -8,24 +8,19 @@ import {configs} from './configs'; import {errorReporter} from './error_reporter'; import {RequestQueue} from './request_queue'; import {utils} from './utils'; -// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang -// because they are using the wrong XHR package. -// Issue: https://github.com/trufflesuite/truffle-contract/issues/14 -delete (global as any).XMLHttpRequest; const DISPENSE_AMOUNT_ZRX = new BigNumber(0.1); const QUEUE_INTERVAL_MS = 5000; -const KOVAN_NETWORK_ID = 42; export class ZRXRequestQueue extends RequestQueue { private zeroEx: ZeroEx; constructor(web3: Web3) { super(web3); this.queueIntervalMs = QUEUE_INTERVAL_MS; - const config = { - networkId: KOVAN_NETWORK_ID, + const zeroExConfig = { + networkId: configs.KOVAN_NETWORK_ID, }; - this.zeroEx = new ZeroEx(web3.currentProvider, config); + this.zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig); } protected async processNextRequestFireAndForgetAsync(recipientAddress: string) { utils.consoleLog(`Processing ZRX ${recipientAddress}`); |