3
3
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
4
import { Args } from '@oclif/core'
5
5
import { IronfishCommand } from '../../command'
6
- import { RemoteFlags } from '../../flags'
6
+ import { JsonFlags , RemoteFlags } from '../../flags'
7
+ import * as ui from '../../ui'
7
8
8
9
export class AddressCommand extends IronfishCommand {
9
10
static description = `show the account's public address
10
11
11
12
The address for an account is the accounts public key, see more here: https://ironfish.network/docs/whitepaper/5_account`
12
13
14
+ static enableJsonFlag = true
15
+
13
16
static args = {
14
17
account : Args . string ( {
15
18
required : false ,
@@ -19,22 +22,25 @@ export class AddressCommand extends IronfishCommand {
19
22
20
23
static flags = {
21
24
...RemoteFlags ,
25
+ ...JsonFlags ,
22
26
}
23
27
24
- async start ( ) : Promise < void > {
28
+ async start ( ) : Promise < unknown > {
25
29
const { args } = await this . parse ( AddressCommand )
26
- const { account } = args
27
30
28
31
const client = await this . connectRpc ( )
29
32
30
33
const response = await client . wallet . getAccountPublicKey ( {
31
- account : account ,
34
+ account : args . account ,
32
35
} )
33
36
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
+ )
37
43
38
- this . log ( `Account: ${ response . content . account } , public key: ${ response . content . publicKey } ` )
44
+ return response . content
39
45
}
40
46
}
0 commit comments