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
|
|
|
|
2024-06-07 12:27:56 +00:00
|
|
|
import AppLayouts.Wallet 1.0
|
|
|
|
|
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
|
2024-06-07 12:27:56 +00:00
|
|
|
import shared.controls 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
|
|
|
|
2024-06-10 10:37:39 +00:00
|
|
|
import AppLayouts.Wallet.controls 1.0
|
|
|
|
|
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
|
2024-03-05 14:08:49 +00:00
|
|
|
popup.store.authenticateAndTransfer(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
|
2024-06-05 12:28:24 +00:00
|
|
|
&& recipientLoader.ready && (amountToSendInput.inputNumberValid || d.isCollectiblesTransfer)) {
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.isLoading = true
|
2024-03-05 09:27:40 +00:00
|
|
|
popup.store.suggestedRoutes(d.isCollectiblesTransfer ? "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
|
2024-03-05 09:27:40 +00:00
|
|
|
readonly property int errorType: !amountToSendInput.input.valid && (!isCollectiblesTransfer) ? 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
|
2024-01-30 13:15:58 +00:00
|
|
|
readonly property double maxFiatBalance: isSelectedHoldingValidAsset ? selectedHolding.currentCurrencyBalance : 0
|
|
|
|
readonly property double maxCryptoBalance: isSelectedHoldingValidAsset ? selectedHolding.currentBalance : 0
|
2023-02-17 12:56:31 +00:00
|
|
|
readonly property double maxInputBalance: amountToSendInput.inputIsFiat ? maxFiatBalance : maxCryptoBalance
|
2024-02-05 16:44:49 +00:00
|
|
|
readonly property string inputSymbol: amountToSendInput.inputIsFiat ? currencyStore.currentCurrency : !!d.selectedHolding && !!d.selectedHolding.symbol ? d.selectedHolding.symbol: ""
|
2024-06-10 10:31:13 +00:00
|
|
|
readonly property bool errorMode: popup.isLoading || !recipientLoader.ready ? false : errorType !== Constants.NoError || networkSelector.errorMode || !(amountToSendInput.inputNumberValid || d.isCollectiblesTransfer)
|
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
|
2024-03-05 09:27:40 +00:00
|
|
|
readonly property bool isCollectiblesTransfer: store.sendType === Constants.SendType.ERC721Transfer ||
|
|
|
|
store.sendType === Constants.SendType.ERC1155Transfer
|
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)
|
2024-02-05 16:44:49 +00:00
|
|
|
store.setSelectedAssetKey(selectedHolding.tokensKey)
|
2023-11-24 08:48:50 +00:00
|
|
|
store.setSelectedTokenIsOwnerToken(false)
|
2024-03-05 09:27:40 +00:00
|
|
|
} else if (d.selectedHoldingType === Constants.TokenType.ERC721 ||
|
|
|
|
d.selectedHoldingType === Constants.TokenType.ERC1155) {
|
|
|
|
let sendType = d.selectedHoldingType === Constants.TokenType.ERC721 ? Constants.SendType.ERC721Transfer : Constants.SendType.ERC1155Transfer
|
|
|
|
store.setSendType(sendType)
|
2023-08-31 10:27:15 +00:00
|
|
|
amountToSendInput.input.text = 1
|
2024-02-05 16:44:49 +00:00
|
|
|
store.setSelectedAssetKey(selectedHolding.contractAddress+":"+selectedHolding.tokenId)
|
2023-08-31 10:27:15 +00:00
|
|
|
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()
|
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
bottomPadding: 16
|
2022-07-27 21:10:00 +00:00
|
|
|
padding: 0
|
|
|
|
background: StatusDialogBackground {
|
2024-02-12 16:44:35 +00:00
|
|
|
implicitHeight: 846
|
|
|
|
implicitWidth: 556
|
2022-07-27 21:10:00 +00:00
|
|
|
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) &&
|
2024-03-05 09:27:40 +00:00
|
|
|
(popup.preSelectedHoldingType < Constants.TokenType.Unknown)) {
|
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) {
|
2024-05-28 17:39:41 +00:00
|
|
|
amountToSendInput.input.text = Number(popup.preDefinedAmountToSend).toLocaleString(Qt.locale(), 'f', -128)
|
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()
|
|
|
|
|
2024-06-07 12:27:56 +00:00
|
|
|
header: Item {
|
|
|
|
implicitHeight: accountSelector.implicitHeight
|
|
|
|
implicitWidth: accountSelector.implicitWidth
|
2022-07-27 21:10:00 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: -height - 18
|
2023-06-28 09:16:30 +00:00
|
|
|
|
2024-06-07 12:27:56 +00:00
|
|
|
AccountSelectorHeader {
|
|
|
|
id: accountSelector
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: popup.store.senderAccounts
|
|
|
|
|
|
|
|
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
|
|
|
|
proxyRoles: [
|
|
|
|
FastExpressionRole {
|
|
|
|
name: "colorizedChainPrefixes"
|
|
|
|
function getChainShortNames(chainIds) {
|
|
|
|
const chainShortNames = popup.store.getNetworkShortNames(chainIds)
|
|
|
|
return WalletUtils.colorizedChainPrefix(chainShortNames)
|
|
|
|
}
|
|
|
|
expression: getChainShortNames(model.preferredSharingChainIds)
|
|
|
|
expectedRoles: ["preferredSharingChainIds"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
selectedAddress: !!popup.preSelectedAccount && !!popup.preSelectedAccount.address ? popup.preSelectedAccount.address : ""
|
|
|
|
onCurrentAccountAddressChanged: {
|
|
|
|
store.switchSenderAccountByAddress(currentAccountAddress)
|
|
|
|
if (d.isSelectedHoldingValidAsset) {
|
|
|
|
d.setSelectedHoldingId(d.selectedHolding.symbol, d.selectedHoldingType)
|
|
|
|
}
|
|
|
|
popup.recalculateRoutesAndFees()
|
2023-11-28 19:16:18 +00:00
|
|
|
}
|
2023-09-20 16:07:09 +00:00
|
|
|
}
|
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
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.alignment: Qt.AlignTop
|
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
|
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
color: Theme.palette.baseColor3
|
2023-09-15 08:51:06 +00:00
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
layer.enabled: scrollView.contentY > 0
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
verticalOffset: 0
|
|
|
|
radius: 8
|
|
|
|
samples: 17
|
|
|
|
color: Theme.palette.dropShadow
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
2023-05-10 11:19:25 +00:00
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: assetAndAmountSelector
|
2022-06-27 13:41:47 +00:00
|
|
|
|
2023-05-10 11:19:25 +00:00
|
|
|
anchors.fill: parent
|
2024-02-12 16:44:35 +00:00
|
|
|
anchors.leftMargin: Style.current.xlPadding
|
|
|
|
anchors.rightMargin: Style.current.xlPadding
|
|
|
|
|
|
|
|
z: 1
|
|
|
|
spacing: 16
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 8
|
|
|
|
Layout.preferredHeight: 44
|
2024-05-29 15:42:26 +00:00
|
|
|
|
|
|
|
HeaderTitleText {
|
2024-02-12 16:44:35 +00:00
|
|
|
id: modalHeader
|
2024-05-29 15:42:26 +00:00
|
|
|
Layout.maximumWidth: contentWidth
|
2024-02-12 16:44:35 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
|
|
|
text: d.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
|
|
|
|
}
|
2023-09-18 09:45:37 +00:00
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
HoldingSelector {
|
|
|
|
id: holdingSelector
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
assetsModel: popup.store.processedAssetsModel
|
|
|
|
collectiblesModel: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
|
2024-03-13 17:38:16 +00:00
|
|
|
networksModel: popup.store.flatNetworksModel
|
2024-02-12 16:44:35 +00:00
|
|
|
visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.TokenType.Unknown) ||
|
|
|
|
(!!d.hoveredHolding && d.hoveredHoldingType !== Constants.TokenType.Unknown)
|
|
|
|
onItemSelected: {
|
|
|
|
d.setSelectedHoldingId(holdingId, holdingType)
|
2023-09-18 09:45:37 +00:00
|
|
|
}
|
2024-02-12 16:44:35 +00:00
|
|
|
onSearchTextChanged: popup.store.assetSearchString = searchText
|
2024-01-30 13:15:58 +00:00
|
|
|
formatCurrentCurrencyAmount: function(balance){
|
|
|
|
return popup.store.currencyStore.formatCurrencyAmount(balance, popup.store.currencyStore.currentCurrency)
|
2023-11-28 19:16:18 +00:00
|
|
|
}
|
2024-02-12 16:44:35 +00:00
|
|
|
formatCurrencyAmountFromBigInt: function(balance, symbol, decimals){
|
2024-06-12 20:43:08 +00:00
|
|
|
return popup.store.formatCurrencyAmountFromBigInt(balance, symbol, decimals, {noSymbol: true})
|
2023-11-28 19:16:18 +00:00
|
|
|
}
|
2023-09-18 09:45:37 +00:00
|
|
|
}
|
|
|
|
|
2024-06-10 10:37:39 +00:00
|
|
|
MaxSendButton {
|
2024-02-12 16:44:35 +00:00
|
|
|
Layout.maximumWidth: 300
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
2024-03-05 09:27:40 +00:00
|
|
|
visible: d.isSelectedHoldingValidAsset || d.isHoveredHoldingValidAsset && !d.isCollectiblesTransfer
|
2024-06-10 10:37:39 +00:00
|
|
|
|
|
|
|
value: d.maxInputBalance
|
|
|
|
symbol: d.inputSymbol
|
|
|
|
valid: amountToSendInput.input.valid || !amountToSendInput.input.text
|
|
|
|
formatCurrencyAmount: (amount, symbol) => d.currencyStore.formatCurrencyAmount(amount, symbol, {noSymbol: !amountToSendInput.inputIsFiat})
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (maxSafeValue > 0)
|
|
|
|
amountToSendInput.input.text = maxSafeValueAsString
|
|
|
|
else
|
|
|
|
amountToSendInput.input.input.edit.clear()
|
|
|
|
amountToSendInput.input.forceActiveFocus()
|
2022-07-27 21:10:00 +00:00
|
|
|
}
|
2021-04-22 04:03:46 +00:00
|
|
|
}
|
2024-02-12 16:44:35 +00:00
|
|
|
}
|
|
|
|
RowLayout {
|
2024-03-05 09:27:40 +00:00
|
|
|
visible: d.isSelectedHoldingValidAsset && !d.isCollectiblesTransfer
|
2024-02-12 16:44:35 +00:00
|
|
|
AmountToSend {
|
|
|
|
id: amountToSendInput
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
isBridgeTx: d.isBridgeTx
|
|
|
|
interactive: popup.interactive
|
|
|
|
selectedHolding: d.selectedHolding
|
|
|
|
maxInputBalance: d.maxInputBalance
|
|
|
|
currentCurrency: d.currencyStore.currentCurrency
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2024-03-28 17:47:49 +00:00
|
|
|
// Collectibles do not have decimals
|
|
|
|
multiplierIndex: d.isSelectedHoldingValidAsset && !!holdingSelector.selectedItem && !!holdingSelector.selectedItem.decimals
|
2024-02-12 16:44:35 +00:00
|
|
|
? holdingSelector.selectedItem.decimals
|
|
|
|
: 0
|
2023-09-15 08:51:06 +00:00
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
formatCurrencyAmount: d.currencyStore.formatCurrencyAmount
|
2022-10-17 10:17:25 +00:00
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
|
2024-02-12 16:44:35 +00:00
|
|
|
input.input.tabNavItem: recipientLoader.item
|
|
|
|
Keys.onTabPressed: event.accepted = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Horizontal spacer
|
|
|
|
RowLayout {}
|
|
|
|
|
|
|
|
AmountToReceive {
|
|
|
|
id: amountToReceive
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
Layout.fillWidth:true
|
|
|
|
visible: !!popup.bestRoutes && popup.bestRoutes !== undefined &&
|
|
|
|
popup.bestRoutes.count > 0 && amountToSendInput.inputNumberValid
|
2022-10-17 10:17:25 +00:00
|
|
|
isLoading: popup.isLoading
|
2024-02-12 16:44:35 +00:00
|
|
|
selectedHolding: d.selectedHolding
|
2023-08-31 10:27:15 +00:00
|
|
|
isBridgeTx: d.isBridgeTx
|
2024-02-12 16:44:35 +00:00
|
|
|
cryptoValueToReceive: d.totalAmountToReceive
|
|
|
|
inputIsFiat: amountToSendInput.inputIsFiat
|
|
|
|
minCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals
|
|
|
|
minFiatDecimals: amountToSendInput.minReceiveFiatDecimals
|
|
|
|
currentCurrency: d.currencyStore.currentCurrency
|
|
|
|
formatCurrencyAmount: d.currencyStore.formatCurrencyAmount
|
2022-07-20 11:15:05 +00:00
|
|
|
}
|
2024-02-12 16:44:35 +00:00
|
|
|
}
|
2022-07-20 11:15:05 +00:00
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
// Selected Recipient
|
|
|
|
ColumnLayout {
|
|
|
|
spacing: 8
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: !d.isBridgeTx && !!d.selectedHolding
|
|
|
|
StatusBaseText {
|
|
|
|
id: label
|
|
|
|
elide: Text.ElideRight
|
|
|
|
text: qsTr("To")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
RecipientView {
|
|
|
|
id: recipientLoader
|
|
|
|
Layout.fillWidth: true
|
2022-11-23 17:58:22 +00:00
|
|
|
store: popup.store
|
2024-03-05 09:27:40 +00:00
|
|
|
isCollectiblesTransfer: d.isCollectiblesTransfer
|
2024-02-12 16:44:35 +00:00
|
|
|
isBridgeTx: d.isBridgeTx
|
|
|
|
interactive: popup.interactive
|
|
|
|
selectedAsset: d.selectedHolding
|
|
|
|
onIsLoading: popup.isLoading = true
|
|
|
|
onRecalculateRoutesAndFees: popup.recalculateRoutesAndFees()
|
|
|
|
onAddressTextChanged: store.setSelectedRecipient(addressText)
|
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
|
|
|
}
|
2024-02-12 16:44:35 +00:00
|
|
|
|
|
|
|
TokenListView {
|
|
|
|
id: tokenListRect
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: Style.current.padding
|
|
|
|
Layout.leftMargin: Style.current.xlPadding
|
|
|
|
Layout.rightMargin: Style.current.xlPadding
|
|
|
|
Layout.bottomMargin: Style.current.xlPadding
|
|
|
|
visible: !d.selectedHolding
|
|
|
|
|
|
|
|
assets: popup.store.processedAssetsModel
|
|
|
|
collectibles: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
|
2024-03-13 17:38:16 +00:00
|
|
|
networksModel: popup.store.flatNetworksModel
|
2024-02-12 16:44:35 +00:00
|
|
|
onlyAssets: holdingSelector.onlyAssets
|
2024-03-28 17:47:49 +00:00
|
|
|
onTokenSelected: function (symbolOrTokenKey, holdingType) {
|
|
|
|
d.setSelectedHoldingId(symbolOrTokenKey, holdingType)
|
2024-02-12 16:44:35 +00:00
|
|
|
}
|
|
|
|
onTokenHovered: {
|
|
|
|
if(hovered) {
|
|
|
|
d.setHoveredHoldingId(symbol, holdingType)
|
|
|
|
} else {
|
|
|
|
d.setHoveredHoldingId("", Constants.TokenType.Unknown)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onAssetSearchStringChanged: store.assetSearchString = assetSearchString
|
|
|
|
formatCurrentCurrencyAmount: function(balance){
|
|
|
|
return popup.store.currencyStore.formatCurrencyAmount(balance, popup.store.currencyStore.currentCurrency)
|
|
|
|
}
|
|
|
|
formatCurrencyAmountFromBigInt: function(balance, symbol, decimals) {
|
2024-06-12 20:43:08 +00:00
|
|
|
return popup.store.formatCurrencyAmountFromBigInt(balance, symbol, decimals, {noSymbol: true})
|
2024-02-12 16:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TabAddressSelectorView {
|
|
|
|
id: addressSelector
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: Style.current.padding
|
|
|
|
Layout.leftMargin: Style.current.xlPadding
|
|
|
|
Layout.rightMargin: Style.current.xlPadding
|
|
|
|
visible: !recipientLoader.ready && !d.isBridgeTx && !!d.selectedHolding
|
|
|
|
|
|
|
|
store: popup.store
|
|
|
|
selectedAccount: popup.preSelectedAccount
|
|
|
|
onRecipientSelected: {
|
|
|
|
recipientLoader.selectedRecipientType = type
|
|
|
|
recipientLoader.selectedRecipient = recipient
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusScrollView {
|
|
|
|
id: scrollView
|
|
|
|
|
|
|
|
padding: 0
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.topMargin: Style.current.bigPadding
|
|
|
|
Layout.leftMargin: Style.current.xlPadding
|
|
|
|
Layout.rightMargin: Style.current.xlPadding
|
|
|
|
|
|
|
|
contentWidth: availableWidth
|
|
|
|
|
2024-06-05 12:28:24 +00:00
|
|
|
visible: recipientLoader.ready && !!d.selectedHolding && (amountToSendInput.inputNumberValid || d.isCollectiblesTransfer)
|
2024-02-12 16:44:35 +00:00
|
|
|
|
|
|
|
objectName: "sendModalScroll"
|
|
|
|
|
|
|
|
Behavior on implicitHeight {
|
|
|
|
NumberAnimation { duration: 700; easing.type: Easing.OutExpo; alwaysRunToEnd: true}
|
|
|
|
}
|
|
|
|
|
|
|
|
NetworkSelector {
|
|
|
|
id: networkSelector
|
|
|
|
|
|
|
|
width: scrollView.availableWidth
|
|
|
|
|
|
|
|
store: popup.store
|
|
|
|
interactive: popup.interactive
|
2024-05-06 09:58:12 +00:00
|
|
|
selectedRecipient: recipientLoader.selectedRecipient
|
2024-02-12 16:44:35 +00:00
|
|
|
ensAddressOrEmpty: recipientLoader.resolvedENSAddress
|
|
|
|
amountToSend: amountToSendInput.cryptoValueToSendFloat
|
|
|
|
minSendCryptoDecimals: amountToSendInput.minSendCryptoDecimals
|
|
|
|
minReceiveCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals
|
|
|
|
selectedAsset: d.selectedHolding
|
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
|
|
|
|
errorType: d.errorType
|
|
|
|
isLoading: popup.isLoading
|
|
|
|
isBridgeTx: d.isBridgeTx
|
2024-03-05 09:27:40 +00:00
|
|
|
isCollectiblesTransfer: d.isCollectiblesTransfer
|
2024-02-12 16:44:35 +00:00
|
|
|
bestRoutes: popup.bestRoutes
|
|
|
|
totalFeesInFiat: d.totalFeesInFiat
|
|
|
|
}
|
|
|
|
}
|
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
|
2024-06-05 12:28:24 +00:00
|
|
|
visible: recipientLoader.ready && (amountToSendInput.inputNumberValid || d.isCollectiblesTransfer) && !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)
|
2024-02-05 16:44:49 +00:00
|
|
|
let totalTokenFeesInFiat = 0
|
|
|
|
if (!!d.selectedHolding && !!d.selectedHolding.marketDetails && !!d.selectedHolding.marketDetails.currencyPrice)
|
|
|
|
totalTokenFeesInFiat = gasTimeEstimate.totalTokenFees * d.selectedHolding.marketDetails.currencyPrice.amount
|
|
|
|
d.totalFeesInFiat = d.currencyStore.getFiatValue(gasTimeEstimate.totalFeesInEth, Constants.ethToken) + totalTokenFeesInFiat
|
2024-03-28 17:47:49 +00:00
|
|
|
|
2024-04-15 05:28:29 +00:00
|
|
|
if (d.selectedHolding.type === Constants.TokenType.ERC20 || d.selectedHolding.type === Constants.TokenType.Native) {
|
2024-03-28 17:47:49 +00:00
|
|
|
// If assets
|
|
|
|
d.totalAmountToReceive = popup.store.getWei2Eth(txRoutes.amountToReceive, d.selectedHolding.decimals)
|
|
|
|
} else {
|
|
|
|
// If collectible
|
|
|
|
d.totalAmountToReceive = txRoutes.amountToReceive
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|