-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
executable file
·58 lines (48 loc) · 1.95 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env node
var prompt = require('prompt');
var program = require("commander");
var chalk = require("chalk");
// Command Line Flags
program
.option('-m, --mode <mode>', "The mode to start decypher in [local, remote]")
.option('-e, --endpoint <endpoint>', "The endpoint for your node to connect to http://...")
.parse(process.argv)
switch(program.mode) {
case "local":
console.log(chalk.bold.cyan(`Starting Decypher...`));
global.solc = require('solc');
global.EthTx = require('ethereumjs-tx');
global.EthUtil = require('ethereumjs-util');
global.fs = require("fs");
global.Web3 = require("web3");
global.SolidityFunction = require("web3/lib/web3/function");
global.web3 = new Web3(new Web3.providers.HttpProvider(`${program.endpoint}`))
global.acct1 = web3.eth.accounts[0];
global.acct2 = web3.eth.accounts[1];
global.acct3 = web3.eth.accounts[2];
global.acct4 = web3.eth.accounts[3];
global.acct5 = web3.eth.accounts[4];
var Decypher = require("./src/local");
global.decypher = new Decypher({ web3: global.web3 });
require('repl').start({});
break;
case "remote":
prompt.start();
prompt.get([{name: 'privateKey', hidden: true}], (error, result) => {
console.log(chalk.bold.cyan(`Starting Decypher...`));
global.solc = require('solc');
global.EthTx = require('ethereumjs-tx');
global.EthUtil = require('ethereumjs-util');
global.fs = require("fs");
global.Web3 = require("web3");
global.SolidityFunction = require("web3/lib/web3/function");
global.web3 = new Web3(new Web3.providers.HttpProvider(`${program.endpoint}`))
var Decypher = require("./src/remote");
global.decypher = new Decypher({ privateKey: result.privateKey, web3: global.web3 });
require('repl').start({});
})
break;
default:
console.log(chalk.red(`Unknown Mode: '${decypher.program.mode}' - Valid modes are [local, remote]`))
break;
}