2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
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
|
|
|
|
2024-03-26 11:57:03 +00:00
|
|
|
property var selectedAsset
|
2022-10-17 10:17:25 +00:00
|
|
|
property string currentCurrency
|
2021-07-05 12:34:56 +00:00
|
|
|
|
2023-08-15 18:21:51 +00:00
|
|
|
property var bestRoutes
|
2022-10-17 10:17:25 +00:00
|
|
|
property var getGasEthValue: function () {}
|
|
|
|
property var getFiatValue: function () {}
|
2023-02-17 12:56:31 +00:00
|
|
|
property var formatCurrencyAmount: function () {}
|
2023-08-15 18:21:51 +00:00
|
|
|
property var getNetworkName: function () {}
|
2021-07-05 12:34:56 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
width: parent.width
|
2024-10-15 19:26:12 +00:00
|
|
|
height: visible ? advancedGasSelector.height + Theme.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
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.halfPadding
|
2022-10-17 10:17:25 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.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
|
2023-08-15 18:21:51 +00:00
|
|
|
title: qsTr("%1 transaction fee").arg(root.getNetworkName(modelData.fromNetwork))
|
2024-03-26 11:57:03 +00:00
|
|
|
subTitle: {
|
2024-07-04 15:39:17 +00:00
|
|
|
let primaryFee = root.formatCurrencyAmount(totalGasAmountEth, Constants.ethToken)
|
2024-03-26 11:57:03 +00:00
|
|
|
if (modelData.gasFees.eip1559Enabled && modelData.gasFees.l1GasFee > 0) {
|
2024-07-04 15:39:17 +00:00
|
|
|
return qsTr("L1 fee: %1\nL2 fee: %2")
|
|
|
|
.arg(root.formatCurrencyAmount(totalGasAmountL1Eth, Constants.ethToken))
|
|
|
|
.arg(primaryFee)
|
2024-03-26 11:57:03 +00:00
|
|
|
}
|
2024-07-04 15:39:17 +00:00
|
|
|
return primaryFee
|
2024-03-26 11:57:03 +00:00
|
|
|
}
|
|
|
|
property double totalGasAmountL1Eth: {
|
2024-06-25 23:03:19 +00:00
|
|
|
const l1FeeInGWei = modelData.gasFees.l1GasFee
|
|
|
|
const l1FeeInEth = globalUtils.wei2Eth(l1FeeInGWei, 9)
|
|
|
|
return l1FeeInEth
|
2024-03-26 11:57:03 +00:00
|
|
|
}
|
|
|
|
|
2023-02-17 12:56:31 +00:00
|
|
|
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)
|
|
|
|
}
|
2024-03-26 11:57:03 +00:00
|
|
|
|
|
|
|
property double totalGasAmountFiat: root.getFiatValue(totalGasAmountEth, Constants.ethToken) + root.getFiatValue(totalGasAmountL1Eth, Constants.ethToken)
|
|
|
|
|
2024-10-15 19:26:12 +00:00
|
|
|
statusListItemSubTitle.width: listItem.width/2 - Theme.smallPadding
|
2022-10-17 10:17:25 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
]
|
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 {
|
2023-08-15 18:21:51 +00:00
|
|
|
id: listItem1
|
2022-12-19 12:39:35 +00:00
|
|
|
color: Theme.palette.statusListItem.backgroundColor
|
|
|
|
width: parent.width
|
|
|
|
asset.name: "tiny/checkmark"
|
|
|
|
asset.color: Theme.palette.directColor1
|
|
|
|
statusListItemIcon.active: true
|
|
|
|
statusListItemIcon.opacity: modelData.isFirstSimpleTx
|
2024-03-26 11:57:03 +00:00
|
|
|
title: qsTr("Approve %1 %2 Bridge").arg(root.getNetworkName(modelData.fromNetwork)).arg(root.selectedAsset.symbol)
|
2023-02-17 12:56:31 +00:00
|
|
|
property double approvalGasFees: modelData.approvalGasFees
|
2024-02-05 16:44:49 +00:00
|
|
|
property string approvalGasFeesSymbol: Constants.ethToken
|
|
|
|
property double approvalGasFeesFiat: root.getFiatValue(approvalGasFees, approvalGasFeesSymbol)
|
2023-02-17 12:56:31 +00:00
|
|
|
subTitle: root.formatCurrencyAmount(approvalGasFees, approvalGasFeesSymbol)
|
2024-10-15 19:26:12 +00:00
|
|
|
statusListItemSubTitle.width: listItem1.width/2 - Theme.smallPadding
|
2022-12-19 12:39:35 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2023-08-15 18:21:51 +00:00
|
|
|
title: qsTr("%1 -> %2 bridge").arg(root.getNetworkName(modelData.fromNetwork)).arg(root.getNetworkName(modelData.toNetwork))
|
2023-02-17 12:56:31 +00:00
|
|
|
property double tokenFees: modelData.tokenFees
|
2024-03-26 11:57:03 +00:00
|
|
|
property double tokenFeesFiat: root.getFiatValue(tokenFees, root.selectedAsset.symbol)
|
|
|
|
subTitle: root.formatCurrencyAmount(tokenFees, root.selectedAsset.symbol)
|
2023-08-31 10:27:15 +00:00
|
|
|
visible: modelData.bridgeName !== "Transfer"
|
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
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2020-08-13 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|