Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output error message when transaction amount is not greater than 0 #3550

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ironfish-cli/src/utils/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import { Asset } from '@ironfish/rust-nodejs'
import { CurrencyUtils, RpcClient } from '@ironfish/sdk'
import { CliUx } from '@oclif/core'
import {createRootLogger, Logger} from '@ironfish/sdk'


export async function promptCurrency(options: {
client: RpcClient
Expand All @@ -16,6 +18,7 @@ export async function promptCurrency(options: {
assetId?: string
confirmations?: number
}
logger?: Logger
}): Promise<bigint>

export async function promptCurrency(options: {
Expand All @@ -28,9 +31,10 @@ export async function promptCurrency(options: {
assetId?: string
confirmations?: number
}
logger?: Logger
}): Promise<bigint | null> {
let text = options.text

const logger = options.logger ?? createRootLogger()
if (options.balance) {
const balance = await options.client.getAccountBalance({
assetId: options.balance.assetId ?? Asset.nativeId().toString('hex'),
Expand All @@ -53,6 +57,7 @@ export async function promptCurrency(options: {
const amount = CurrencyUtils.decodeIron(input)

if (options.minimum != null && amount < options.minimum) {
logger.log("Please enter an amount greater than 0")
continue
}

Expand Down