2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2020-08-13 08:24:51 +00:00
|
|
|
import QtQuick.Layouts 1.13
|
2020-08-20 04:45:29 +00:00
|
|
|
import QtQuick.Dialogs 1.3
|
2022-03-18 14:47:51 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2023-06-28 09:16:30 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-12-08 21:20:43 +00:00
|
|
|
import shared.stores 1.0
|
2022-07-21 08:40:49 +00:00
|
|
|
import shared.panels 1.0
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
import StatusQ.Components 0.1
|
2023-05-10 11:19:25 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
2022-03-18 14:47:51 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-05-10 11:19:25 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2021-10-14 09:20:18 +00:00
|
|
|
import "../panels"
|
2021-10-14 10:12:22 +00:00
|
|
|
import "../controls"
|
2021-10-14 13:45:08 +00:00
|
|
|
import "../views"
|
2020-05-27 20:50:39 +00:00
|
|
|
|
2022-07-27 21:10:00 +00:00
|
|
|
StatusDialog {
|
2022-03-18 14:47:51 +00:00
|
|
|
id: popup
|
2022-01-04 12:06:05 +00:00
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
property bool isBridgeTx: false
|
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property string preSelectedRecipient
|
|
|
|
property string preDefinedAmountToSend
|
2023-09-11 10:20:36 +00:00
|
|
|
property var preSelectedHolding
|
|
|
|
property string preSelectedHoldingID
|
|
|
|
property var preSelectedHoldingType
|
2022-10-17 10:17:25 +00:00
|
|
|
property bool interactive: true
|
2023-09-11 10:20:36 +00:00
|
|
|
property alias onlyAssets: holdingSelector.onlyAssets
|
2020-06-26 16:08:51 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property alias modalHeader: modalHeader.text
|
|
|
|
|
|
|
|
property var store: TransactionStore{}
|
2023-01-08 22:23:51 +00:00
|
|
|
property var currencyStore: store.currencyStore
|
2023-05-04 12:55:39 +00:00
|
|
|
property var selectedAccount: store.selectedSenderAccount
|
2023-09-11 10:20:36 +00:00
|
|
|
property var collectiblesModel: store.collectiblesModel
|
|
|
|
property var nestedCollectiblesModel: store.nestedCollectiblesModel
|
2022-10-17 10:17:25 +00:00
|
|
|
property var bestRoutes
|
2023-04-18 16:05:24 +00:00
|
|
|
property alias addressText: recipientLoader.addressText
|
2022-10-17 10:17:25 +00:00
|
|
|
property bool isLoading: false
|
2022-11-23 17:58:22 +00:00
|
|
|
property int sendType: isBridgeTx ? Constants.SendType.Bridge : Constants.SendType.Transfer
|
2020-08-20 04:45:29 +00:00
|
|
|
property MessageDialog sendingError: MessageDialog {
|
|
|
|
id: sendingError
|
2022-04-04 11:26:30 +00:00
|
|
|
title: qsTr("Error sending the transaction")
|
2020-08-20 04:45:29 +00:00
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
2020-08-20 04:45:29 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property var sendTransaction: function() {
|
2023-04-18 16:05:24 +00:00
|
|
|
let recipientAddress = Utils.isValidAddress(popup.addressText) ? popup.addressText : recipientLoader.resolvedENSAddress
|
2022-10-17 10:17:25 +00:00
|
|
|
d.isPendingTx = true
|
2022-09-28 08:43:37 +00:00
|
|
|
popup.store.authenticateAndTransfer(
|
2022-08-29 16:28:54 +00:00
|
|
|
popup.selectedAccount.address,
|
|
|
|
recipientAddress,
|
2023-02-17 12:56:31 +00:00
|
|
|
d.selectedSymbol,
|
|
|
|
amountToSendInput.cryptoValueToSend,
|
2023-08-15 18:21:51 +00:00
|
|
|
d.uuid)
|
2022-05-19 08:53:57 +00:00
|
|
|
}
|
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
|
2023-09-11 10:20:36 +00:00
|
|
|
if(!!popup.selectedAccount && d.isSelectedHoldingValidAsset && recipientLoader.ready && amountToSendInput.inputNumberValid) {
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.isLoading = true
|
2023-09-11 10:20:36 +00:00
|
|
|
let amount = Math.round(amountToSendInput.cryptoValueToSend * Math.pow(10, d.selectedHolding.decimals))
|
2023-08-15 18:21:51 +00:00
|
|
|
popup.store.suggestedRoutes(amount.toString(16), popup.sendType)
|
2022-02-01 21:03:47 +00:00
|
|
|
}
|
2022-05-19 08:53:57 +00:00
|
|
|
})
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
2022-12-19 13:02:56 +00:00
|
|
|
readonly property int errorType: !amountToSendInput.input.valid ? Constants.SendAmountExceedsBalance :
|
2023-08-15 18:21:51 +00:00
|
|
|
(popup.bestRoutes && popup.bestRoutes.count === 0 &&
|
|
|
|
!!amountToSendInput.input.text && recipientLoader.ready && !popup.isLoading) ?
|
2022-12-19 13:02:56 +00:00
|
|
|
Constants.NoRoute : Constants.NoError
|
2023-09-11 10:20:36 +00:00
|
|
|
readonly property double maxFiatBalance: isSelectedHoldingValidAsset ? selectedHolding.totalCurrencyBalance.amount : 0
|
|
|
|
readonly property double maxCryptoBalance: isSelectedHoldingValidAsset ? selectedHolding.totalBalance.amount : 0
|
2023-02-17 12:56:31 +00:00
|
|
|
readonly property double maxInputBalance: amountToSendInput.inputIsFiat ? maxFiatBalance : maxCryptoBalance
|
2023-08-15 18:21:51 +00:00
|
|
|
readonly property string selectedSymbol: store.selectedAssetSymbol
|
|
|
|
readonly property string inputSymbol: amountToSendInput.inputIsFiat ? popup.currencyStore.currentCurrency : selectedSymbol
|
2023-04-18 16:05:24 +00:00
|
|
|
readonly property bool errorMode: popup.isLoading || !recipientLoader.ready ? false : errorType !== Constants.NoError || networkSelector.errorMode || !amountToSendInput.inputNumberValid
|
2022-08-29 16:28:54 +00:00
|
|
|
readonly property string uuid: Utils.uuid()
|
2022-10-17 10:17:25 +00:00
|
|
|
property bool isPendingTx: false
|
2022-11-30 12:59:21 +00:00
|
|
|
property string totalTimeEstimate
|
2023-02-17 12:56:31 +00:00
|
|
|
property double totalFeesInFiat
|
|
|
|
property double totalAmountToReceive
|
2023-09-11 10:20:36 +00:00
|
|
|
|
|
|
|
property var selectedHolding: null
|
|
|
|
property var selectedHoldingType: Constants.HoldingType.Unknown
|
|
|
|
readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.HoldingType.Asset
|
|
|
|
property var hoveredHolding: null
|
|
|
|
property var hoveredHoldingType: Constants.HoldingType.Unknown
|
|
|
|
readonly property bool isHoveredHoldingValidAsset: !!hoveredHolding && hoveredHoldingType === Constants.HoldingType.Asset
|
|
|
|
|
|
|
|
function setSelectedHoldingId(holdingId, holdingType) {
|
|
|
|
let holding = store.getHolding(holdingId, holdingType)
|
|
|
|
setSelectedHolding(holding, holdingType)
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSelectedHolding(holding, holdingType) {
|
|
|
|
d.selectedHolding = holding
|
|
|
|
d.selectedHoldingType = holdingType
|
|
|
|
let selectorHolding = store.holdingToSelectorHolding(holding, holdingType)
|
|
|
|
holdingSelector.setSelectedItem(selectorHolding, holdingType)
|
|
|
|
}
|
|
|
|
|
|
|
|
function setHoveredHoldingId(holdingId, holdingType) {
|
|
|
|
let holding = store.getHolding(holdingId, holdingType)
|
|
|
|
setHoveredHolding(holding, holdingType)
|
|
|
|
}
|
|
|
|
|
|
|
|
function setHoveredHolding(holding, holdingType) {
|
|
|
|
d.hoveredHolding = holding
|
|
|
|
d.hoveredHoldingType = holdingType
|
|
|
|
let selectorHolding = store.holdingToSelectorHolding(holding, holdingType)
|
|
|
|
holdingSelector.setHoveredItem(selectorHolding, holdingType)
|
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
width: 556
|
2022-08-29 16:28:54 +00:00
|
|
|
topMargin: 64 + header.height
|
2023-07-05 19:32:02 +00:00
|
|
|
bottomPadding: footer.visible ? footer.height : 32
|
2022-07-27 21:10:00 +00:00
|
|
|
|
|
|
|
padding: 0
|
|
|
|
background: StatusDialogBackground {
|
|
|
|
color: Theme.palette.baseColor3
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
onSelectedAccountChanged: popup.recalculateRoutesAndFees()
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
onOpened: {
|
2022-12-14 21:06:14 +00:00
|
|
|
amountToSendInput.input.input.edit.forceActiveFocus()
|
2021-06-29 13:25:05 +00:00
|
|
|
|
2023-09-11 10:20:36 +00:00
|
|
|
if (popup.preSelectedHoldingType !== Constants.HoldingType.Unknown) {
|
|
|
|
if(!!popup.preSelectedHolding) {
|
|
|
|
d.setSelectedHolding(popup.preSelectedHolding, popup.preSelectedHoldingType)
|
|
|
|
} else if (!!popup.preSelectedHoldingID) {
|
|
|
|
d.setSelectedHoldingId(popup.preSelectedHoldingID, popup.preSelectedHoldingType)
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-05-19 08:53:57 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
if(!!popup.preDefinedAmountToSend) {
|
2022-12-14 21:06:14 +00:00
|
|
|
amountToSendInput.input.text = popup.preDefinedAmountToSend
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!!popup.preSelectedRecipient) {
|
2023-04-18 16:05:24 +00:00
|
|
|
recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address
|
|
|
|
recipientLoader.selectedRecipient = {address: popup.preSelectedRecipient}
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
|
|
|
|
if(popup.isBridgeTx) {
|
2023-04-18 16:05:24 +00:00
|
|
|
recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address
|
|
|
|
recipientLoader.selectedRecipient = {address: popup.selectedAccount.address}
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-11 09:24:26 +00:00
|
|
|
header: AccountsModalHeader {
|
2022-07-27 21:10:00 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: -height - 18
|
2023-06-28 09:16:30 +00:00
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: popup.store.senderAccounts
|
|
|
|
|
|
|
|
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
|
|
|
|
}
|
2023-04-24 18:35:34 +00:00
|
|
|
selectedAccount: !!popup.selectedAccount ? popup.selectedAccount: {}
|
2023-07-21 08:41:24 +00:00
|
|
|
getNetworkShortNames: function(chainIds) {return store.getNetworkShortNames(chainIds)}
|
2023-05-04 12:55:39 +00:00
|
|
|
onSelectedIndexChanged: store.switchSenderAccount(selectedIndex)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
|
2023-05-10 11:19:25 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: group1
|
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
anchors.fill: parent
|
2023-05-10 11:19:25 +00:00
|
|
|
|
|
|
|
ClippingWrapper {
|
2023-02-02 15:28:39 +00:00
|
|
|
Layout.fillWidth: true
|
2023-05-10 11:19:25 +00:00
|
|
|
Layout.preferredHeight: assetAndAmountSelector.implicitHeight
|
|
|
|
+ Style.current.halfPadding
|
|
|
|
z: 100
|
|
|
|
|
|
|
|
clipBottomMargin: 20
|
2022-06-27 13:41:47 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
Rectangle {
|
2023-05-10 11:19:25 +00:00
|
|
|
anchors.fill: parent
|
2023-02-02 15:28:39 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
color: Theme.palette.baseColor3
|
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
layer.enabled: scrollView.contentY > 0
|
2022-08-29 16:28:54 +00:00
|
|
|
layer.effect: DropShadow {
|
2022-11-30 18:57:00 +00:00
|
|
|
verticalOffset: 0
|
|
|
|
radius: 8
|
2022-08-29 16:28:54 +00:00
|
|
|
samples: 17
|
|
|
|
color: Theme.palette.dropShadow
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
|
2023-02-02 15:28:39 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: assetAndAmountSelector
|
|
|
|
|
|
|
|
anchors.fill: parent
|
2022-08-29 16:28:54 +00:00
|
|
|
anchors.leftMargin: Style.current.xlPadding
|
|
|
|
anchors.rightMargin: Style.current.xlPadding
|
2023-02-02 15:28:39 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
z: 1
|
2022-12-14 21:06:14 +00:00
|
|
|
spacing: 16
|
2022-08-29 16:28:54 +00:00
|
|
|
|
2022-12-14 21:06:14 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 8
|
2023-07-31 13:50:41 +00:00
|
|
|
Layout.preferredHeight: 44
|
2022-08-29 16:28:54 +00:00
|
|
|
StatusBaseText {
|
2022-10-17 10:17:25 +00:00
|
|
|
id: modalHeader
|
2022-12-14 21:06:14 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
2023-09-11 10:20:36 +00:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2022-11-23 17:58:22 +00:00
|
|
|
text: popup.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
|
2022-12-14 21:06:14 +00:00
|
|
|
font.pixelSize: 28
|
|
|
|
lineHeight: 38
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
font.letterSpacing: -0.4
|
2022-08-29 16:28:54 +00:00
|
|
|
color: Theme.palette.directColor1
|
2022-12-14 21:06:14 +00:00
|
|
|
Layout.maximumWidth: contentWidth
|
2022-08-18 20:49:50 +00:00
|
|
|
}
|
2023-09-11 10:20:36 +00:00
|
|
|
HoldingSelector {
|
|
|
|
id: holdingSelector
|
2022-12-14 21:06:14 +00:00
|
|
|
Layout.fillWidth: true
|
2023-09-11 10:20:36 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
assetsModel: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : null
|
|
|
|
collectiblesModel: popup.selectedAccount ? popup.nestedCollectiblesModel : null
|
2022-12-16 08:50:56 +00:00
|
|
|
currentCurrencySymbol: RootStore.currencyStore.currentCurrencySymbol
|
2023-09-11 10:20:36 +00:00
|
|
|
visible: !!d.selectedHolding || !!d.hoveredHolding
|
2022-12-16 08:50:56 +00:00
|
|
|
getNetworkIcon: function(chainId){
|
|
|
|
return RootStore.getNetworkIcon(chainId)
|
|
|
|
}
|
2023-09-11 10:20:36 +00:00
|
|
|
onItemSelected: {
|
|
|
|
d.setSelectedHoldingId(holdingId, holdingType)
|
2023-05-04 12:55:39 +00:00
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
2023-09-11 10:20:36 +00:00
|
|
|
|
2022-12-14 21:06:14 +00:00
|
|
|
StatusListItemTag {
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
|
|
|
Layout.preferredHeight: 22
|
2023-09-11 10:20:36 +00:00
|
|
|
visible: d.isSelectedHoldingValidAsset || d.isHoveredHoldingValidAsset
|
2023-01-27 12:19:23 +00:00
|
|
|
title: {
|
2023-09-11 10:20:36 +00:00
|
|
|
if(d.isHoveredHoldingValidAsset) {
|
|
|
|
const balance = popup.currencyStore.formatCurrencyAmount((amountToSendInput.inputIsFiat ? d.hoveredHolding.totalCurrencyBalance.amount : d.hoveredHolding.totalBalance.amount) , d.hoveredHolding.symbol)
|
2023-04-18 16:05:24 +00:00
|
|
|
return qsTr("Max: %1").arg(balance)
|
|
|
|
}
|
2023-02-17 12:56:31 +00:00
|
|
|
if (d.maxInputBalance <= 0)
|
2023-01-27 12:19:23 +00:00
|
|
|
return qsTr("No balances active")
|
2023-02-17 12:56:31 +00:00
|
|
|
const balance = popup.currencyStore.formatCurrencyAmount(d.maxInputBalance, d.inputSymbol)
|
2023-01-27 12:19:23 +00:00
|
|
|
return qsTr("Max: %1").arg(balance)
|
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
tagClickable: true
|
2022-12-14 21:06:14 +00:00
|
|
|
closeButtonVisible: false
|
|
|
|
titleText.font.pixelSize: 12
|
2023-04-18 16:05:24 +00:00
|
|
|
bgColor: amountToSendInput.input.valid || !amountToSendInput.input.text ? Theme.palette.primaryColor3 : Theme.palette.dangerColor2
|
|
|
|
titleText.color: amountToSendInput.input.valid || !amountToSendInput.input.text ? Theme.palette.primaryColor1 : Theme.palette.dangerColor1
|
2023-06-09 10:38:40 +00:00
|
|
|
onTagClicked: {
|
2023-06-14 09:07:20 +00:00
|
|
|
amountToSendInput.input.text = popup.currencyStore.formatCurrencyAmount(d.maxInputBalance, d.inputSymbol, {noSymbol: true, rawAmount: true}, LocaleUtils.userInputLocale)
|
2023-06-09 10:38:40 +00:00
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
TokenListView {
|
|
|
|
id: tokenListRect
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2023-09-11 10:20:36 +00:00
|
|
|
visible: !d.selectedHolding
|
2023-04-18 16:05:24 +00:00
|
|
|
assets: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : null
|
|
|
|
searchTokenSymbolByAddressFn: function (address) {
|
|
|
|
return store.findTokenSymbolByAddress(address)
|
|
|
|
}
|
|
|
|
getNetworkIcon: function(chainId){
|
|
|
|
return RootStore.getNetworkIcon(chainId)
|
|
|
|
}
|
|
|
|
onTokenSelected: {
|
2023-09-11 10:20:36 +00:00
|
|
|
d.setSelectedHoldingId(symbol, Constants.HoldingType.Asset)
|
2023-04-18 16:05:24 +00:00
|
|
|
}
|
|
|
|
onTokenHovered: {
|
2023-09-11 10:20:36 +00:00
|
|
|
if(hovered) {
|
|
|
|
d.setHoveredHoldingId(symbol, Constants.HoldingType.Asset)
|
|
|
|
} else {
|
|
|
|
d.setHoveredHoldingId("", Constants.HoldingType.Unknown)
|
|
|
|
}
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2022-12-14 21:06:14 +00:00
|
|
|
}
|
|
|
|
RowLayout {
|
2023-09-11 10:20:36 +00:00
|
|
|
visible: d.isSelectedHoldingValidAsset
|
2022-12-14 21:06:14 +00:00
|
|
|
AmountToSend {
|
|
|
|
id: amountToSendInput
|
|
|
|
Layout.fillWidth:true
|
|
|
|
isBridgeTx: popup.isBridgeTx
|
|
|
|
interactive: popup.interactive
|
2023-02-17 12:56:31 +00:00
|
|
|
selectedSymbol: d.selectedSymbol
|
|
|
|
maxInputBalance: d.maxInputBalance
|
2023-08-15 18:21:51 +00:00
|
|
|
currentCurrency: popup.currencyStore.currentCurrency
|
2022-12-19 13:02:56 +00:00
|
|
|
getFiatValue: function(cryptoValue) {
|
2023-02-17 12:56:31 +00:00
|
|
|
return selectedSymbol ? popup.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency) : 0.0
|
2022-12-19 13:02:56 +00:00
|
|
|
}
|
|
|
|
getCryptoValue: function(fiatValue) {
|
2023-02-17 12:56:31 +00:00
|
|
|
return selectedSymbol ? popup.currencyStore.getCryptoValue(fiatValue, selectedSymbol, currentCurrency) : 0.0
|
2022-12-19 13:02:56 +00:00
|
|
|
}
|
2023-02-17 12:56:31 +00:00
|
|
|
formatCurrencyAmount: popup.currencyStore.formatCurrencyAmount
|
2022-12-14 21:06:14 +00:00
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
2023-02-02 15:28:39 +00:00
|
|
|
|
|
|
|
// Horizontal spacer
|
|
|
|
RowLayout {}
|
|
|
|
|
2022-12-14 21:06:14 +00:00
|
|
|
AmountToReceive {
|
|
|
|
id: amountToReceive
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
Layout.fillWidth:true
|
2023-08-15 18:21:51 +00:00
|
|
|
visible: !!popup.bestRoutes && popup.bestRoutes !== undefined && popup.bestRoutes.count > 0 && amountToSendInput.inputNumberValid
|
2022-12-14 21:06:14 +00:00
|
|
|
isLoading: popup.isLoading
|
2023-02-17 12:56:31 +00:00
|
|
|
selectedSymbol: d.selectedSymbol
|
2022-12-14 21:06:14 +00:00
|
|
|
isBridgeTx: popup.isBridgeTx
|
2023-01-08 22:23:51 +00:00
|
|
|
cryptoValueToReceive: d.totalAmountToReceive
|
|
|
|
inputIsFiat: amountToSendInput.inputIsFiat
|
2023-02-17 14:09:15 +00:00
|
|
|
minCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals
|
|
|
|
minFiatDecimals: amountToSendInput.minReceiveFiatDecimals
|
2023-08-15 18:21:51 +00:00
|
|
|
currentCurrency: popup.currencyStore.currentCurrency
|
2023-01-08 22:23:51 +00:00
|
|
|
getFiatValue: function(cryptoValue) {
|
2023-02-17 12:56:31 +00:00
|
|
|
return popup.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency)
|
2023-01-08 22:23:51 +00:00
|
|
|
}
|
2023-02-17 12:56:31 +00:00
|
|
|
formatCurrencyAmount: popup.currencyStore.formatCurrencyAmount
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-10 11:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ClippingWrapper {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
implicitWidth: scrollView.implicitWidth
|
|
|
|
implicitHeight: scrollView.implicitHeight
|
|
|
|
|
|
|
|
clipTopMargin: 40
|
|
|
|
clipBottomMargin: popup.bottomPadding
|
2022-06-27 13:41:47 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2022-06-27 13:41:47 +00:00
|
|
|
id: scrollView
|
2023-05-10 11:19:25 +00:00
|
|
|
|
2022-12-14 21:06:14 +00:00
|
|
|
topPadding: 12
|
2023-05-10 11:19:25 +00:00
|
|
|
anchors.fill: parent
|
2023-05-31 20:58:23 +00:00
|
|
|
contentWidth: availableWidth
|
2023-02-15 14:55:16 +00:00
|
|
|
|
2023-05-10 11:19:25 +00:00
|
|
|
clip: false
|
2022-07-21 12:15:02 +00:00
|
|
|
objectName: "sendModalScroll"
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
Column {
|
|
|
|
id: layout
|
2022-07-20 11:15:05 +00:00
|
|
|
width: scrollView.availableWidth
|
2022-11-23 17:58:22 +00:00
|
|
|
spacing: Style.current.bigPadding
|
2022-07-14 17:47:59 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
|
2023-04-18 16:05:24 +00:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: 8
|
2022-08-29 16:28:54 +00:00
|
|
|
width: parent.width
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2023-09-11 10:20:36 +00:00
|
|
|
visible: !isBridgeTx && !!d.selectedHolding
|
2023-04-18 16:05:24 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: label
|
|
|
|
elide: Text.ElideRight
|
|
|
|
text: qsTr("To")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
2022-08-25 19:20:21 +00:00
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
RecipientView {
|
|
|
|
id: recipientLoader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
store: popup.store
|
|
|
|
isBridgeTx: popup.isBridgeTx
|
|
|
|
interactive: popup.interactive
|
2023-09-11 10:20:36 +00:00
|
|
|
selectedAsset: d.selectedHolding
|
2023-04-18 16:05:24 +00:00
|
|
|
onIsLoading: popup.isLoading = true
|
|
|
|
onRecalculateRoutesAndFees: popup.recalculateRoutesAndFees()
|
2022-07-27 21:10:00 +00:00
|
|
|
}
|
2021-04-22 04:03:46 +00:00
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-07-20 11:15:05 +00:00
|
|
|
TabAddressSelectorView {
|
|
|
|
id: addressSelector
|
2022-08-29 16:28:54 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2022-07-20 11:15:05 +00:00
|
|
|
store: popup.store
|
2023-04-06 12:59:24 +00:00
|
|
|
selectedAccount: popup.selectedAccount
|
2023-04-18 16:05:24 +00:00
|
|
|
onRecipientSelected: {
|
|
|
|
recipientLoader.selectedRecipientType = type
|
|
|
|
recipientLoader.selectedRecipient = recipient
|
2022-07-20 11:15:05 +00:00
|
|
|
}
|
2023-09-11 10:20:36 +00:00
|
|
|
visible: !recipientLoader.ready && !isBridgeTx && !!d.selectedHolding
|
2022-05-19 08:53:57 +00:00
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-07-20 11:15:05 +00:00
|
|
|
NetworkSelector {
|
|
|
|
id: networkSelector
|
2022-08-29 16:28:54 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2022-07-20 11:15:05 +00:00
|
|
|
store: popup.store
|
2022-10-17 10:17:25 +00:00
|
|
|
interactive: popup.interactive
|
2022-07-20 11:15:05 +00:00
|
|
|
selectedAccount: popup.selectedAccount
|
2023-04-18 16:05:24 +00:00
|
|
|
ensAddressOrEmpty: recipientLoader.isENSValid ? recipientLoader.resolvedENSAddress : ""
|
2023-01-08 22:23:51 +00:00
|
|
|
amountToSend: amountToSendInput.cryptoValueToSend
|
2023-02-17 14:09:15 +00:00
|
|
|
minSendCryptoDecimals: amountToSendInput.minSendCryptoDecimals
|
|
|
|
minReceiveCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals
|
2023-09-11 10:20:36 +00:00
|
|
|
selectedAsset: d.selectedHolding
|
2022-10-17 10:17:25 +00:00
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
|
2023-09-11 10:20:36 +00:00
|
|
|
visible: recipientLoader.ready && !!d.selectedHolding && amountToSendInput.inputNumberValid
|
2022-12-19 13:02:56 +00:00
|
|
|
errorType: d.errorType
|
2022-10-17 10:17:25 +00:00
|
|
|
isLoading: popup.isLoading
|
2022-11-23 17:58:22 +00:00
|
|
|
isBridgeTx: popup.isBridgeTx
|
2022-07-20 11:15:05 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
FeesView {
|
2022-07-20 11:15:05 +00:00
|
|
|
id: fees
|
2022-08-29 16:28:54 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2023-09-11 10:20:36 +00:00
|
|
|
visible: recipientLoader.ready && !!d.selectedHolding && networkSelector.advancedOrCustomMode && amountToSendInput.inputNumberValid
|
2023-02-17 12:56:31 +00:00
|
|
|
selectedTokenSymbol: d.selectedSymbol
|
2022-11-23 17:58:22 +00:00
|
|
|
isLoading: popup.isLoading
|
|
|
|
bestRoutes: popup.bestRoutes
|
|
|
|
store: popup.store
|
2022-11-30 12:59:21 +00:00
|
|
|
gasFiatAmount: d.totalFeesInFiat
|
2022-12-19 13:02:56 +00:00
|
|
|
errorType: d.errorType
|
2022-07-01 11:24:32 +00:00
|
|
|
}
|
2020-08-20 04:45:29 +00:00
|
|
|
}
|
2020-10-19 09:39:07 +00:00
|
|
|
}
|
2020-08-20 04:45:29 +00:00
|
|
|
}
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
|
|
|
|
2022-07-27 21:10:00 +00:00
|
|
|
footer: SendModalFooter {
|
2022-11-23 17:58:22 +00:00
|
|
|
nextButtonText: popup.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
|
2023-08-15 18:21:51 +00:00
|
|
|
maxFiatFees: popup.isLoading ? "..." : popup.currencyStore.formatCurrencyAmount(d.totalFeesInFiat, popup.currencyStore.currentCurrency)
|
2022-11-30 12:59:21 +00:00
|
|
|
totalTimeEstimate: popup.isLoading? "..." : d.totalTimeEstimate
|
2022-10-20 12:58:56 +00:00
|
|
|
pending: d.isPendingTx || popup.isLoading
|
2023-04-18 16:05:24 +00:00
|
|
|
visible: recipientLoader.ready && amountToSendInput.inputNumberValid && !d.errorMode
|
2022-10-17 10:17:25 +00:00
|
|
|
onNextButtonClicked: popup.sendTransaction()
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2021-07-05 12:34:56 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
Component {
|
|
|
|
id: transactionSettingsConfirmationPopupComponent
|
|
|
|
TransactionSettingsConfirmationPopup {}
|
|
|
|
}
|
2021-07-05 12:34:56 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
Connections {
|
2023-04-20 08:41:45 +00:00
|
|
|
target: popup.store.walletSectionSendInst
|
2023-08-15 18:21:51 +00:00
|
|
|
function onSuggestedRoutesReady(txRoutes) {
|
|
|
|
popup.bestRoutes = txRoutes.suggestedRoutes
|
|
|
|
let gasTimeEstimate = txRoutes.gasTimeEstimate
|
2022-11-30 12:59:21 +00:00
|
|
|
d.totalTimeEstimate = popup.store.getLabelForEstimatedTxTime(gasTimeEstimate.totalTime)
|
2023-08-15 18:21:51 +00:00
|
|
|
d.totalFeesInFiat = popup.currencyStore.getFiatValue( gasTimeEstimate.totalFeesInEth, "ETH", popup.currencyStore.currentCurrency) +
|
|
|
|
popup.currencyStore.getFiatValue(gasTimeEstimate.totalTokenFees, fees.selectedTokenSymbol, popup.currencyStore.currentCurrency)
|
2023-09-11 10:20:36 +00:00
|
|
|
d.totalAmountToReceive = popup.store.getWei2Eth(txRoutes.amountToReceive, d.selectedHolding.decimals)
|
2023-08-15 18:21:51 +00:00
|
|
|
networkSelector.toNetworksList = txRoutes.toNetworksModel
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.isLoading = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
Connections {
|
2023-04-20 08:41:45 +00:00
|
|
|
target: popup.store.walletSectionSendInst
|
2023-08-15 18:21:51 +00:00
|
|
|
function onTransactionSent(chainId: int, txHash: string, uuid: string, error: string) {
|
2022-10-17 10:17:25 +00:00
|
|
|
d.isPendingTx = false
|
2023-08-15 18:21:51 +00:00
|
|
|
if (uuid !== d.uuid) return
|
|
|
|
if (!!error) {
|
|
|
|
if (error.includes(Constants.walletSection.cancelledMessage)) {
|
|
|
|
return
|
2022-02-24 19:24:58 +00:00
|
|
|
}
|
2023-08-15 18:21:51 +00:00
|
|
|
sendingError.text = error
|
|
|
|
return sendingError.open()
|
2022-02-24 19:24:58 +00:00
|
|
|
}
|
2023-08-15 18:21:51 +00:00
|
|
|
let url = "%1/%2".arg(popup.store.getEtherscanLink(chainId)).arg(txHash)
|
|
|
|
Global.displayToastMessage(qsTr("Transaction pending..."),
|
|
|
|
qsTr("View on etherscan"),
|
|
|
|
"",
|
|
|
|
true,
|
|
|
|
Constants.ephemeralNotificationType.normal,
|
|
|
|
url)
|
|
|
|
popup.close()
|
2022-02-24 19:24:58 +00:00
|
|
|
}
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|