2023-09-01 12:27:44 +03:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\qmltype SingleFeeSubscriber
|
|
|
|
\inherits QtObject
|
2023-09-28 12:09:47 +02:00
|
|
|
\brief Helper object that parses fees response and provides fee text and error text for single fee response
|
2023-09-01 12:27:44 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
2023-09-28 12:09:47 +02:00
|
|
|
|
2023-09-01 12:27:44 +03:00
|
|
|
// Published properties
|
|
|
|
property var feesResponse
|
|
|
|
|
|
|
|
// Internal properties based on response
|
|
|
|
readonly property string feeText: {
|
2025-01-29 13:11:50 +01:00
|
|
|
if (!root.feesResponse) {
|
2023-09-01 12:27:44 +03:00
|
|
|
return ""
|
2025-01-29 13:11:50 +01:00
|
|
|
}
|
2023-09-01 12:27:44 +03:00
|
|
|
|
|
|
|
|
2025-01-29 13:11:50 +01:00
|
|
|
if (!!root.feesResponse.error) {
|
|
|
|
return "-"
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!root.feesResponse || !Object.values(root.feesResponse.ethCurrency).length || !Object.values(root.feesResponse.fiatCurrency).length) {
|
|
|
|
return ""
|
|
|
|
}
|
2023-09-01 12:27:44 +03:00
|
|
|
|
2025-01-29 13:11:50 +01:00
|
|
|
return LocaleUtils.currencyAmountToLocaleString(root.feesResponse.ethCurrency)
|
|
|
|
+ " (" + LocaleUtils.currencyAmountToLocaleString(root.feesResponse.fiatCurrency) + ")"
|
|
|
|
}
|
|
|
|
readonly property string feeErrorText: {
|
|
|
|
if (!root.feesResponse)
|
|
|
|
return ""
|
2023-09-01 12:27:44 +03:00
|
|
|
|
2025-01-29 13:11:50 +01:00
|
|
|
return root.feesResponse.error
|
2023-09-01 12:27:44 +03:00
|
|
|
}
|
|
|
|
}
|