Skip to content

Commit

Permalink
fix bugs: no initial account, missing ProgramInfo interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mixmix committed Sep 22, 2024
1 parent cd5bf20 commit 33ae44e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ program
.addCommand(entropyTransferCommand())
.addCommand(entropySignCommand())
.addCommand(entropyProgramCommand())
.action(async (options: EntropyTuiOptions) => {
const { account, endpoint } = options
const entropy = await loadEntropy(account, endpoint)
launchTui(entropy, options)
.action(async (opts: EntropyTuiOptions) => {
const { account, endpoint } = opts
const entropy = account
? await loadEntropy(account, endpoint)
: undefined
// NOTE: on initial startup you have no account
launchTui(entropy, opts)
})

program.parseAsync().then(() => {})
2 changes: 1 addition & 1 deletion src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function accountChoicesWithOther (accounts: EntropyAccountConfig[]) {
}

export function findAccountByAddressOrName (accounts: EntropyAccountConfig[], aliasOrAddress: string) {
if (!aliasOrAddress || !aliasOrAddress.length) throw Error('aliasOrAddress required')
if (!aliasOrAddress || !aliasOrAddress.length) throw Error('account name or address required')

return (
accounts.find(account => account.address === aliasOrAddress) ||
Expand Down
2 changes: 2 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ export function getSync (configPath = CONFIG_PATH): EntropyConfig {
const configBuffer = readFileSync(configPath, 'utf8')
return deserialize(configBuffer)
} catch (err) {
console.log('CODE', err.code)
if (err.code !== 'ENOENT') throw err

const newConfig = migrateData(allMigrations, {})
mkdirp.sync(dirname(configPath))
writeFileSync(configPath, serialize(newConfig))
return newConfig
}
Expand Down
2 changes: 1 addition & 1 deletion src/program/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class EntropyProgram extends EntropyBase {
)
}

async get (programPointer: string) {
async get (programPointer: string): Promise<any> {
this.logger.debug(`program pointer: ${programPointer}`, `${FLOW_CONTEXT}::PROGRAM_PRESENCE_CHECK`);
return this.entropy.programs.dev.getProgramInfo(programPointer)
}
Expand Down

0 comments on commit 33ae44e

Please sign in to comment.