From 3ba45760c5eee960611d9dd3859d4b22f29f1e92 Mon Sep 17 00:00:00 2001 From: mix irving Date: Fri, 28 Jun 2024 01:46:12 +1200 Subject: [PATCH] remove duplicate file (#145) --- src/index.ts | 90 ---------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 src/index.ts diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 4dcfcf70..00000000 --- a/src/index.ts +++ /dev/null @@ -1,90 +0,0 @@ -import inquirer from 'inquirer' -import * as config from './config' -import * as flows from './flows' -import { EntropyTuiOptions } from './types' -import { logo } from './common/ascii' -import { debug, print } from './common/utils' - -// tui = text user interface -export default async function tui (options: EntropyTuiOptions) { - await config.init() - - console.clear() - console.log(logo) // the Entropy logo - debug(options) - - const choices = { - 'Manage Accounts': flows.manageAccounts, - 'Balance': flows.checkBalance, - 'Register': flows.register, - 'Sign': flows.sign, - 'Transfer': flows.entropyTransfer, - 'Deploy Program': flows.devPrograms, - 'User Programs': flows.userPrograms, - // 'Construct an Ethereum Tx': flows.ethTransaction, - } - - const devChoices = { - // 'Entropy Faucet': flows.entropyFaucet, - } - - if (options.dev) Object.assign(choices, devChoices) - - // assign exit so its last - Object.assign(choices, { 'Exit': async () => {} }) - - main(choices, options) -} - -async function main (choices, options) { - let storedConfig = await config.get() - - // if there are accounts available and selected account is not set, - // first account in list is set as the selected account - if (!storedConfig.selectedAccount && storedConfig.accounts.length) { - await config.set({ ...storedConfig, ...{ selectedAccount: storedConfig.accounts[0].address } }) - storedConfig = await config.get() - } - - const answers = await inquirer.prompt([{ - type: 'list', - name: 'choice', - message: 'Select Action', - pageSize: Object.keys(choices).length, - choices: Object.keys(choices), - }]) - - if (answers.choice === 'Exit') { - print('Have a nice day') - process.exit() - } - - let returnToMain: boolean | undefined = undefined; - - if (!storedConfig.selectedAccount && answers.choice !== 'Manage Accounts') { - console.error('There are currently no accounts available, please create or import your new account using the Manage Accounts feature') - } else { - debug(answers) - const newConfigUpdates = await choices[answers.choice](storedConfig, options) - if (typeof newConfigUpdates === 'string' && newConfigUpdates === 'exit') { - returnToMain = true - } else { - await config.set({ ...storedConfig, ...newConfigUpdates }) - } - storedConfig = await config.get() - } - - if (!returnToMain) { - ({ returnToMain } = await inquirer.prompt([{ - type: 'confirm', - name: 'returnToMain', - message: 'Return to main menu?' - }])) - } - - if (returnToMain) main(choices, options) - else { - print('Have a nice day') - process.exit() - } -}