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
|
2023-09-15 08:51:06 +00:00
|
|
|
import shared.stores.send 1.0
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2023-11-28 19:16:18 +00:00
|
|
|
import StatusQ 0.1
|
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
|
|
|
|
2023-09-05 15:27:30 +00:00
|
|
|
import "./panels"
|
|
|
|
import "./controls"
|
|
|
|
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
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
property var preSelectedAccount: store.selectedSenderAccount
|
2023-09-27 13:41:55 +00:00
|
|
|
// expected content depends on the preSelectedRecipientType value.
|
|
|
|
// If type Address this must be a string else it expects an object. See RecipientView.selectedRecipientType
|
|
|
|
property var preSelectedRecipient
|
|
|
|
property int preSelectedRecipientType: TabAddressSelectorView.Type.Address
|
2022-10-17 10:17:25 +00:00
|
|
|
property string preDefinedAmountToSend
|
2023-09-27 13:41:55 +00:00
|
|
|
// token symbol
|
2023-09-11 10:20:36 +00:00
|
|
|
property string preSelectedHoldingID
|
2023-11-07 22:45:47 +00:00
|
|
|
property int preSelectedHoldingType: Constants.TokenType.Unknown
|
2023-09-20 16:07:09 +00:00
|
|
|
property int preSelectedSendType
|
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
|
|
|
|
|
2023-11-28 19:16:18 +00:00
|
|
|
required property TransactionStore store
|
2023-09-11 10:20:36 +00:00
|
|
|
property var nestedCollectiblesModel: store.nestedCollectiblesModel
|
2022-10-17 10:17:25 +00:00
|
|
|
property var bestRoutes
|
|
|
|
property bool isLoading: false
|
2023-08-31 10:27:15 +00:00
|
|
|
|
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() {
|
|
|
|
d.isPendingTx = true
|
2023-09-20 16:07:09 +00:00
|
|
|
popup.store.authenticateAndTransfer(amountToSendInput.cryptoValueToSend, 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-20 13:01:37 +00:00
|
|
|
if(!!popup.preSelectedAccount && !!holdingSelector.selectedItem
|
2023-09-15 08:51:06 +00:00
|
|
|
&& recipientLoader.ready && amountToSendInput.inputNumberValid) {
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.isLoading = true
|
2023-09-20 16:07:09 +00:00
|
|
|
popup.store.suggestedRoutes(d.isERC721Transfer ? "1" : amountToSendInput.cryptoValueToSend)
|
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
|
2023-11-09 08:21:25 +00:00
|
|
|
|
|
|
|
property bool ensOrStickersPurpose: popup.preSelectedSendType === Constants.SendType.ENSRegister ||
|
|
|
|
popup.preSelectedSendType === Constants.SendType.ENSRelease ||
|
|
|
|
popup.preSelectedSendType === Constants.SendType.ENSSetPubKey ||
|
|
|
|
popup.preSelectedSendType === Constants.SendType.StickersBuy
|
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
readonly property var currencyStore: store.currencyStore
|
2023-08-31 10:27:15 +00:00
|
|
|
readonly property int errorType: !amountToSendInput.input.valid && !isERC721Transfer ? 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-11-28 19:16:18 +00:00
|
|
|
readonly property double totalSelectedHoldingBalance: isSelectedHoldingValidAsset ? !d.selectedHolding.communityId ? selectedHoldingAggregator.value/(10 ** d.selectedHolding.decimals): selectedHoldingAggregator.value: 0
|
|
|
|
readonly property double maxFiatBalance: isSelectedHoldingValidAsset && selectedHolding.marketDetails ? totalSelectedHoldingBalance * selectedHolding.marketDetails.currencyPrice.amount : 0
|
|
|
|
readonly property double maxCryptoBalance: isSelectedHoldingValidAsset ? totalSelectedHoldingBalance : 0
|
2023-02-17 12:56:31 +00:00
|
|
|
readonly property double maxInputBalance: amountToSendInput.inputIsFiat ? maxFiatBalance : maxCryptoBalance
|
2023-09-26 13:45:44 +00:00
|
|
|
readonly property string inputSymbol: amountToSendInput.inputIsFiat ? currencyStore.currentCurrency : store.selectedAssetSymbol
|
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-20 16:07:09 +00:00
|
|
|
readonly property bool isBridgeTx: store.sendType === Constants.SendType.Bridge
|
|
|
|
readonly property bool isERC721Transfer: store.sendType === Constants.SendType.ERC721Transfer
|
2023-09-11 10:20:36 +00:00
|
|
|
property var selectedHolding: null
|
2023-11-07 22:45:47 +00:00
|
|
|
property var selectedHoldingType: Constants.TokenType.Unknown
|
|
|
|
readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.TokenType.ERC20
|
2023-09-11 10:20:36 +00:00
|
|
|
property var hoveredHolding: null
|
2023-11-07 22:45:47 +00:00
|
|
|
property var hoveredHoldingType: Constants.TokenType.Unknown
|
|
|
|
readonly property bool isHoveredHoldingValidAsset: !!hoveredHolding && hoveredHoldingType === Constants.TokenType.ERC20
|
2023-09-11 10:20:36 +00:00
|
|
|
|
|
|
|
function setSelectedHoldingId(holdingId, holdingType) {
|
|
|
|
let holding = store.getHolding(holdingId, holdingType)
|
|
|
|
setSelectedHolding(holding, holdingType)
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSelectedHolding(holding, holdingType) {
|
|
|
|
d.selectedHoldingType = holdingType
|
2023-08-31 10:27:15 +00:00
|
|
|
d.selectedHolding = holding
|
2023-09-11 10:20:36 +00:00
|
|
|
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.hoveredHoldingType = holdingType
|
2023-08-31 10:27:15 +00:00
|
|
|
d.hoveredHolding = holding
|
2023-09-11 10:20:36 +00:00
|
|
|
let selectorHolding = store.holdingToSelectorHolding(holding, holdingType)
|
|
|
|
holdingSelector.setHoveredItem(selectorHolding, holdingType)
|
|
|
|
}
|
2023-08-31 10:27:15 +00:00
|
|
|
|
|
|
|
onSelectedHoldingChanged: {
|
2023-11-07 22:45:47 +00:00
|
|
|
if (d.selectedHoldingType === Constants.TokenType.ERC20) {
|
2023-11-09 08:21:25 +00:00
|
|
|
if(!d.ensOrStickersPurpose && store.sendType !== Constants.SendType.Bridge)
|
2023-09-20 16:07:09 +00:00
|
|
|
store.setSendType(Constants.SendType.Transfer)
|
2023-08-31 10:27:15 +00:00
|
|
|
store.setSelectedAssetSymbol(selectedHolding.symbol)
|
2023-11-24 08:48:50 +00:00
|
|
|
store.setSelectedTokenIsOwnerToken(false)
|
2023-11-07 22:45:47 +00:00
|
|
|
} else if (d.selectedHoldingType === Constants.TokenType.ERC721) {
|
2023-09-20 16:07:09 +00:00
|
|
|
store.setSendType(Constants.SendType.ERC721Transfer)
|
2023-08-31 10:27:15 +00:00
|
|
|
amountToSendInput.input.text = 1
|
|
|
|
store.setSelectedAssetSymbol(selectedHolding.contractAddress+":"+selectedHolding.tokenId)
|
|
|
|
store.setRouteEnabledFromChains(selectedHolding.chainId)
|
|
|
|
store.updateRoutePreferredChains(selectedHolding.chainId)
|
2023-11-24 08:48:50 +00:00
|
|
|
store.setSelectedTokenIsOwnerToken(selectedHolding.communityPrivilegesLevel === Constants.TokenPrivilegesLevel.Owner)
|
2023-08-31 10:27:15 +00:00
|
|
|
}
|
2023-11-24 08:48:50 +00:00
|
|
|
store.setSelectedTokenName(selectedHolding.name)
|
|
|
|
|
2023-08-31 10:27:15 +00:00
|
|
|
recalculateRoutesAndFees()
|
|
|
|
}
|
2023-11-09 10:48:41 +00:00
|
|
|
|
|
|
|
function prepareForMaxSend(value, symbol) {
|
|
|
|
if(symbol !== "ETH") {
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
|
|
|
|
return value - Math.max(0.0001, Math.min(0.01, value * 0.1))
|
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
|
2023-11-28 19:16:18 +00:00
|
|
|
SumAggregator {
|
|
|
|
id: selectedHoldingAggregator
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: d.isSelectedHoldingValidAsset ? d.selectedHolding.balances: d.isHoveredHoldingValidAsset && !!d.hoveredHolding.symbol ? d.hoveredHolding.balances: null
|
|
|
|
filters: FastExpressionFilter {
|
|
|
|
expression: {
|
|
|
|
store.selectedSenderAccount
|
|
|
|
return store.selectedSenderAccount.address === model.account
|
|
|
|
}
|
|
|
|
expectedRoles: ["account"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
roleName: "balance"
|
|
|
|
}
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
width: 556
|
2022-07-27 21:10:00 +00:00
|
|
|
|
|
|
|
padding: 0
|
|
|
|
background: StatusDialogBackground {
|
|
|
|
color: Theme.palette.baseColor3
|
|
|
|
}
|
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-20 16:07:09 +00:00
|
|
|
if(popup.preSelectedSendType !== Constants.SendType.Unknown) {
|
|
|
|
store.setSendType(popup.preSelectedSendType)
|
|
|
|
}
|
2023-11-07 22:45:47 +00:00
|
|
|
if ((popup.preSelectedHoldingType > Constants.TokenType.Native) &&
|
|
|
|
(popup.preSelectedHoldingType < Constants.TokenType.ERC1155)) {
|
2023-09-12 14:26:38 +00:00
|
|
|
tokenListRect.browsingHoldingType = popup.preSelectedHoldingType
|
2023-09-26 13:45:44 +00:00
|
|
|
if (!!popup.preSelectedHoldingID) {
|
2023-09-11 10:20:36 +00:00
|
|
|
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-09-27 13:41:55 +00:00
|
|
|
recipientLoader.selectedRecipientType = popup.preSelectedRecipientType
|
|
|
|
if (popup.preSelectedRecipientType == TabAddressSelectorView.Type.Address) {
|
|
|
|
recipientLoader.selectedRecipient = {address: popup.preSelectedRecipient}
|
|
|
|
} else {
|
|
|
|
recipientLoader.selectedRecipient = popup.preSelectedRecipient
|
|
|
|
}
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
|
2023-08-31 10:27:15 +00:00
|
|
|
if(d.isBridgeTx) {
|
2023-04-18 16:05:24 +00:00
|
|
|
recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address
|
2023-09-20 13:01:37 +00:00
|
|
|
recipientLoader.selectedRecipient = {address: popup.preSelectedAccount.address}
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-31 10:27:15 +00:00
|
|
|
onClosed: popup.store.resetStoredProperties()
|
|
|
|
|
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-09-20 13:01:37 +00:00
|
|
|
selectedAccount: !!popup.preSelectedAccount ? popup.preSelectedAccount: {}
|
2023-07-21 08:41:24 +00:00
|
|
|
getNetworkShortNames: function(chainIds) {return store.getNetworkShortNames(chainIds)}
|
2023-09-20 16:07:09 +00:00
|
|
|
onSelectedIndexChanged: {
|
|
|
|
store.switchSenderAccount(selectedIndex)
|
2023-11-28 19:16:18 +00:00
|
|
|
if (d.isSelectedHoldingValidAsset) {
|
|
|
|
d.setSelectedHoldingId(d.selectedHolding.symbol, d.selectedHoldingType)
|
|
|
|
}
|
2023-09-20 16:07:09 +00:00
|
|
|
popup.recalculateRoutesAndFees()
|
|
|
|
}
|
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
|
2023-08-31 10:27:15 +00:00
|
|
|
text: d.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-15 08:51:06 +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
|
2023-11-28 19:16:18 +00:00
|
|
|
selectedSenderAccount: store.selectedSenderAccount.address
|
|
|
|
assetsModel: popup.store.walletAssetStore.groupedAccountAssetsModel
|
2023-09-20 13:01:37 +00:00
|
|
|
collectiblesModel: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
|
2023-10-30 22:18:58 +00:00
|
|
|
networksModel: popup.store.allNetworksModel
|
2023-09-26 13:45:44 +00:00
|
|
|
currentCurrencySymbol: d.currencyStore.currentCurrencySymbol
|
2023-11-07 22:45:47 +00:00
|
|
|
visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.TokenType.Unknown) ||
|
|
|
|
(!!d.hoveredHolding && d.hoveredHoldingType !== Constants.TokenType.Unknown)
|
2023-09-11 10:20:36 +00:00
|
|
|
onItemSelected: {
|
|
|
|
d.setSelectedHoldingId(holdingId, holdingType)
|
2023-05-04 12:55:39 +00:00
|
|
|
}
|
2023-11-28 19:16:18 +00:00
|
|
|
getCurrencyAmountFromBigInt: function(balance, symbol, decimals){
|
|
|
|
return store.getCurrencyAmountFromBigInt(balance, symbol, decimals)
|
|
|
|
}
|
|
|
|
getCurrentCurrencyAmount: function(balance){
|
|
|
|
return store.getCurrentCurrencyAmount(balance)
|
|
|
|
}
|
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 {
|
2023-12-05 13:32:15 +00:00
|
|
|
Layout.maximumWidth: 300
|
2022-12-14 21:06:14 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
|
|
|
Layout.preferredHeight: 22
|
2023-08-31 10:27:15 +00:00
|
|
|
visible: d.isSelectedHoldingValidAsset || d.isHoveredHoldingValidAsset && !d.isERC721Transfer
|
2023-01-27 12:19:23 +00:00
|
|
|
title: {
|
2023-08-31 10:27:15 +00:00
|
|
|
if(d.isHoveredHoldingValidAsset && !!d.hoveredHolding.symbol) {
|
2023-11-28 19:16:18 +00:00
|
|
|
let totalAmount = !d.hoveredHolding.communityId ? selectedHoldingAggregator.value/(10 ** d.hoveredHolding.decimals): selectedHoldingAggregator.value
|
|
|
|
const input = amountToSendInput.inputIsFiat ? totalAmount * d.hoveredHolding.marketDetails.currencyPrice.amount : totalAmount
|
2023-11-09 10:48:41 +00:00
|
|
|
const max = d.prepareForMaxSend(input, d.hoveredHolding.symbol)
|
|
|
|
if (max <= 0)
|
|
|
|
return qsTr("No balances active")
|
|
|
|
const balance = d.currencyStore.formatCurrencyAmount(max , d.hoveredHolding.symbol)
|
2023-11-28 19:16:18 +00:00
|
|
|
return qsTr("Max: %1").arg(balance.toString())
|
2023-04-18 16:05:24 +00:00
|
|
|
}
|
2023-11-09 10:48:41 +00:00
|
|
|
const max = d.prepareForMaxSend(d.maxInputBalance, d.inputSymbol)
|
|
|
|
if (max <= 0)
|
2023-01-27 12:19:23 +00:00
|
|
|
return qsTr("No balances active")
|
2023-11-09 10:48:41 +00:00
|
|
|
|
|
|
|
const balance = d.currencyStore.formatCurrencyAmount(max, d.inputSymbol)
|
2023-11-28 19:16:18 +00:00
|
|
|
return qsTr("Max: %1").arg(balance.toString())
|
2023-01-27 12:19:23 +00:00
|
|
|
}
|
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-11-09 10:48:41 +00:00
|
|
|
const max = d.prepareForMaxSend(d.maxInputBalance, d.inputSymbol)
|
|
|
|
amountToSendInput.input.text = d.currencyStore.formatCurrencyAmount(max, d.inputSymbol, {noSymbol: true, rawAmount: true}, LocaleUtils.userInputLocale)
|
2023-06-09 10:38:40 +00:00
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-14 21:06:14 +00:00
|
|
|
RowLayout {
|
2023-08-31 10:27:15 +00:00
|
|
|
visible: d.isSelectedHoldingValidAsset && !d.isERC721Transfer
|
2022-12-14 21:06:14 +00:00
|
|
|
AmountToSend {
|
|
|
|
id: amountToSendInput
|
2023-09-15 08:51:06 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2023-08-31 10:27:15 +00:00
|
|
|
isBridgeTx: d.isBridgeTx
|
2022-12-14 21:06:14 +00:00
|
|
|
interactive: popup.interactive
|
2023-09-20 16:07:09 +00:00
|
|
|
selectedSymbol: store.selectedAssetSymbol
|
2023-02-17 12:56:31 +00:00
|
|
|
maxInputBalance: d.maxInputBalance
|
2023-09-26 13:45:44 +00:00
|
|
|
currentCurrency: d.currencyStore.currentCurrency
|
2023-09-15 08:51:06 +00:00
|
|
|
|
2023-11-28 19:16:18 +00:00
|
|
|
multiplierIndex: !!holdingSelector.selectedItem
|
2023-09-15 08:51:06 +00:00
|
|
|
? holdingSelector.selectedItem.decimals
|
|
|
|
: 0
|
|
|
|
|
2022-12-19 13:02:56 +00:00
|
|
|
getFiatValue: function(cryptoValue) {
|
2023-09-26 13:45:44 +00:00
|
|
|
return selectedSymbol ? d.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency) : 0.0
|
2022-12-19 13:02:56 +00:00
|
|
|
}
|
2023-09-15 08:51:06 +00:00
|
|
|
|
2022-12-19 13:02:56 +00:00
|
|
|
getCryptoValue: function(fiatValue) {
|
2023-09-26 13:45:44 +00:00
|
|
|
return selectedSymbol ? d.currencyStore.getCryptoValue(fiatValue, selectedSymbol, currentCurrency) : 0.0
|
2022-12-19 13:02:56 +00:00
|
|
|
}
|
2023-09-15 08:51:06 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
formatCurrencyAmount: d.currencyStore.formatCurrencyAmount
|
2022-12-14 21:06:14 +00:00
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
|
2023-10-30 09:34:07 +00:00
|
|
|
input.input.tabNavItem: recipientLoader.item
|
|
|
|
Keys.onTabPressed: event.accepted = true
|
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-31 10:27:15 +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-09-20 16:07:09 +00:00
|
|
|
selectedSymbol: store.selectedAssetSymbol
|
2023-08-31 10:27:15 +00:00
|
|
|
isBridgeTx: d.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-09-26 13:45:44 +00:00
|
|
|
currentCurrency: d.currencyStore.currentCurrency
|
2023-01-08 22:23:51 +00:00
|
|
|
getFiatValue: function(cryptoValue) {
|
2023-09-26 13:45:44 +00:00
|
|
|
return d.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency)
|
2023-01-08 22:23:51 +00:00
|
|
|
}
|
2023-09-26 13:45:44 +00:00
|
|
|
formatCurrencyAmount: d.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
|
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-09-18 09:45:37 +00:00
|
|
|
TokenListView {
|
|
|
|
id: tokenListRect
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
|
|
|
|
|
|
|
visible: !d.selectedHolding
|
2023-11-28 19:16:18 +00:00
|
|
|
selectedSenderAccount: store.selectedSenderAccount.address
|
|
|
|
assets: popup.store.walletAssetStore.groupedAccountAssetsModel
|
2023-09-20 13:01:37 +00:00
|
|
|
collectibles: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
|
2023-10-30 22:18:58 +00:00
|
|
|
networksModel: popup.store.allNetworksModel
|
2023-09-18 09:45:37 +00:00
|
|
|
onlyAssets: holdingSelector.onlyAssets
|
2023-10-30 22:18:58 +00:00
|
|
|
// TODO remove this as address should be found directly in model itself
|
2023-09-18 09:45:37 +00:00
|
|
|
searchTokenSymbolByAddressFn: function (address) {
|
|
|
|
return store.findTokenSymbolByAddress(address)
|
|
|
|
}
|
|
|
|
onTokenSelected: {
|
|
|
|
d.setSelectedHoldingId(symbol, holdingType)
|
|
|
|
}
|
|
|
|
onTokenHovered: {
|
|
|
|
if(hovered) {
|
|
|
|
d.setHoveredHoldingId(symbol, holdingType)
|
|
|
|
} else {
|
2023-11-07 22:45:47 +00:00
|
|
|
d.setHoveredHoldingId("", Constants.TokenType.Unknown)
|
2023-09-18 09:45:37 +00:00
|
|
|
}
|
|
|
|
}
|
2023-11-28 19:16:18 +00:00
|
|
|
getCurrencyAmountFromBigInt: function(balance, symbol, decimals){
|
|
|
|
return store.getCurrencyAmountFromBigInt(balance, symbol, decimals)
|
|
|
|
}
|
|
|
|
getCurrentCurrencyAmount: function(balance){
|
|
|
|
return store.getCurrentCurrencyAmount(balance)
|
|
|
|
}
|
2023-09-18 09:45:37 +00:00
|
|
|
}
|
|
|
|
|
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-08-31 10:27:15 +00:00
|
|
|
visible: !d.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
|
2023-08-31 10:27:15 +00:00
|
|
|
isERC721Transfer: d.isERC721Transfer
|
|
|
|
isBridgeTx: d.isBridgeTx
|
2023-04-18 16:05:24 +00:00
|
|
|
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()
|
2023-09-20 16:07:09 +00:00
|
|
|
onAddressTextChanged: store.setSelectedRecipient(addressText)
|
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-09-20 13:01:37 +00:00
|
|
|
selectedAccount: popup.preSelectedAccount
|
2023-04-18 16:05:24 +00:00
|
|
|
onRecipientSelected: {
|
|
|
|
recipientLoader.selectedRecipientType = type
|
|
|
|
recipientLoader.selectedRecipient = recipient
|
2022-07-20 11:15:05 +00:00
|
|
|
}
|
2023-08-31 10:27:15 +00:00
|
|
|
visible: !recipientLoader.ready && !d.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
|
2023-09-15 08:51:06 +00:00
|
|
|
|
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
|
2023-09-20 13:01:37 +00:00
|
|
|
selectedAccount: popup.preSelectedAccount
|
2023-09-19 15:06:57 +00:00
|
|
|
ensAddressOrEmpty: recipientLoader.resolvedENSAddress
|
2023-09-15 08:51:06 +00:00
|
|
|
amountToSend: amountToSendInput.cryptoValueToSendFloat
|
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
|
2023-08-31 10:27:15 +00:00
|
|
|
isBridgeTx: d.isBridgeTx
|
|
|
|
isERC721Transfer: d.isERC721Transfer
|
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-09-20 16:07:09 +00:00
|
|
|
selectedTokenSymbol: store.selectedAssetSymbol
|
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 {
|
2023-09-25 12:39:54 +00:00
|
|
|
width: parent.width
|
2023-08-31 10:27:15 +00:00
|
|
|
nextButtonText: d.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
|
2023-09-26 13:45:44 +00:00
|
|
|
maxFiatFees: popup.isLoading ? "..." : d.currencyStore.formatCurrencyAmount(d.totalFeesInFiat, d.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-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-09-26 13:45:44 +00:00
|
|
|
d.totalFeesInFiat = d.currencyStore.getFiatValue( gasTimeEstimate.totalFeesInEth, "ETH", d.currencyStore.currentCurrency) +
|
|
|
|
d.currencyStore.getFiatValue(gasTimeEstimate.totalTokenFees, fees.selectedTokenSymbol, d.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) {
|
2023-11-02 11:40:43 +00:00
|
|
|
if (error.includes(Constants.walletSection.authenticationCanceled)) {
|
2023-08-15 18:21:51 +00:00
|
|
|
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
|
|
|
popup.close()
|
2022-02-24 19:24:58 +00:00
|
|
|
}
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|