2020-08-13 07:27:53 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.controls 1.0
|
|
|
|
import shared.controls.chat 1.0
|
2021-10-21 15:07:13 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2022-07-01 11:24:32 +00:00
|
|
|
import StatusQ.Components 0.1
|
2022-10-17 10:17:25 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2020-08-13 07:27:53 +00:00
|
|
|
Item {
|
|
|
|
id: root
|
2021-05-21 20:19:03 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property string selectedTokenSymbol
|
|
|
|
property string currentCurrency
|
2021-07-05 12:34:56 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property var bestRoutes: []
|
|
|
|
property var getGasEthValue: function () {}
|
|
|
|
property var getFiatValue: function () {}
|
2023-02-17 12:56:31 +00:00
|
|
|
property var formatCurrencyAmount: function () {}
|
2021-07-05 12:34:56 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
width: parent.width
|
2022-11-30 12:59:21 +00:00
|
|
|
height: visible ? advancedGasSelector.height + Style.current.halfPadding : 0
|
2020-08-13 07:27:53 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
Column {
|
|
|
|
id: advancedGasSelector
|
2021-05-21 20:19:03 +00:00
|
|
|
width: parent.width
|
2022-10-17 10:17:25 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
|
|
|
|
spacing: Style.current.halfPadding
|
2020-08-20 04:45:29 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
// Normal transaction
|
|
|
|
Repeater {
|
|
|
|
model: root.bestRoutes
|
|
|
|
StatusListItem {
|
|
|
|
id: listItem
|
|
|
|
color: Theme.palette.statusListItem.backgroundColor
|
|
|
|
width: parent.width
|
2022-12-14 21:06:14 +00:00
|
|
|
asset.name: "tiny/gas"
|
|
|
|
asset.color: Theme.palette.directColor1
|
|
|
|
statusListItemIcon.active: true
|
|
|
|
statusListItemIcon.opacity: modelData.isFirstSimpleTx
|
2022-10-17 10:17:25 +00:00
|
|
|
title: qsTr("%1 transaction fee").arg(modelData.fromNetwork.chainName)
|
2023-02-17 12:56:31 +00:00
|
|
|
subTitle: root.formatCurrencyAmount(totalGasAmountEth, "ETH")
|
|
|
|
property double totalGasAmountEth: {
|
2022-11-30 12:59:21 +00:00
|
|
|
let maxFees = modelData.gasFees.maxFeePerGasM
|
2022-10-17 10:17:25 +00:00
|
|
|
let gasPrice = modelData.gasFees.eip1559Enabled ? maxFees : modelData.gasFees.gasPrice
|
|
|
|
return root.getGasEthValue(gasPrice , modelData.gasAmount)
|
|
|
|
}
|
2023-02-17 12:56:31 +00:00
|
|
|
property double totalGasAmountFiat: root.getFiatValue(totalGasAmountEth, "ETH", root.currentCurrency)
|
2022-10-17 10:17:25 +00:00
|
|
|
statusListItemSubTitle.width: listItem.width/2 - Style.current.smallPadding
|
|
|
|
statusListItemSubTitle.elide: Text.ElideMiddle
|
|
|
|
statusListItemSubTitle.wrapMode: Text.NoWrap
|
|
|
|
components: [
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2023-02-17 12:56:31 +00:00
|
|
|
text: root.formatCurrencyAmount(totalGasAmountFiat, root.currentCurrency)
|
2022-10-17 10:17:25 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
width: listItem.width/2 - Style.current.padding
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
]
|
2021-07-05 12:34:56 +00:00
|
|
|
}
|
2020-08-13 07:27:53 +00:00
|
|
|
}
|
|
|
|
|
2022-12-19 12:39:35 +00:00
|
|
|
// Approval transaction
|
|
|
|
Repeater {
|
|
|
|
model: root.bestRoutes
|
|
|
|
StatusListItem {
|
|
|
|
id: listItem
|
|
|
|
color: Theme.palette.statusListItem.backgroundColor
|
|
|
|
width: parent.width
|
|
|
|
asset.name: "tiny/checkmark"
|
|
|
|
asset.color: Theme.palette.directColor1
|
|
|
|
statusListItemIcon.active: true
|
|
|
|
statusListItemIcon.opacity: modelData.isFirstSimpleTx
|
|
|
|
title: qsTr("Approve %1 %2 Bridge").arg(modelData.fromNetwork.chainName).arg(root.selectedTokenSymbol)
|
2023-02-17 12:56:31 +00:00
|
|
|
property double approvalGasFees: modelData.approvalGasFees
|
|
|
|
property string approvalGasFeesSymbol: "ETH"
|
|
|
|
property double approvalGasFeesFiat: root.getFiatValue(approvalGasFees, approvalGasFeesSymbol, root.currentCurrency)
|
|
|
|
subTitle: root.formatCurrencyAmount(approvalGasFees, approvalGasFeesSymbol)
|
2022-12-19 12:39:35 +00:00
|
|
|
statusListItemSubTitle.width: listItem.width/2 - Style.current.smallPadding
|
|
|
|
statusListItemSubTitle.elide: Text.ElideMiddle
|
|
|
|
statusListItemSubTitle.wrapMode: Text.NoWrap
|
|
|
|
visible: modelData.approvalRequired
|
|
|
|
components: [
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2023-02-17 12:56:31 +00:00
|
|
|
text: root.formatCurrencyAmount(approvalGasFeesFiat, root.currentCurrency)
|
2022-12-19 12:39:35 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
width: listItem.width/2 - Style.current.padding
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
// Bridge
|
|
|
|
Repeater {
|
2022-12-14 21:06:14 +00:00
|
|
|
id: bridgeRepeater
|
2022-10-17 10:17:25 +00:00
|
|
|
model: root.bestRoutes
|
2022-12-14 21:06:14 +00:00
|
|
|
delegate: StatusListItem {
|
2022-10-17 10:17:25 +00:00
|
|
|
id: listItem2
|
|
|
|
color: Theme.palette.statusListItem.backgroundColor
|
|
|
|
width: parent.width
|
2022-12-14 21:06:14 +00:00
|
|
|
asset.name: "tiny/bridge"
|
|
|
|
asset.color: Theme.palette.directColor1
|
|
|
|
statusListItemIcon.active: true
|
|
|
|
statusListItemIcon.opacity: modelData.isFirstBridgeTx
|
2022-10-17 10:17:25 +00:00
|
|
|
title: qsTr("%1 -> %2 bridge").arg(modelData.fromNetwork.chainName).arg(modelData.toNetwork.chainName)
|
2023-02-17 12:56:31 +00:00
|
|
|
property double tokenFees: modelData.tokenFees
|
|
|
|
property double tokenFeesFiat: root.getFiatValue(tokenFees, root.selectedTokenSymbol, root.currentCurrency)
|
|
|
|
subTitle: root.formatCurrencyAmount(tokenFees, root.selectedTokenSymbol)
|
2022-10-17 10:17:25 +00:00
|
|
|
visible: modelData.bridgeName !== "Simple"
|
2022-11-30 12:59:21 +00:00
|
|
|
statusListItemSubTitle.width: 100
|
2022-10-17 10:17:25 +00:00
|
|
|
statusListItemSubTitle.elide: Text.ElideMiddle
|
|
|
|
components: [
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2023-02-17 12:56:31 +00:00
|
|
|
text: root.formatCurrencyAmount(tokenFeesFiat, root.currentCurrency)
|
2022-10-17 10:17:25 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
width: listItem2.width/2 - Style.current.padding
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2020-08-13 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|