From b3b32be82abbd67f4c228e22b3988be903e54a93 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Thu, 21 Mar 2024 14:32:25 -0700 Subject: [PATCH] adding estimate and duration to send.ts --- ironfish-cli/src/commands/wallet/send.ts | 25 +++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/ironfish-cli/src/commands/wallet/send.ts b/ironfish-cli/src/commands/wallet/send.ts index 1a56ee1ed0..84c4d21008 100644 --- a/ironfish-cli/src/commands/wallet/send.ts +++ b/ironfish-cli/src/commands/wallet/send.ts @@ -8,6 +8,7 @@ import { isValidPublicAddress, RawTransaction, RawTransactionSerde, + TimeUtils, Transaction, } from '@ironfish/sdk' import { CliUx, Flags } from '@oclif/core' @@ -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` @@ -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)?') @@ -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`,