Lukáš Tinkl 38d155f590 feat(SwapModal): Integrate Sign and Approve modals
- remove old popup and related components/adaptors
- simplify the API of the Sign/Approve modals to take pre-formatted
amounts as strings
- correct login/auth icon
- SB: make it possible to open the new secondary modals
- SB: fix the `fetchSuggestedRoutes` response handling, pass around the
`uuid` and inject it to the mocked suggested routes
- adjust SB pages and tests

Fixes #15443
2024-07-12 16:04:21 +02:00

52 lines
1.5 KiB
QML

import QtQuick 2.15
import StatusQ.Core 0.1
import StatusQ.Core.Utils 0.1 as SQUtils
QtObject {
id: root
readonly property string currentCurrency: "USD"
property string currentCurrencySymbol: "$"
function formatCurrencyAmount(amount, symbol, options = null, locale = null) {
if (isNaN(amount)) {
return "N/A"
}
var currencyAmount = getCurrencyAmount(amount, symbol)
return LocaleUtils.currencyAmountToLocaleString(currencyAmount, options, locale)
}
function formatCurrencyAmountFromBigInt(balance, symbol, decimals, options = null) {
let bigIntBalance = SQUtils.AmountsArithmetic.fromString(balance)
let decimalBalance = SQUtils.AmountsArithmetic.toNumber(bigIntBalance, decimals)
return formatCurrencyAmount(decimalBalance, symbol, options)
}
function getFiatValue(balance, cryptoSymbol) {
return parseFloat(balance)
}
function getCryptoValue(balance, symbol) {
return balance
}
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
})
}
}