From caf266ac548f3a2460728b2aa3ad1b111bce8f85 Mon Sep 17 00:00:00 2001 From: Jason Spafford Date: Thu, 15 Aug 2024 14:53:52 -0700 Subject: [PATCH] Make wallet:address support JSON output (#5290) Also convert the output to a card --- ironfish-cli/src/commands/wallet/address.ts | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ironfish-cli/src/commands/wallet/address.ts b/ironfish-cli/src/commands/wallet/address.ts index 8815793fea..4a42444f5f 100644 --- a/ironfish-cli/src/commands/wallet/address.ts +++ b/ironfish-cli/src/commands/wallet/address.ts @@ -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, @@ -19,22 +22,25 @@ export class AddressCommand extends IronfishCommand { static flags = { ...RemoteFlags, + ...JsonFlags, } - async start(): Promise { + async start(): Promise { 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 } }