diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2017-11-21 05:12:15 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2017-12-13 07:45:22 +0800 |
commit | bbb768c5cfa8bf713670608f859debae42b42898 (patch) | |
tree | 40ae6f11995fa44a1ee58092a8308faac63abec4 /packages/kovan-faucets/src/ts/ether_request_queue.ts | |
parent | 5678196706a63d27fc5b00b5224c8213510e76f0 (diff) | |
download | dexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.tar.gz dexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.tar.zst dexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.zip |
Add kovan faucet project into the mono repo
Diffstat (limited to 'packages/kovan-faucets/src/ts/ether_request_queue.ts')
-rw-r--r-- | packages/kovan-faucets/src/ts/ether_request_queue.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/kovan-faucets/src/ts/ether_request_queue.ts b/packages/kovan-faucets/src/ts/ether_request_queue.ts new file mode 100644 index 000000000..663f98082 --- /dev/null +++ b/packages/kovan-faucets/src/ts/ether_request_queue.ts @@ -0,0 +1,26 @@ +import * as _ from 'lodash'; +import promisify = require('es6-promisify'); +import {utils} from './utils'; +import {configs} from './configs'; +import {RequestQueue} from './request_queue'; +import {errorReporter} from './error_reporter'; + +const DISPENSE_AMOUNT_ETHER = 0.1; + +export class EtherRequestQueue extends RequestQueue { + protected async processNextRequestFireAndForgetAsync(recipientAddress: string) { + utils.consoleLog(`Processing ETH ${recipientAddress}`); + const sendTransactionAsync = promisify(this.web3.eth.sendTransaction); + try { + const txHash = await sendTransactionAsync({ + from: configs.DISPENSER_ADDRESS, + to: recipientAddress, + value: this.web3.toWei(DISPENSE_AMOUNT_ETHER, 'ether'), + }); + utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ETHER} ETH to ${recipientAddress} tx: ${txHash}`); + } catch (err) { + utils.consoleLog(`Unexpected err: ${err} - ${JSON.stringify(err)}`); + await errorReporter.reportAsync(err); + } + } +} |