Skip to content

Commit

Permalink
adding estimate and duration to send.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
patnir committed Mar 21, 2024
1 parent 04b8bdb commit b3b32be
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions ironfish-cli/src/commands/wallet/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
isValidPublicAddress,
RawTransaction,
RawTransactionSerde,
TimeUtils,
Transaction,
} from '@ironfish/sdk'
import { CliUx, Flags } from '@oclif/core'
Expand All @@ -18,8 +19,11 @@ import { promptCurrency } from '../../utils/currency'
import { getExplorer } from '../../utils/explorer'
import { selectFee } from '../../utils/fees'
import { getSpendPostTimeInMs } from '../../utils/spendPostTime'
import { TransactionTimer } from '../../utils/timer'
import { displayTransactionSummary, watchTransaction } from '../../utils/transaction'
import {
displayTransactionSummary,
TransactionTimer,
watchTransaction,
} from '../../utils/transaction'

export class Send extends IronfishCommand {
static description = `Send coins to another account`
Expand Down Expand Up @@ -250,7 +254,13 @@ export class Send extends IronfishCommand {

const transactionTimer = new TransactionTimer(spendPostTime, raw)

transactionTimer.displayEstimate()
if (spendPostTime > 0) {
this.log(
`Time to send: ${TimeUtils.renderSpan(transactionTimer.getEstimateInMs(), {
hideMilliseconds: true,
})}`,
)
}

if (!flags.confirm) {
const confirmed = await CliUx.ux.confirm('Do you confirm (Y/N)?')
Expand All @@ -271,6 +281,15 @@ export class Send extends IronfishCommand {

transactionTimer.end()

this.log(
`Sending took ${TimeUtils.renderSpan(
transactionTimer.getEndTime() - transactionTimer.getStartTime(),
{
hideMilliseconds: true,
},
)}`,
)

if (response.content.accepted === false) {
this.warn(
`Transaction '${transaction.hash().toString('hex')}' was not accepted into the mempool`,
Expand Down

0 comments on commit b3b32be

Please sign in to comment.