Skip to content

Commit caf266a

Browse files
authored
Make wallet:address support JSON output (#5290)
Also convert the output to a card
1 parent a905072 commit caf266a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

ironfish-cli/src/commands/wallet/address.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
44
import { Args } from '@oclif/core'
55
import { IronfishCommand } from '../../command'
6-
import { RemoteFlags } from '../../flags'
6+
import { JsonFlags, RemoteFlags } from '../../flags'
7+
import * as ui from '../../ui'
78

89
export class AddressCommand extends IronfishCommand {
910
static description = `show the account's public address
1011
1112
The address for an account is the accounts public key, see more here: https://ironfish.network/docs/whitepaper/5_account`
1213

14+
static enableJsonFlag = true
15+
1316
static args = {
1417
account: Args.string({
1518
required: false,
@@ -19,22 +22,25 @@ export class AddressCommand extends IronfishCommand {
1922

2023
static flags = {
2124
...RemoteFlags,
25+
...JsonFlags,
2226
}
2327

24-
async start(): Promise<void> {
28+
async start(): Promise<unknown> {
2529
const { args } = await this.parse(AddressCommand)
26-
const { account } = args
2730

2831
const client = await this.connectRpc()
2932

3033
const response = await client.wallet.getAccountPublicKey({
31-
account: account,
34+
account: args.account,
3235
})
3336

34-
if (!response) {
35-
this.error(`An error occurred while fetching the public key.`)
36-
}
37+
this.log(
38+
ui.card({
39+
Account: response.content.account,
40+
Address: response.content.publicKey,
41+
}),
42+
)
3743

38-
this.log(`Account: ${response.content.account}, public key: ${response.content.publicKey}`)
44+
return response.content
3945
}
4046
}

0 commit comments

Comments
 (0)