Skip to content

Commit

Permalink
Make wallet:address support JSON output (#5290)
Browse files Browse the repository at this point in the history
Also convert the output to a card
  • Loading branch information
NullSoldier committed Aug 15, 2024
1 parent a905072 commit caf266a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions ironfish-cli/src/commands/wallet/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { Args } from '@oclif/core'
import { IronfishCommand } from '../../command'
import { RemoteFlags } from '../../flags'
import { JsonFlags, RemoteFlags } from '../../flags'
import * as ui from '../../ui'

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

static enableJsonFlag = true

static args = {
account: Args.string({
required: false,
Expand All @@ -19,22 +22,25 @@ export class AddressCommand extends IronfishCommand {

static flags = {
...RemoteFlags,
...JsonFlags,
}

async start(): Promise<void> {
async start(): Promise<unknown> {
const { args } = await this.parse(AddressCommand)
const { account } = args

const client = await this.connectRpc()

const response = await client.wallet.getAccountPublicKey({
account: account,
account: args.account,
})

if (!response) {
this.error(`An error occurred while fetching the public key.`)
}
this.log(
ui.card({
Account: response.content.account,
Address: response.content.publicKey,
}),
)

this.log(`Account: ${response.content.account}, public key: ${response.content.publicKey}`)
return response.content
}
}

0 comments on commit caf266a

Please sign in to comment.