mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-10-01 01:06:17 -04:00
almost fix cli
This commit is contained in:
parent
2a050e1d8a
commit
efe89a0b58
75
cli.js
75
cli.js
@ -12,7 +12,6 @@ const websnarkUtils = require('websnark/src/utils');
|
|||||||
|
|
||||||
let web3, mixer, circuit, proving_key, groth16;
|
let web3, mixer, circuit, proving_key, groth16;
|
||||||
let MERKLE_TREE_HEIGHT, AMOUNT, EMPTY_ELEMENT;
|
let MERKLE_TREE_HEIGHT, AMOUNT, EMPTY_ELEMENT;
|
||||||
|
|
||||||
const inBrowser = (typeof window !== "undefined");
|
const inBrowser = (typeof window !== "undefined");
|
||||||
|
|
||||||
function createDeposit(nullifier, secret) {
|
function createDeposit(nullifier, secret) {
|
||||||
@ -121,36 +120,46 @@ Example:
|
|||||||
process.exit(code);
|
process.exit(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const args = process.argv.slice(2);
|
if (inBrowser) {
|
||||||
// if (args.length === 0) {
|
window.deposit = deposit;
|
||||||
// printHelp();
|
window.withdraw = async () => {
|
||||||
// } else {
|
const note = prompt("Enter the note to withdraw");
|
||||||
// switch (args[0]) {
|
const receiver = (await web3.eth.getAccounts())[0];
|
||||||
// case 'deposit':
|
await withdraw(note, receiver);
|
||||||
// if (args.length === 1)
|
};
|
||||||
// await init(); // then...
|
init();
|
||||||
// deposit().then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)});
|
} else {
|
||||||
// else
|
const args = process.argv.slice(2);
|
||||||
// printHelp(1);
|
if (args.length === 0) {
|
||||||
// break;
|
printHelp();
|
||||||
//
|
} else {
|
||||||
// case 'withdraw':
|
switch (args[0]) {
|
||||||
// if (args.length === 3 && /^0x[0-9a-fA-F]{128}$/.test(args[1]) && /^0x[0-9a-fA-F]{40}$/.test(args[2]))
|
case 'deposit':
|
||||||
// await init(); // then...
|
if (args.length === 1) {
|
||||||
// withdraw(args[1], args[2]).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)});
|
await init(); // then...
|
||||||
// else
|
deposit().then(() => process.exit(0)).catch(err => {
|
||||||
// printHelp(1);
|
console.log(err);
|
||||||
// break;
|
process.exit(1)
|
||||||
//
|
});
|
||||||
// default:
|
}
|
||||||
// printHelp(1);
|
else
|
||||||
// }
|
printHelp(1);
|
||||||
// }
|
break;
|
||||||
|
|
||||||
window.deposit = deposit;
|
case 'withdraw':
|
||||||
window.withdraw = async () => {
|
if (args.length === 3 && /^0x[0-9a-fA-F]{128}$/.test(args[1]) && /^0x[0-9a-fA-F]{40}$/.test(args[2])) {
|
||||||
const note = prompt("Enter the note to withdraw");
|
await init(); // then...
|
||||||
const receiver = (await web3.eth.getAccounts())[0];
|
withdraw(args[1], args[2]).then(() => process.exit(0)).catch(err => {
|
||||||
await withdraw(note, receiver);
|
console.log(err);
|
||||||
};
|
process.exit(1)
|
||||||
init();
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printHelp(1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printHelp(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user