Skip to content

Commit

Permalink
Normalize arg destructuring and remove a few extra as casts (#5033)
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-if authored Jun 12, 2024
1 parent c0f9736 commit 9427dbc
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/blocks/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class ShowBlock extends IronfishCommand {

async start(): Promise<void> {
const { args } = await this.parse(ShowBlock)
const search = args.search
const { search } = args

const client = await this.sdk.connectRpc()
const data = await client.chain.getBlock({ search })
Expand Down
5 changes: 2 additions & 3 deletions ironfish-cli/src/commands/chain/asset.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { Assert, BufferUtils } from '@ironfish/sdk'
import { BufferUtils } from '@ironfish/sdk'
import { Args } from '@oclif/core'
import { IronfishCommand } from '../../command'
import { RemoteFlags } from '../../flags'
Expand All @@ -22,8 +22,7 @@ export default class Asset extends IronfishCommand {

async start(): Promise<void> {
const { args } = await this.parse(Asset)
Assert.isString(args.id)
const assetId = args.id
const { id: assetId } = args

const client = await this.sdk.connectRpc()
const data = await client.chain.getAsset({ id: assetId })
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/chain/broadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class BroadcastCommand extends IronfishCommand {

async start(): Promise<void> {
const { args } = await this.parse(BroadcastCommand)
const transaction = args.transaction
const { transaction } = args

ux.action.start(`Broadcasting transaction`)
const client = await this.sdk.connectRpc()
Expand Down
4 changes: 2 additions & 2 deletions ironfish-cli/src/commands/chain/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default class Export extends IronfishCommand {
const client = await this.sdk.connectRpc()

const stream = client.chain.exportChainStream({
start: args.start as number | null,
stop: args.stop as number | null,
start: args.start,
stop: args.stop,
})

const { start, stop } = await AsyncUtils.first(stream.contentStream())
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/chain/power.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class Power extends IronfishCommand {

async start(): Promise<void> {
const { flags, args } = await this.parse(Power)
const block = args.block as number | null | undefined
const { block } = args

const client = await this.sdk.connectRpc()

Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/chain/repair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class RepairChain extends IronfishCommand {

const total = Number(node.chain.head.sequence)
let done = 0
let head = node.chain.head as BlockHeader | null
let head: BlockHeader | null = node.chain.head

speed.start()
progress.start(total, 0, {
Expand Down
3 changes: 1 addition & 2 deletions ironfish-cli/src/commands/chain/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export default class Show extends IronfishCommand {

async start(): Promise<void> {
const { args } = await this.parse(Show)
const start = args.start as number | null
const stop = args.stop as number | null
const { start, stop } = args

this.log(`Getting the chain blocks...`)
await this.sdk.client.connect()
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/config/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class GetCommand extends IronfishCommand {

async start(): Promise<void> {
const { args, flags } = await this.parse(GetCommand)
const name = args.name
const { name } = args

const client = await this.sdk.connectRpc(flags.local)

Expand Down
3 changes: 1 addition & 2 deletions ironfish-cli/src/commands/config/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export class SetCommand extends IronfishCommand {

async start(): Promise<void> {
const { args, flags } = await this.parse(SetCommand)
const name = args.name
const value = args.value
const { name, value } = args

const client = await this.sdk.connectRpc(flags.local)
await client.config.setConfig({ name, value })
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/config/unset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class UnsetCommand extends IronfishCommand {

async start(): Promise<void> {
const { args, flags } = await this.parse(UnsetCommand)
const name = args.name
const { name } = args

const client = await this.sdk.connectRpc(flags.local)
await client.config.unsetConfig({ name })
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/peers/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ShowCommand extends IronfishCommand {

async start(): Promise<void> {
const { args } = await this.parse(ShowCommand)
const identity = args.identity
const { identity } = args

await this.sdk.client.connect()
const [peer, messages] = await Promise.all([
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class AddressCommand extends IronfishCommand {

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

const client = await this.sdk.connectRpc()

Expand Down
3 changes: 2 additions & 1 deletion ironfish-cli/src/commands/wallet/chainport/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ export class BridgeCommand extends IronfishCommand {
}

async start(): Promise<void> {
const client = await this.sdk.connectRpc()
const { flags } = await this.parse(BridgeCommand)

const client = await this.sdk.connectRpc()

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

if (networkId !== TESTNET.id) {
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CreateCommand extends IronfishCommand {

async start(): Promise<void> {
const { args } = await this.parse(CreateCommand)
let name = args.account as string
let name = args.account

if (!name) {
name = await ux.prompt('Enter the name of the account', {
Expand Down
5 changes: 2 additions & 3 deletions ironfish-cli/src/commands/wallet/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ export class DeleteCommand extends IronfishCommand {

async start(): Promise<void> {
const { args, flags } = await this.parse(DeleteCommand)
const confirm = flags.confirm
const wait = flags.wait
const account = args.account
const { confirm, wait } = flags
const { account } = args

const client = await this.sdk.connectRpc()

Expand Down
6 changes: 2 additions & 4 deletions ironfish-cli/src/commands/wallet/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ export class ExportCommand extends IronfishCommand {

async start(): Promise<void> {
const { flags, args } = await this.parse(ExportCommand)
const { color, local } = flags
const account = args.account as string
const exportPath = flags.path
const viewOnly = flags.viewonly
const { color, local, path: exportPath, viewonly: viewOnly } = flags
const { account } = args

if (flags.language) {
flags.mnemonic = true
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ImportCommand extends IronfishCommand {

async start(): Promise<void> {
const { flags, args } = await this.parse(ImportCommand)
const blob = args.blob
const { blob } = args

const client = await this.sdk.connectRpc()

Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ResetCommand extends IronfishCommand {

async start(): Promise<void> {
const { args, flags } = await this.parse(ResetCommand)
const account = args.account
const { account } = args

if (!flags.confirm) {
const confirm = await ux.confirm(
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/scanning/off.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ScanningOffCommand extends IronfishCommand {

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

const client = await this.sdk.connectRpc()

Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/scanning/on.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ScanningOnCommand extends IronfishCommand {

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

const client = await this.sdk.connectRpc()

Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/transaction/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class TransactionImportCommand extends IronfishCommand {

async start(): Promise<void> {
const { flags, args } = await this.parse(TransactionImportCommand)
const txArg = args.transaction
const { transaction: txArg } = args

let transaction

Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/transaction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class TransactionCommand extends IronfishCommand {

async start(): Promise<void> {
const { flags, args } = await this.parse(TransactionCommand)
const hash = args.hash
const { hash } = args
// TODO: remove account arg
const account = flags.account ? flags.account : args.account

Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/transaction/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class TransactionViewCommand extends IronfishCommand {

const account = flags.account ?? (await this.selectAccount(client))

let transactionString = flags.transaction as string
let transactionString = flags.transaction
if (!transactionString) {
transactionString = await longPrompt(
'Enter the hex-encoded transaction, raw transaction, or unsigned transaction to view',
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/transaction/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class WatchTxCommand extends IronfishCommand {

async start(): Promise<void> {
const { flags, args } = await this.parse(WatchTxCommand)
const hash = args.hash
const { hash } = args
// TODO: remove account arg
const account = flags.account ? flags.account : args.account

Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/use.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class UseCommand extends IronfishCommand {

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

const client = await this.sdk.connectRpc()
await client.wallet.useAccount({ account })
Expand Down

0 comments on commit 9427dbc

Please sign in to comment.