aboutsummaryrefslogtreecommitdiffstats
path: root/packages/kovan-faucets/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/kovan-faucets/src')
-rw-r--r--packages/kovan-faucets/src/ts/error_reporter.ts9
-rw-r--r--packages/kovan-faucets/src/ts/ether_request_queue.ts7
-rw-r--r--packages/kovan-faucets/src/ts/handler.ts19
-rw-r--r--packages/kovan-faucets/src/ts/id_management.ts3
-rw-r--r--packages/kovan-faucets/src/ts/request_queue.ts3
-rw-r--r--packages/kovan-faucets/src/ts/server.ts3
-rw-r--r--packages/kovan-faucets/src/ts/utils.ts2
-rw-r--r--packages/kovan-faucets/src/ts/zrx_request_queue.ts15
8 files changed, 38 insertions, 23 deletions
diff --git a/packages/kovan-faucets/src/ts/error_reporter.ts b/packages/kovan-faucets/src/ts/error_reporter.ts
index 74e99da15..db21647c0 100644
--- a/packages/kovan-faucets/src/ts/error_reporter.ts
+++ b/packages/kovan-faucets/src/ts/error_reporter.ts
@@ -1,9 +1,10 @@
-import * as fs from 'fs';
import * as express from 'express';
-import {utils} from './utils';
-import {configs} from './configs';
+import * as fs from 'fs';
import rollbar = require('rollbar');
+import {configs} from './configs';
+import {utils} from './utils';
+
export const errorReporter = {
setup() {
rollbar.init(configs.ROLLBAR_ACCESS_KEY, {
@@ -18,7 +19,7 @@ export const errorReporter = {
process.exit(1);
});
},
- reportAsync(err: Error, req?: express.Request): Promise<any> {
+ async reportAsync(err: Error, req?: express.Request): Promise<any> {
if (configs.ENVIRONMENT === 'development') {
return; // Do not log development environment errors
}
diff --git a/packages/kovan-faucets/src/ts/ether_request_queue.ts b/packages/kovan-faucets/src/ts/ether_request_queue.ts
index 663f98082..b1648ca28 100644
--- a/packages/kovan-faucets/src/ts/ether_request_queue.ts
+++ b/packages/kovan-faucets/src/ts/ether_request_queue.ts
@@ -1,9 +1,10 @@
-import * as _ from 'lodash';
import promisify = require('es6-promisify');
-import {utils} from './utils';
+import * as _ from 'lodash';
+
import {configs} from './configs';
-import {RequestQueue} from './request_queue';
import {errorReporter} from './error_reporter';
+import {RequestQueue} from './request_queue';
+import {utils} from './utils';
const DISPENSE_AMOUNT_ETHER = 0.1;
diff --git a/packages/kovan-faucets/src/ts/handler.ts b/packages/kovan-faucets/src/ts/handler.ts
index 460008e93..f3c6ba1f0 100644
--- a/packages/kovan-faucets/src/ts/handler.ts
+++ b/packages/kovan-faucets/src/ts/handler.ts
@@ -1,15 +1,17 @@
-import * as _ from 'lodash';
import * as express from 'express';
-import {EtherRequestQueue} from './ether_request_queue';
-import {ZRXRequestQueue} from './zrx_request_queue';
-import {configs} from './configs';
-import {utils} from './utils';
+import * as _ from 'lodash';
+import * as Web3 from 'web3';
import ProviderEngine = require('web3-provider-engine');
-import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
-import NonceSubprovider = require('web3-provider-engine/subproviders/nonce-tracker');
import HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet');
+import NonceSubprovider = require('web3-provider-engine/subproviders/nonce-tracker');
+import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
+
+import {configs} from './configs';
+import {EtherRequestQueue} from './ether_request_queue';
import {idManagement} from './id_management';
-import * as Web3 from 'web3';
+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
@@ -71,6 +73,7 @@ export class Handler {
});
res.status(200).send(payload);
}
+ // tslint:disable-next-line:prefer-function-over-method
private createProviderEngine(rpcUrl: string) {
const engine = new ProviderEngine();
engine.addProvider(new NonceSubprovider());
diff --git a/packages/kovan-faucets/src/ts/id_management.ts b/packages/kovan-faucets/src/ts/id_management.ts
index 838650be0..2090ce58a 100644
--- a/packages/kovan-faucets/src/ts/id_management.ts
+++ b/packages/kovan-faucets/src/ts/id_management.ts
@@ -1,6 +1,7 @@
-import {configs} from './configs';
import * as EthereumTx from 'ethereumjs-tx';
+import {configs} from './configs';
+
type Callback = (err: Error, accounts: any) => void;
export const idManagement = {
diff --git a/packages/kovan-faucets/src/ts/request_queue.ts b/packages/kovan-faucets/src/ts/request_queue.ts
index 301aec8d5..98e8e381a 100644
--- a/packages/kovan-faucets/src/ts/request_queue.ts
+++ b/packages/kovan-faucets/src/ts/request_queue.ts
@@ -41,12 +41,15 @@ export class RequestQueue {
return;
}
const recipientAddress = this.queue.shift();
+ // tslint:disable-next-line:no-floating-promises
this.processNextRequestFireAndForgetAsync(recipientAddress);
+
}, this.queueIntervalMs);
}
protected stop() {
clearInterval(this.queueIntervalId);
}
+ // tslint:disable-next-line:prefer-function-over-method
protected async processNextRequestFireAndForgetAsync(recipientAddress: string) {
throw new Error('Expected processNextRequestFireAndForgetAsync to be implemented by a superclass');
}
diff --git a/packages/kovan-faucets/src/ts/server.ts b/packages/kovan-faucets/src/ts/server.ts
index 0ae10e556..d60363ceb 100644
--- a/packages/kovan-faucets/src/ts/server.ts
+++ b/packages/kovan-faucets/src/ts/server.ts
@@ -1,7 +1,8 @@
import * as bodyParser from 'body-parser';
import * as express from 'express';
-import {Handler} from './handler';
+
import {errorReporter} from './error_reporter';
+import {Handler} from './handler';
// Setup the errorReporter to catch uncaught exceptions and unhandled rejections
errorReporter.setup();
diff --git a/packages/kovan-faucets/src/ts/utils.ts b/packages/kovan-faucets/src/ts/utils.ts
index fd9630b76..6a0b262e6 100644
--- a/packages/kovan-faucets/src/ts/utils.ts
+++ b/packages/kovan-faucets/src/ts/utils.ts
@@ -1,5 +1,5 @@
-import * as _ from 'lodash';
import * as express from 'express';
+import * as _ from 'lodash';
export const utils = {
consoleLog(message: string) {
diff --git a/packages/kovan-faucets/src/ts/zrx_request_queue.ts b/packages/kovan-faucets/src/ts/zrx_request_queue.ts
index e66a2b300..8971f94f0 100644
--- a/packages/kovan-faucets/src/ts/zrx_request_queue.ts
+++ b/packages/kovan-faucets/src/ts/zrx_request_queue.ts
@@ -1,12 +1,13 @@
-import * as _ from 'lodash';
import {ZeroEx} from '0x.js';
import BigNumber from 'bignumber.js';
import promisify = require('es6-promisify');
-import {utils} from './utils';
+import * as _ from 'lodash';
+import * as Web3 from 'web3';
+
import {configs} from './configs';
-import {RequestQueue} from './request_queue';
import {errorReporter} from './error_reporter';
-import * as Web3 from 'web3';
+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
@@ -14,13 +15,17 @@ 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;
- this.zeroEx = new ZeroEx(web3.currentProvider);
+ const config = {
+ networkId: KOVAN_NETWORK_ID,
+ };
+ this.zeroEx = new ZeroEx(web3.currentProvider, config);
}
protected async processNextRequestFireAndForgetAsync(recipientAddress: string) {
utils.consoleLog(`Processing ZRX ${recipientAddress}`);