2023-05-10 11:05:45 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
2024-01-30 13:15:58 +00:00
|
|
|
import StatusQ.Core 0.1
|
2024-05-28 17:39:41 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2024-01-30 13:15:58 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
QtObject {
|
2023-12-18 10:12:57 +00:00
|
|
|
id: root
|
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
readonly property string currentCurrency: "USD"
|
|
|
|
property string currentCurrencySymbol: "$"
|
|
|
|
|
|
|
|
function formatCurrencyAmount(amount, symbol, options = null, locale = null) {
|
2024-01-30 13:15:58 +00:00
|
|
|
if (isNaN(amount)) {
|
|
|
|
return "N/A"
|
|
|
|
}
|
|
|
|
var currencyAmount = getCurrencyAmount(amount, symbol)
|
|
|
|
return LocaleUtils.currencyAmountToLocaleString(currencyAmount, options, locale)
|
2023-09-26 13:45:44 +00:00
|
|
|
}
|
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
function formatCurrencyAmountFromBigInt(balance, symbol, decimals, options = null) {
|
2024-05-28 17:39:41 +00:00
|
|
|
let bigIntBalance = SQUtils.AmountsArithmetic.fromString(balance)
|
|
|
|
let decimalBalance = SQUtils.AmountsArithmetic.toNumber(bigIntBalance, decimals)
|
2024-06-12 20:43:08 +00:00
|
|
|
return formatCurrencyAmount(decimalBalance, symbol, options)
|
2024-05-28 17:39:41 +00:00
|
|
|
}
|
|
|
|
|
2024-02-05 16:44:49 +00:00
|
|
|
function getFiatValue(balance, cryptoSymbol) {
|
2023-09-26 13:45:44 +00:00
|
|
|
return balance
|
|
|
|
}
|
2023-12-18 10:12:57 +00:00
|
|
|
|
|
|
|
function getCurrencyAmount(amount, symbol) {
|
|
|
|
return ({
|
|
|
|
amount: amount,
|
|
|
|
symbol: symbol ? symbol.toUpperCase() : root.currentCurrency,
|
|
|
|
displayDecimals: 2,
|
|
|
|
stripTrailingZeroes: false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCurrentCurrencyAmount(amount) {
|
|
|
|
return ({
|
|
|
|
amount: amount,
|
|
|
|
symbol: root.currentCurrency,
|
|
|
|
displayDecimals: 2,
|
|
|
|
stripTrailingZeroes: false
|
|
|
|
})
|
|
|
|
}
|
2023-09-26 13:45:44 +00:00
|
|
|
}
|