Skip to content

Commit a2740dc

Browse files
authored
feat(cli): Check if the wallet is unlocked in wallet CLI commands (#5358)
1 parent 22db8b3 commit a2740dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+118
-31
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class AddressCommand extends IronfishCommand {
2929
const { args } = await this.parse(AddressCommand)
3030

3131
const client = await this.connectRpc()
32+
await ui.checkWalletUnlocked(client)
3233

3334
const response = await client.wallet.getAccountPublicKey({
3435
account: args.account,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { BufferUtils } from '@ironfish/sdk'
1212
import { Flags } from '@oclif/core'
1313
import { IronfishCommand } from '../../command'
1414
import { RemoteFlags } from '../../flags'
15-
import { table, TableFlags } from '../../ui'
15+
import { checkWalletUnlocked, table, TableFlags } from '../../ui'
1616
import { renderAssetWithVerificationStatus, useAccount } from '../../utils'
1717
import { TableCols } from '../../utils/table'
1818

@@ -38,6 +38,7 @@ export class AssetsCommand extends IronfishCommand {
3838
const { flags } = await this.parse(AssetsCommand)
3939

4040
const client = await this.connectRpc()
41+
await checkWalletUnlocked(client)
4142

4243
const account = await useAccount(client, flags.account)
4344

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Balance is your coins from all of your transactions, even if they are on forks o
5353
const { flags } = await this.parse(BalanceCommand)
5454

5555
const client = await this.connectRpc()
56+
await ui.checkWalletUnlocked(client)
5657

5758
const account = await useAccount(client, flags.account)
5859

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BufferUtils, CurrencyUtils, GetBalancesResponse, RpcAsset } from '@iron
55
import { Flags } from '@oclif/core'
66
import { IronfishCommand } from '../../command'
77
import { RemoteFlags } from '../../flags'
8-
import { table, TableColumns, TableFlags } from '../../ui'
8+
import { checkWalletUnlocked, table, TableColumns, TableFlags } from '../../ui'
99
import { compareAssets, renderAssetWithVerificationStatus, useAccount } from '../../utils'
1010

1111
type AssetBalancePairs = { asset: RpcAsset; balance: GetBalancesResponse['balances'][number] }
@@ -32,6 +32,7 @@ export class BalancesCommand extends IronfishCommand {
3232
async start(): Promise<void> {
3333
const { flags } = await this.parse(BalancesCommand)
3434
const client = await this.connectRpc()
35+
await checkWalletUnlocked(client)
3536

3637
const account = await useAccount(client, flags.account)
3738

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ This will destroy tokens and decrease supply for a given asset.`
9292
async start(): Promise<void> {
9393
const { flags } = await this.parse(Burn)
9494
const client = await this.connectRpc()
95+
await ui.checkWalletUnlocked(client)
9596

9697
if (!flags.offline) {
9798
const status = await client.wallet.getNodeStatus()

ironfish-cli/src/commands/wallet/chainport/send.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export class BridgeCommand extends IronfishCommand {
8080
const { flags } = await this.parse(BridgeCommand)
8181

8282
const client = await this.connectRpc()
83+
await ui.checkWalletUnlocked(client)
8384

8485
const networkId = (await client.chain.getNetworkInfo()).content.networkId
8586

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { Args } from '@oclif/core'
66
import { IronfishCommand } from '../../command'
77
import { RemoteFlags } from '../../flags'
8-
import { inputPrompt } from '../../ui'
8+
import { checkWalletUnlocked, inputPrompt } from '../../ui'
99

1010
export class CreateCommand extends IronfishCommand {
1111
static description = `create a new account`
@@ -30,6 +30,7 @@ export class CreateCommand extends IronfishCommand {
3030
}
3131

3232
const client = await this.connectRpc()
33+
await checkWalletUnlocked(client)
3334

3435
this.log(`Creating account ${name}`)
3536
const result = await client.wallet.createAccount({ name })

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class DecryptCommand extends IronfishCommand {
3232

3333
let passphrase = flags.passphrase
3434
if (!passphrase) {
35-
passphrase = await inputPrompt('Enter a passphrase to decrypt the wallet', true, {
35+
passphrase = await inputPrompt('Enter your passphrase to decrypt the wallet', true, {
3636
password: true,
3737
})
3838
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class DeleteCommand extends IronfishCommand {
3434
const { account } = args
3535

3636
const client = await this.connectRpc()
37+
await ui.checkWalletUnlocked(client)
3738

3839
ux.action.start(`Deleting account '${account}'`)
3940
const response = await client.wallet.removeAccount({ account, confirm, wait })

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import fs from 'fs'
77
import path from 'path'
88
import { IronfishCommand } from '../../command'
99
import { EnumLanguageKeyFlag, JsonFlags, RemoteFlags } from '../../flags'
10-
import { confirmOrQuit } from '../../ui'
10+
import { checkWalletUnlocked, confirmOrQuit } from '../../ui'
1111
import { useAccount } from '../../utils'
1212

1313
export class ExportCommand extends IronfishCommand {
@@ -57,6 +57,7 @@ export class ExportCommand extends IronfishCommand {
5757
: AccountFormat.Base64Json
5858

5959
const client = await this.connectRpc(local)
60+
await checkWalletUnlocked(client)
6061

6162
const account = await useAccount(client, flags.account)
6263

0 commit comments

Comments
 (0)