aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2017-12-13 09:18:15 +0800
committerBrandon Millman <brandon.millman@gmail.com>2017-12-14 04:36:29 +0800
commit91f276d9254bba3d93fc821c4fadab2eb6fc1d65 (patch)
tree9c33a09f44f06d5f9b45da74e027012cf4dfbbb6
parent1e9f23ebba5e0729b64e757d6901205278871e9f (diff)
downloaddexon-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
-rw-r--r--packages/contracts/package.json2
-rw-r--r--packages/kovan-faucets/README.md10
-rw-r--r--packages/kovan-faucets/package.json8
-rw-r--r--packages/kovan-faucets/src/ts/configs.ts3
-rw-r--r--packages/kovan-faucets/src/ts/ether_request_queue.ts2
-rw-r--r--packages/kovan-faucets/src/ts/global.d.ts17
-rw-r--r--packages/kovan-faucets/src/ts/handler.ts5
-rw-r--r--packages/kovan-faucets/src/ts/id_management.ts11
-rw-r--r--packages/kovan-faucets/src/ts/request_queue.ts4
-rw-r--r--packages/kovan-faucets/src/ts/server.ts2
-rw-r--r--packages/kovan-faucets/src/ts/zrx_request_queue.ts13
-rw-r--r--yarn.lock8
12 files changed, 37 insertions, 48 deletions
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index f4d0b5865..93f28f990 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -54,7 +54,7 @@
"yargs": "^10.0.3"
},
"dependencies": {
- "0x.js": "^0.27.1",
+ "0x.js": "~0.27.2",
"@0xproject/json-schemas": "^0.6.10",
"@0xproject/utils": "^0.1.0",
"@0xproject/web3-wrapper": "^0.1.0",
diff --git a/packages/kovan-faucets/README.md b/packages/kovan-faucets/README.md
index b372c8b15..8903440e3 100644
--- a/packages/kovan-faucets/README.md
+++ b/packages/kovan-faucets/README.md
@@ -21,8 +21,11 @@ export FAUCET_ENVIRONMENT=development
export DISPENSER_ADDRESS=0x5409ed021d9299bf6814279a6a1411a7e866a631
export DISPENSER_PRIVATE_KEY=f2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d
export FAUCET_ROLLBAR_ACCESS_KEY={GET_THIS_FROM_ROLLBAR_ACCOUNT_SETTINGS}
+export INFURA_API_KEY={GET_THIS_FROM_INFURA}
```
+Infura API Key can be requested here: https://infura.io/register.html
+
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`.
```
@@ -31,13 +34,14 @@ npm run dev
## Endpoints
-```GET /rain/:recipient_address```
+```GET /ether/:recipient```
Where recipient_address is a hex encoded Ethereum address prefixed with `0x`.
-```GET /queue```
+```GET /zrx/:recipient```
+
+Where recipient_address is a hex encoded Ethereum address prefixed with `0x`.
-Returns the status of the queue
```javascript
{
diff --git a/packages/kovan-faucets/package.json b/packages/kovan-faucets/package.json
index b4fe84b86..378cd2613 100644
--- a/packages/kovan-faucets/package.json
+++ b/packages/kovan-faucets/package.json
@@ -1,6 +1,6 @@
{
"private": true,
- "name": "@0xproject/token-and-ether-faucet",
+ "name": "@0xproject/kovan_faucets",
"version": "1.0.0",
"description": "A faucet micro-service that dispenses test ERC20 tokens or Ether",
"main": "server.js",
@@ -8,16 +8,16 @@
"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 --project src/**/*.ts",
+ "lint": "tslint --project . 'src/**/*.ts'",
"clean": "shx rm -rf bin"
},
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
+ "@0xproject/utils": "^0.1.0",
"0x.js": "~0.27.2",
"bignumber.js": "~4.1.0",
"body-parser": "^1.17.1",
- "es6-promisify": "^5.0.0",
"ethereumjs-tx": "^1.3.3",
"express": "^4.15.2",
"lodash": "^4.17.4",
@@ -34,7 +34,7 @@
"gulp": "^3.9.1",
"nodemon": "^1.11.0",
"shx": "^0.2.2",
- "source-map-loader": "^0.2.0",
+ "source-map-loader": "^0.1.6",
"tslint": "5.8.0",
"typescript": "~2.6.1",
"web3-typescript-typings": "^0.7.2",
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}`);
diff --git a/yarn.lock b/yarn.lock
index 6e37cdb30..83887c3ba 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8203,14 +8203,6 @@ source-map-loader@^0.1.6:
loader-utils "~0.2.2"
source-map "~0.1.33"
-source-map-loader@^0.2.0:
- version "0.2.3"
- resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-0.2.3.tgz#d4b0c8cd47d54edce3e6bfa0f523f452b5b0e521"
- dependencies:
- async "^2.5.0"
- loader-utils "~0.2.2"
- source-map "~0.6.1"
-
source-map-resolve@^0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.1.tgz#7ad0f593f2281598e854df80f19aae4b92d7a11a"