Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NayNay] File Restructure: Base Class + Balance Restructure #207

Merged
merged 16 commits into from
Aug 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
little cleanup
rh0delta committed Aug 1, 2024
commit 423631c279c87da91c0a856acf1402bf352ecd88
5 changes: 4 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@ import { initializeEntropy } from './common/initializeEntropy'
import { BalanceCommand } from './balance/command'

const program = new Command()
// Array of restructured commands to make it easier to migrate them to the new "flow"
const RESTRUCTURED_COMMANDS = ['balance']

function endpointOption (){
return new Option(
@@ -99,7 +101,8 @@ program
.hook('preAction', async (_thisCommand, actionCommand) => {
if (!entropy || (entropy.keyring.accounts.registration.address !== actionCommand.args[0] || entropy.keyring.accounts.registration.address !== actionCommand.opts().account)) {
// balance includes an address argument, use that address to instantiate entropy
if (actionCommand.name() === 'balance' && actionCommand.args.length) {
// can keep the conditional to check for length of args, and use the first index since it is our pattern to have the address as the first argument
if (RESTRUCTURED_COMMANDS.includes(actionCommand.name()) && actionCommand.args.length) {
await loadEntropy(actionCommand.args[0], actionCommand.opts().endpoint, actionCommand.opts().password)
} else {
// if address is not an argument, use the address from the option