diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2017-12-13 05:06:02 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2017-12-13 07:56:30 +0800 |
commit | 1e9f23ebba5e0729b64e757d6901205278871e9f (patch) | |
tree | ad768a48539ebaa66f0c852f4d9a2183cbbcb2ce /packages/kovan-faucets | |
parent | bbb768c5cfa8bf713670608f859debae42b42898 (diff) | |
download | dexon-sol-tools-1e9f23ebba5e0729b64e757d6901205278871e9f.tar dexon-sol-tools-1e9f23ebba5e0729b64e757d6901205278871e9f.tar.gz dexon-sol-tools-1e9f23ebba5e0729b64e757d6901205278871e9f.tar.bz2 dexon-sol-tools-1e9f23ebba5e0729b64e757d6901205278871e9f.tar.lz dexon-sol-tools-1e9f23ebba5e0729b64e757d6901205278871e9f.tar.xz dexon-sol-tools-1e9f23ebba5e0729b64e757d6901205278871e9f.tar.zst dexon-sol-tools-1e9f23ebba5e0729b64e757d6901205278871e9f.zip |
Fix build errors
Diffstat (limited to 'packages/kovan-faucets')
-rw-r--r-- | packages/kovan-faucets/README.md | 2 | ||||
-rw-r--r-- | packages/kovan-faucets/gulpfile.js | 16 | ||||
-rw-r--r-- | packages/kovan-faucets/package.json | 21 | ||||
-rw-r--r-- | packages/kovan-faucets/scripts/postpublish.js | 14 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/error_reporter.ts | 9 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/ether_request_queue.ts | 7 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/handler.ts | 19 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/id_management.ts | 3 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/request_queue.ts | 3 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/server.ts | 3 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/utils.ts | 2 | ||||
-rw-r--r-- | packages/kovan-faucets/src/ts/zrx_request_queue.ts | 15 | ||||
-rw-r--r-- | packages/kovan-faucets/tsconfig.json | 11 |
13 files changed, 60 insertions, 65 deletions
diff --git a/packages/kovan-faucets/README.md b/packages/kovan-faucets/README.md index 72c1368fb..b372c8b15 100644 --- a/packages/kovan-faucets/README.md +++ b/packages/kovan-faucets/README.md @@ -25,8 +25,6 @@ export FAUCET_ROLLBAR_ACCESS_KEY={GET_THIS_FROM_ROLLBAR_ACCOUNT_SETTINGS} Note: The above public/private keys exist when running `testrpc` with the following option `--mnemonic concert load couple harbor equip island argue ramp clarify fence smart topic`. -The real production key with kovan ETH exist in 1password - ``` npm run dev ``` diff --git a/packages/kovan-faucets/gulpfile.js b/packages/kovan-faucets/gulpfile.js index 3e80e656e..773faf33a 100644 --- a/packages/kovan-faucets/gulpfile.js +++ b/packages/kovan-faucets/gulpfile.js @@ -3,19 +3,11 @@ const nodemon = require('nodemon'); const path = require('path'); const webpack = require('webpack'); const fs = require('fs'); - -const nodeModules = {}; -fs.readdirSync('node_modules') - .filter(function(x) { - return ['.bin'].indexOf(x) === -1; - }) - .forEach(function(mod) { - nodeModules[mod] = 'commonjs ' + mod; - }); +const nodeExternals = require('webpack-node-externals'); const config = { target: 'node', - entry: ['./src/ts/server.ts'], + entry: [path.join(__dirname, '/src/ts/server.ts')], output: { path: path.join(__dirname, '/bin'), filename: 'server.js', @@ -51,7 +43,9 @@ const config = { entryOnly: false, }), ], - externals: nodeModules, + externals: nodeExternals({ + modulesDir: path.join(__dirname, '../../node_modules') + }), watchOptions: { ignored: /bin|node_modules|transpiled/ }, diff --git a/packages/kovan-faucets/package.json b/packages/kovan-faucets/package.json index db1e1675d..b4fe84b86 100644 --- a/packages/kovan-faucets/package.json +++ b/packages/kovan-faucets/package.json @@ -1,23 +1,24 @@ { - "name": "@0xproject/erc20-token-faucet", + "private": true, + "name": "@0xproject/token-and-ether-faucet", "version": "1.0.0", - "description": "A faucet micro-service that dispenses test ERC20 tokens", + "description": "A faucet micro-service that dispenses test ERC20 tokens or Ether", "main": "server.js", "scripts": { "build": "node ../../node_modules/gulp/bin/gulp.js build", "dev": "node ../../node_modules/gulp/bin/gulp.js run", "start": "node ./bin/server.js", - "lint": "tslint src/**/*.ts", + "lint": "tslint --project src/**/*.ts", "clean": "shx rm -rf bin" }, "author": "Fabio Berger", "license": "Apache-2.0", "dependencies": { - "0x.js": "~0.25.1", + "0x.js": "~0.27.2", "bignumber.js": "~4.1.0", "body-parser": "^1.17.1", "es6-promisify": "^5.0.0", - "ethereumjs-tx": "^1.2.5", + "ethereumjs-tx": "^1.3.3", "express": "^4.15.2", "lodash": "^4.17.4", "rollbar": "^0.6.5", @@ -25,11 +26,10 @@ "web3-provider-engine": "^13.0.1" }, "devDependencies": { - "@0xproject/tslint-config": "^0.1.0", + "@0xproject/tslint-config": "^0.2.1", "@types/body-parser": "^1.16.1", - "@types/es6-promise": "^0.0.33", "@types/express": "^4.0.35", - "@types/lodash": "^4.14.57", + "@types/lodash": "^4.14.86", "awesome-typescript-loader": "^3.1.3", "gulp": "^3.9.1", "nodemon": "^1.11.0", @@ -37,7 +37,8 @@ "source-map-loader": "^0.2.0", "tslint": "5.8.0", "typescript": "~2.6.1", - "web3-typescript-typings": "^0.7.1", - "webpack": "^3.1.0" + "web3-typescript-typings": "^0.7.2", + "webpack": "^3.1.0", + "webpack-node-externals": "^1.6.0" } } diff --git a/packages/kovan-faucets/scripts/postpublish.js b/packages/kovan-faucets/scripts/postpublish.js deleted file mode 100644 index 7fa452b08..000000000 --- a/packages/kovan-faucets/scripts/postpublish.js +++ /dev/null @@ -1,14 +0,0 @@ -const postpublish_utils = require('../../../scripts/postpublish_utils'); -const packageJSON = require('../package.json'); - -const subPackageName = packageJSON.name; - -postpublish_utils.getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch (function(err) { - throw err; - }); 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}`); diff --git a/packages/kovan-faucets/tsconfig.json b/packages/kovan-faucets/tsconfig.json index 4e995704a..6b14a6f6b 100644 --- a/packages/kovan-faucets/tsconfig.json +++ b/packages/kovan-faucets/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { - "outDir": "./transpiled/", - "sourceMap": true, - "noImplicitAny": true, "module": "commonjs", "target": "es5", - "baseUrl": "./src/", - "types": [ "body-parser", "es6-promise", "express", "lodash" ] + "lib": [ "es2015", "dom" ], + "outDir": "lib", + "sourceMap": true, + "declaration": true, + "noImplicitAny": true, + "experimentalDecorators": true, }, "include": [ "../../node_modules/web3-typescript-typings/index.d.ts", |