aboutsummaryrefslogtreecommitdiffstats
path: root/packages/testnet-faucets/src/ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/testnet-faucets/src/ts')
-rw-r--r--packages/testnet-faucets/src/ts/dispatch_queue.ts4
-rw-r--r--packages/testnet-faucets/src/ts/error_reporter.ts4
-rw-r--r--packages/testnet-faucets/src/ts/handler.ts19
-rw-r--r--packages/testnet-faucets/src/ts/server.ts24
4 files changed, 33 insertions, 18 deletions
diff --git a/packages/testnet-faucets/src/ts/dispatch_queue.ts b/packages/testnet-faucets/src/ts/dispatch_queue.ts
index b1996a0c2..0a13df7c9 100644
--- a/packages/testnet-faucets/src/ts/dispatch_queue.ts
+++ b/packages/testnet-faucets/src/ts/dispatch_queue.ts
@@ -7,8 +7,8 @@ const MAX_QUEUE_SIZE = 500;
const DEFAULT_QUEUE_INTERVAL_MS = 1000;
export class DispatchQueue {
- private _queueIntervalMs: number;
- private _queue: Array<() => Promise<void>>;
+ private readonly _queueIntervalMs: number;
+ private readonly _queue: Array<() => Promise<void>>;
private _queueIntervalIdIfExists?: NodeJS.Timer;
constructor() {
this._queueIntervalMs = DEFAULT_QUEUE_INTERVAL_MS;
diff --git a/packages/testnet-faucets/src/ts/error_reporter.ts b/packages/testnet-faucets/src/ts/error_reporter.ts
index a0abcc07b..49c37b6eb 100644
--- a/packages/testnet-faucets/src/ts/error_reporter.ts
+++ b/packages/testnet-faucets/src/ts/error_reporter.ts
@@ -12,7 +12,7 @@ export const errorReporter = {
rollbar.handleUncaughtExceptions(configs.ROLLBAR_ACCESS_KEY);
process.on('unhandledRejection', async (err: Error) => {
logUtils.log(`Uncaught exception ${err}. Stack: ${err.stack}`);
- await this.reportAsync(err);
+ await errorReporter.reportAsync(err);
process.exit(1);
});
},
@@ -20,7 +20,7 @@ export const errorReporter = {
if (configs.ENVIRONMENT === 'development') {
return; // Do not log development environment errors
}
- return new Promise((resolve, reject) => {
+ return new Promise<any>((resolve, reject) => {
rollbar.handleError(err, req, (rollbarErr: Error) => {
if (rollbarErr) {
logUtils.log(`Error reporting to rollbar, ignoring: ${rollbarErr}`);
diff --git a/packages/testnet-faucets/src/ts/handler.ts b/packages/testnet-faucets/src/ts/handler.ts
index 6d26691d6..3749bc70b 100644
--- a/packages/testnet-faucets/src/ts/handler.ts
+++ b/packages/testnet-faucets/src/ts/handler.ts
@@ -5,9 +5,12 @@ import { Provider } from 'ethereum-types';
import * as express from 'express';
import * as _ from 'lodash';
-import { NonceTrackerSubprovider, PrivateKeyWalletSubprovider } from '@0xproject/subproviders';
-import ProviderEngine = require('web3-provider-engine');
-import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
+import {
+ NonceTrackerSubprovider,
+ PrivateKeyWalletSubprovider,
+ RPCSubprovider,
+ Web3ProviderEngine,
+} from '@0xproject/subproviders';
import { configs } from './configs';
import { constants } from './constants';
@@ -34,19 +37,15 @@ enum RequestedAssetType {
const FIVE_DAYS_IN_MS = 4.32e8; // TODO: make this configurable
export class Handler {
- private _networkConfigByNetworkId: ItemByNetworkId<NetworkConfig> = {};
+ private readonly _networkConfigByNetworkId: ItemByNetworkId<NetworkConfig> = {};
private static _createProviderEngine(rpcUrl: string): Provider {
if (_.isUndefined(configs.DISPENSER_PRIVATE_KEY)) {
throw new Error('Dispenser Private key not found');
}
- const engine = new ProviderEngine();
+ const engine = new Web3ProviderEngine();
engine.addProvider(new NonceTrackerSubprovider());
engine.addProvider(new PrivateKeyWalletSubprovider(configs.DISPENSER_PRIVATE_KEY));
- engine.addProvider(
- new RpcSubprovider({
- rpcUrl,
- }),
- );
+ engine.addProvider(new RPCSubprovider(rpcUrl));
engine.start();
return engine;
}
diff --git a/packages/testnet-faucets/src/ts/server.ts b/packages/testnet-faucets/src/ts/server.ts
index 5416cdcc3..f00562000 100644
--- a/packages/testnet-faucets/src/ts/server.ts
+++ b/packages/testnet-faucets/src/ts/server.ts
@@ -24,10 +24,26 @@ app.get('/ping', (req: express.Request, res: express.Response) => {
res.status(constants.SUCCESS_STATUS).send('pong');
});
app.get('/info', handler.getQueueInfo.bind(handler));
-app.get('/ether/:recipient', parameterTransformer.transform, handler.dispenseEther.bind(handler));
-app.get('/zrx/:recipient', parameterTransformer.transform, handler.dispenseZRX.bind(handler));
-app.get('/order/weth/:recipient', parameterTransformer.transform, handler.dispenseWETHOrderAsync.bind(handler));
-app.get('/order/zrx/:recipient', parameterTransformer.transform, handler.dispenseZRXOrderAsync.bind(handler));
+app.get(
+ '/ether/:recipient',
+ parameterTransformer.transform.bind(parameterTransformer),
+ handler.dispenseEther.bind(handler),
+);
+app.get(
+ '/zrx/:recipient',
+ parameterTransformer.transform.bind(parameterTransformer),
+ handler.dispenseZRX.bind(handler),
+);
+app.get(
+ '/order/weth/:recipient',
+ parameterTransformer.transform.bind(parameterTransformer),
+ handler.dispenseWETHOrderAsync.bind(handler),
+);
+app.get(
+ '/order/zrx/:recipient',
+ parameterTransformer.transform.bind(parameterTransformer),
+ handler.dispenseZRXOrderAsync.bind(handler),
+);
// Log to rollbar any errors unhandled by handlers
app.use(errorReporter.errorHandler());