Cleanup kovan-faucet package
This commit is contained in:
parent
1e9f23ebba
commit
91f276d925
@ -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",
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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",
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import promisify = require('es6-promisify');
|
||||
import {promisify} from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import {configs} from './configs';
|
||||
|
17
packages/kovan-faucets/src/ts/global.d.ts
vendored
17
packages/kovan-faucets/src/ts/global.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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')}`;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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}`);
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user