Skip to content

Commit

Permalink
Add check for signer or registered account (#7098)
Browse files Browse the repository at this point in the history
# Description
- Add a check that an address is a signer or registered account when running `account:show`
- Add a helpful warning message for if this check fails 

# Related issues
- Partially addresses #7091
  • Loading branch information
eelanagaraj authored Feb 12, 2021
1 parent 52e6b62 commit aad23dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/cli/src/commands/account/show.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseCommand } from '../../base'
import { newCheckBuilder } from '../../utils/checks'
import { printValueMapRecursive } from '../../utils/cli'
import { Args } from '../../utils/command'

Expand All @@ -16,7 +17,9 @@ export default class Show extends BaseCommand {

async run() {
const { args } = this.parse(Show)

await newCheckBuilder(this, args.address)
.isSignerOrAccount()
.runChecks()
const accounts = await this.kit.contracts.getAccounts()
const address = await accounts.signerToAccount(args.address)
printValueMapRecursive(await accounts.getAccountSummary(address))
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/utils/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ class CheckBuilder {
const res =
(await accounts.isAccount(this.signer!)) || (await accounts.isSigner(this.signer!))
return res
})
}),
`${this.signer} is not a signer or registered as an account. Try authorizing as a signer or running account:register.`
)

isVoteSignerOrAccount = () =>
Expand Down

0 comments on commit aad23dd

Please sign in to comment.