import inquirer from 'inquirer'; import { deposit, transact, balance } from '../script/zk.js' import { ethers } from 'ethers'; let trees; let data; export const serviceController = { error: "", balance: balance, deposit: async () => { let amountPrompt = await inquirer.prompt({ type: "input", name: "amount", message: "Enter the amount of XFT to deposit: " }) if (isNaN(amountPrompt.amount)) { let errorMsg = "No amount specified"; serviceController.error = errorMsg; console.log(errorMsg); return; } const arg = { amount: ethers.parseEther(amountPrompt.amount) }; [trees, data] = await deposit(arg); }, withdraw: async () => { let amountPrompt = await inquirer.prompt({ type: "input", name: "amount", message: "Enter the amount of XFT to withdraw: " }) if (isNaN(amountPrompt.amount)) { let errorMsg = "No amount specified"; serviceController.error = errorMsg; console.log(errorMsg); return; } const args = { amount: ethers.parseEther(amountPrompt.amount), trees: trees, data: data }; await transact(args); } } export const commandController = { 'd': serviceController.deposit, 'w': serviceController.withdraw, 'r': () => true, 'exit': process.exit }