2024-07-01 15:56:44 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQml.Models 2.15
|
|
|
|
|
|
|
|
import StatusQ 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
import AppLayouts.Wallet.panels 1.0
|
|
|
|
import AppLayouts.Wallet.popups 1.0
|
2024-08-08 13:52:19 +00:00
|
|
|
import AppLayouts.Wallet.controls 1.0
|
2024-07-01 15:56:44 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
SignTransactionModalBase {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
required property string fromTokenSymbol
|
|
|
|
required property string fromTokenAmount
|
|
|
|
required property string fromTokenContractAddress
|
|
|
|
|
|
|
|
required property string toTokenSymbol
|
|
|
|
required property string toTokenAmount
|
|
|
|
required property string toTokenContractAddress
|
|
|
|
|
|
|
|
required property string accountName
|
|
|
|
required property string accountAddress
|
|
|
|
required property string accountEmoji
|
|
|
|
required property color accountColor
|
|
|
|
|
|
|
|
required property string networkShortName // e.g. "oeth"
|
|
|
|
required property string networkName // e.g. "Optimism"
|
|
|
|
required property string networkIconPath // e.g. `Style.svg("network/Network=Optimism")`
|
|
|
|
required property string networkBlockExplorerUrl
|
|
|
|
|
|
|
|
required property string fiatFees
|
|
|
|
required property string cryptoFees
|
|
|
|
required property double slippage
|
|
|
|
|
2024-07-22 16:22:33 +00:00
|
|
|
required property string serviceProviderName
|
|
|
|
required property string serviceProviderURL
|
2024-08-08 13:52:19 +00:00
|
|
|
required property string serviceProviderTandCUrl
|
2024-07-01 15:56:44 +00:00
|
|
|
|
|
|
|
//: e.g. (swap) 100 DAI to 100 USDT
|
2024-07-31 10:04:51 +00:00
|
|
|
subtitle: qsTr("%1 to %2").arg(formatBigNumber(fromTokenAmount, fromTokenSymbol)).arg(formatBigNumber(toTokenAmount, toTokenSymbol))
|
2024-07-01 15:56:44 +00:00
|
|
|
|
|
|
|
gradientColor: Utils.setColorAlpha(root.accountColor, 0.05) // 5% of wallet color
|
|
|
|
fromImageSource: Constants.tokenIcon(root.fromTokenSymbol)
|
|
|
|
toImageSource: Constants.tokenIcon(root.toTokenSymbol)
|
|
|
|
|
|
|
|
//: e.g. "Swap 100 DAI to 100 USDT in <account name> on <network chain name>"
|
2024-07-31 10:04:51 +00:00
|
|
|
headerMainText: qsTr("Swap %1 to %2 in %3 on %4").arg(formatBigNumber(root.fromTokenAmount, root.fromTokenSymbol))
|
|
|
|
.arg(formatBigNumber(root.toTokenAmount, root.toTokenSymbol)).arg(root.accountName).arg(root.networkName)
|
2024-07-01 15:56:44 +00:00
|
|
|
headerSubTextLayout: [
|
2024-08-08 13:52:19 +00:00
|
|
|
SwapProvidersTermsAndConditionsText {
|
|
|
|
serviceProviderName: root.serviceProviderName
|
|
|
|
onLinkClicked: root.openLinkWithConfirmation(root.serviceProviderURL)
|
|
|
|
onTermsAndConditionClicked: root.openLinkWithConfirmation(root.serviceProviderTandCUrl)
|
2024-07-01 15:56:44 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
infoTagText: qsTr("Review all details before signing")
|
|
|
|
|
|
|
|
headerIconComponent: StatusSmartIdenticon {
|
|
|
|
asset.name: "filled-account"
|
|
|
|
asset.emoji: root.accountEmoji
|
|
|
|
asset.color: root.accountColor
|
|
|
|
asset.isLetterIdenticon: !!root.accountEmoji
|
|
|
|
asset.bgWidth: 40
|
|
|
|
asset.bgHeight: 40
|
|
|
|
|
|
|
|
bridgeBadge.visible: true
|
|
|
|
bridgeBadge.border.width: 2
|
|
|
|
bridgeBadge.color: Style.current.darkBlue
|
|
|
|
bridgeBadge.image.source: Style.svg("sign")
|
|
|
|
}
|
|
|
|
|
|
|
|
leftFooterContents: ObjectModel {
|
|
|
|
RowLayout {
|
|
|
|
Layout.leftMargin: 4
|
|
|
|
spacing: Style.current.bigPadding
|
|
|
|
ColumnLayout {
|
|
|
|
spacing: 2
|
|
|
|
StatusBaseText {
|
|
|
|
text: qsTr("Max fees:")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: Style.current.additionalTextSize
|
|
|
|
}
|
|
|
|
StatusTextWithLoadingState {
|
|
|
|
objectName: "footerFiatFeesText"
|
2024-07-10 18:35:24 +00:00
|
|
|
text: loading ? Constants.dummyText : root.fiatFees
|
2024-07-01 15:56:44 +00:00
|
|
|
loading: root.feesLoading
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ColumnLayout {
|
|
|
|
spacing: 2
|
|
|
|
StatusBaseText {
|
|
|
|
text: qsTr("Max slippage:")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: Style.current.additionalTextSize
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
objectName: "footerMaxSlippageText"
|
|
|
|
text: "%1%".arg(LocaleUtils.numberToLocaleString(root.slippage))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pay
|
|
|
|
SignInfoBox {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: Style.current.bigPadding
|
|
|
|
objectName: "payBox"
|
|
|
|
caption: qsTr("Pay")
|
2024-07-31 10:04:51 +00:00
|
|
|
primaryText: formatBigNumber(root.fromTokenAmount, root.fromTokenSymbol)
|
2024-07-10 18:35:24 +00:00
|
|
|
secondaryText: root.fromTokenSymbol !== Constants.ethToken ? SQUtils.Utils.elideAndFormatWalletAddress(root.fromTokenContractAddress) : ""
|
2024-07-01 15:56:44 +00:00
|
|
|
icon: Constants.tokenIcon(root.fromTokenSymbol)
|
|
|
|
badge: root.networkIconPath
|
|
|
|
components: [
|
|
|
|
ContractInfoButtonWithMenu {
|
2024-07-10 18:35:24 +00:00
|
|
|
visible: root.fromTokenSymbol !== Constants.ethToken
|
2024-07-01 15:56:44 +00:00
|
|
|
symbol: root.fromTokenSymbol
|
|
|
|
contractAddress: root.fromTokenContractAddress
|
|
|
|
networkName: root.networkName
|
2024-07-04 11:55:16 +00:00
|
|
|
networkShortName: root.networkShortName
|
2024-07-01 15:56:44 +00:00
|
|
|
networkBlockExplorerUrl: root.networkBlockExplorerUrl
|
2024-07-04 11:55:16 +00:00
|
|
|
onOpenLink: (link) => root.openLinkWithConfirmation(link)
|
2024-07-01 15:56:44 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Receive
|
|
|
|
SignInfoBox {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: Style.current.bigPadding
|
|
|
|
objectName: "receiveBox"
|
|
|
|
caption: qsTr("Receive")
|
2024-07-31 10:04:51 +00:00
|
|
|
primaryText: formatBigNumber(root.toTokenAmount, root.toTokenSymbol)
|
2024-07-10 18:35:24 +00:00
|
|
|
secondaryText: root.toTokenSymbol !== Constants.ethToken ? SQUtils.Utils.elideAndFormatWalletAddress(root.toTokenContractAddress) : ""
|
2024-07-01 15:56:44 +00:00
|
|
|
icon: Constants.tokenIcon(root.toTokenSymbol)
|
|
|
|
badge: root.networkIconPath
|
|
|
|
components: [
|
|
|
|
ContractInfoButtonWithMenu {
|
2024-07-10 18:35:24 +00:00
|
|
|
visible: root.toTokenSymbol !== Constants.ethToken
|
2024-07-01 15:56:44 +00:00
|
|
|
symbol: root.toTokenSymbol
|
|
|
|
contractAddress: root.toTokenContractAddress
|
|
|
|
networkName: root.networkName
|
2024-07-04 11:55:16 +00:00
|
|
|
networkShortName: root.networkShortName
|
2024-07-01 15:56:44 +00:00
|
|
|
networkBlockExplorerUrl: root.networkBlockExplorerUrl
|
2024-07-04 11:55:16 +00:00
|
|
|
onOpenLink: (link) => root.openLinkWithConfirmation(link)
|
2024-07-01 15:56:44 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Account
|
|
|
|
SignInfoBox {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: Style.current.bigPadding
|
|
|
|
objectName: "accountBox"
|
|
|
|
caption: qsTr("In account")
|
|
|
|
primaryText: root.accountName
|
|
|
|
secondaryText: SQUtils.Utils.elideAndFormatWalletAddress(root.accountAddress)
|
2024-07-04 11:55:16 +00:00
|
|
|
asset.name: "filled-account"
|
2024-07-01 15:56:44 +00:00
|
|
|
asset.emoji: root.accountEmoji
|
|
|
|
asset.color: root.accountColor
|
|
|
|
asset.isLetterIdenticon: !!root.accountEmoji
|
|
|
|
}
|
|
|
|
|
|
|
|
// Network
|
|
|
|
SignInfoBox {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: Style.current.bigPadding
|
|
|
|
objectName: "networkBox"
|
|
|
|
caption: qsTr("Network")
|
|
|
|
primaryText: root.networkName
|
|
|
|
icon: root.networkIconPath
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fees
|
|
|
|
SignInfoBox {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: Style.current.bigPadding
|
|
|
|
objectName: "feesBox"
|
|
|
|
caption: qsTr("Fees")
|
|
|
|
primaryText: qsTr("Max. fees on %1").arg(root.networkName)
|
2024-07-10 18:35:24 +00:00
|
|
|
primaryTextCustomColor: Theme.palette.baseColor1
|
2024-07-01 15:56:44 +00:00
|
|
|
secondaryText: " "
|
|
|
|
components: [
|
|
|
|
ColumnLayout {
|
|
|
|
spacing: 2
|
2024-07-04 11:55:16 +00:00
|
|
|
StatusTextWithLoadingState {
|
2024-07-01 15:56:44 +00:00
|
|
|
objectName: "fiatFeesText"
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2024-07-10 18:35:24 +00:00
|
|
|
text: loading ? Constants.dummyText : root.fiatFees
|
2024-07-01 15:56:44 +00:00
|
|
|
horizontalAlignment: Text.AlignRight
|
|
|
|
font.pixelSize: Style.current.additionalTextSize
|
2024-07-04 11:55:16 +00:00
|
|
|
loading: root.feesLoading
|
2024-07-01 15:56:44 +00:00
|
|
|
}
|
2024-07-04 11:55:16 +00:00
|
|
|
StatusTextWithLoadingState {
|
2024-07-01 15:56:44 +00:00
|
|
|
objectName: "cryptoFeesText"
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2024-07-10 18:35:24 +00:00
|
|
|
text: loading ? Constants.dummyText : root.cryptoFees
|
2024-07-01 15:56:44 +00:00
|
|
|
horizontalAlignment: Text.AlignRight
|
|
|
|
font.pixelSize: Style.current.additionalTextSize
|
2024-07-04 11:55:16 +00:00
|
|
|
customColor: Theme.palette.baseColor1
|
|
|
|
loading: root.feesLoading
|
2024-07-01 15:56:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|