-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (38 loc) · 1.35 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
"use strict";
const green = require("chalk").green;
const inquirer = require("inquirer");
const utils = require("./utils");
const mixer = require('./mixer')
let depositAmount
function prompt() {
const depositAddress = utils.generateDepositAddress()
const houseAddress = 'TheHouse'
/* Inquirer documentation: https://github.com/SBoudrias/Inquirer.js#documentation */
inquirer.prompt([
{
name: "addresses",
message: "Please enter a comma-separated list of new, unused Jobcoin addresses where your mixed Jobcoins will be sent:"
},
{
name: "deposit",
message: `You may now send Jobcoins to address ${green(depositAddress)}. They will be mixed and sent to your destination addresses. \n Enter ${green('"y"')} to run again.`,
when: (answers) => answers.addresses
},
])
.then((answers) => {
mixer.pollNetwork(depositAddress)
.then(deposit => {
depositAmount = deposit
mixer.transferToHouse(deposit, depositAddress, houseAddress)
})
.then(response => mixer.distributeCoins(answers.addresses, houseAddress, depositAmount))
.catch(err => console.error('something went wrong: ', err))
if (answers.deposit && answers.deposit.toLowerCase() === "y") {
prompt();
}
});
}
console.log("Welcome to the Jobcoin mixer!");
prompt();
module.exports = prompt;