Skip to content

Commit

Permalink
cleanup from smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
rh0delta committed Aug 6, 2024
1 parent 118c5a7 commit 6dfd8b2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/accounts/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class AccountsCommand extends BaseCommand {
}

public async selectAccount (accounts: EntropyAccountConfig[]) {
const answers = await inquirer.prompt([selectAccountQuestions(accounts)])
const answers = await inquirer.prompt(selectAccountQuestions(accounts))

return { selectedAccount: answers.selectedAccount.address }
}
Expand Down Expand Up @@ -91,7 +91,7 @@ export class AccountsCommand extends BaseCommand {
public async runInteraction (config): Promise<any> {
const { accounts } = config
const { interactionChoice } = await inquirer.prompt(manageAccountsQuestions)

switch (interactionChoice) {
case 'create-account': {
const createAccountParams = await this.getUserInput()
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const ACCOUNTS_CONTENT = {
message: "Choose account:",
},
interactionChoice: {
name: 'choice',
name: 'interactionChoice',
choices: [
{ name: 'Create/Import Account', value: 'create-import' },
{ name: 'Select Account', value: 'select-account' },
Expand Down
39 changes: 37 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EntropyTuiOptions } from './types'

import { cliEntropyTransfer } from './flows/entropyTransfer/cli'
import { cliSign } from './flows/sign/cli'
import { getSelectedAccount, stringify } from './common/utils'
import { getSelectedAccount, stringify, updateConfig } from './common/utils'
import Entropy from '@entropyxyz/sdk'
import { initializeEntropy } from './common/initializeEntropy'
import { BalanceCommand } from './balance/command'
Expand Down Expand Up @@ -150,7 +150,7 @@ program.command('new-account')
)
.addOption(
new Option(
'-p, --path',
'-pa, --path',
'Derivation path'
).default(ACCOUNTS_CONTENT.path.default)
)
Expand All @@ -165,6 +165,41 @@ program.command('new-account')
process.exit(0)
})

/* register */
program.command('register')
.description('Register an entropy account with a program')
.argument('address', 'Address of existing entropy account')
.addOption(passwordOption())
.addOption(endpointOption())
.addOption(
new Option(
'-pointer, --pointer',
'Program pointer of program to be used for registering'
)
)
.addOption(
new Option(
'-data, --program-data',
'Path to file containing program data in JSON format'
)
)
.action(async (address, opts) => {
const storedConfig = await config.get()
const { accounts } = storedConfig
const accountsCommand = new AccountsCommand(entropy, opts.endpoint)
writeOut('Attempting to register account with addtess: ' + address)
const accountToRegister = getSelectedAccount(accounts, address)
if (!accountToRegister) {
throw new Error('AccountError: Unable to register non-existent account')
}
const updatedAccount = await accountsCommand.registerAccount(accountToRegister)
const arrIdx = accounts.indexOf(accountToRegister)
accounts.splice(arrIdx, 1, updatedAccount)
await updateConfig(storedConfig, { accounts, selectedAccount: updatedAccount.address })
writeOut("Your address" + updatedAccount.address + "has been successfully registered.")
process.exit(0)
})

/* balance */
program.command('balance')
.description('Get the balance of an Entropy account. Output is a number')
Expand Down

0 comments on commit 6dfd8b2

Please sign in to comment.