2024-07-09 22:10:13 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
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-07-03 20:46:00 +00:00
|
|
|
import AppLayouts.Wallet.adaptors 1.0
|
2024-07-09 22:10:13 +00:00
|
|
|
import AppLayouts.Wallet.controls 1.0
|
|
|
|
import AppLayouts.Wallet.panels 1.0
|
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
2024-06-10 10:37:39 +00:00
|
|
|
|
2024-07-02 11:19:37 +00:00
|
|
|
import shared.popups.send.panels 1.0
|
2023-09-05 15:27:30 +00:00
|
|
|
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
|
|
|
|
2024-07-03 03:55:05 +00:00
|
|
|
property var preSelectedAccount: selectedAccount
|
2024-07-02 11:19:37 +00:00
|
|
|
|
|
|
|
// Recipient properties definition
|
|
|
|
property alias preSelectedRecipient: recipientInputLoader.selectedRecipient
|
|
|
|
property alias preSelectedRecipientType: recipientInputLoader.selectedRecipientType
|
|
|
|
|
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
|
2024-07-09 22:10:13 +00:00
|
|
|
property WalletStores.CollectiblesStore collectiblesStore
|
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property var bestRoutes
|
|
|
|
property bool isLoading: false
|
2024-07-08 20:14:30 +00:00
|
|
|
property int loginType
|
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
|
|
|
|
2024-07-10 09:03:32 +00:00
|
|
|
readonly property var selectedAccount: {
|
|
|
|
selectedSenderAccountEntry.value // Item changed is not triggered when the value is changed
|
|
|
|
return selectedSenderAccountEntry.item ?? ModelUtils.get(store.accounts, 0)
|
|
|
|
}
|
2024-07-03 03:55:05 +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-07-02 11:19:37 +00:00
|
|
|
&& recipientInputLoader.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
|
|
|
|
2024-07-03 20:46:00 +00:00
|
|
|
readonly property WalletAccountsAdaptor accountsAdaptor: WalletAccountsAdaptor {
|
|
|
|
accountsModel: popup.store.accounts
|
|
|
|
flatNetworksModel: popup.store.flatNetworksModel
|
|
|
|
areTestNetworksEnabled: popup.store.areTestNetworksEnabled
|
|
|
|
}
|
|
|
|
|
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 &&
|
2024-07-02 11:19:37 +00:00
|
|
|
!!amountToSendInput.input.text && recipientInputLoader.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-07-02 11:19:37 +00:00
|
|
|
readonly property bool errorMode: popup.isLoading || !recipientInputLoader.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
|
|
|
|
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-07-03 08:51:15 +00:00
|
|
|
LeftJoinModel {
|
|
|
|
id: fromNetworksRouteModel
|
|
|
|
leftModel: popup.store.fromNetworksRouteModel
|
|
|
|
rightModel: popup.store.flatNetworksModel
|
|
|
|
joinRole: "chainId"
|
|
|
|
}
|
|
|
|
LeftJoinModel {
|
|
|
|
id: toNetworksRouteModel
|
|
|
|
leftModel: popup.store.toNetworksRouteModel
|
|
|
|
rightModel: popup.store.flatNetworksModel
|
|
|
|
joinRole: "chainId"
|
|
|
|
}
|
|
|
|
|
2024-07-03 03:55:05 +00:00
|
|
|
ModelEntry {
|
|
|
|
id: selectedSenderAccountEntry
|
|
|
|
key: "address"
|
|
|
|
sourceModel: popup.store.accounts
|
|
|
|
value: popup.store.selectedSenderAccountAddress
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
}
|
2024-07-09 22:10:13 +00:00
|
|
|
if (!!popup.preSelectedHoldingID
|
|
|
|
&& popup.preSelectedHoldingType > Constants.TokenType.Native
|
|
|
|
&& popup.preSelectedHoldingType < Constants.TokenType.Unknown) {
|
|
|
|
|
|
|
|
if (popup.preSelectedHoldingType === Constants.TokenType.ERC20) {
|
|
|
|
const entry = ModelUtils.getByKey(
|
|
|
|
assetsAdaptor.outputAssetsModel, "tokensKey",
|
|
|
|
popup.preSelectedHoldingID)
|
|
|
|
d.selectedHoldingType = Constants.TokenType.ERC20
|
|
|
|
d.selectedHolding = entry
|
|
|
|
|
|
|
|
holdingSelector.setCustom(entry.symbol, entry.iconSource,
|
|
|
|
popup.preSelectedHoldingID)
|
|
|
|
holdingSelector.selectedItem = entry
|
|
|
|
} else {
|
|
|
|
const entry = ModelUtils.getByKey(
|
|
|
|
popup.store.collectiblesModel,
|
|
|
|
"uid", popup.preSelectedHoldingID)
|
|
|
|
|
|
|
|
d.selectedHoldingType = entry.tokenType
|
|
|
|
d.selectedHolding = entry
|
|
|
|
|
|
|
|
const id = entry.communityId ? entry.collectionUid : entry.uid
|
|
|
|
|
|
|
|
holdingSelector.setCustom(entry.name,
|
|
|
|
entry.imageUrl || entry.mediaUrl,
|
|
|
|
id)
|
|
|
|
holdingSelector.selectedItem = entry
|
|
|
|
holdingSelector.currentTab = TokenSelectorPanel.Tabs.Collectibles
|
2023-09-11 10:20:36 +00:00
|
|
|
}
|
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
|
|
|
}
|
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 {
|
2024-07-08 18:07:29 +00:00
|
|
|
sourceModel: popup.store.accounts
|
|
|
|
|
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "canSend"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
]
|
2024-06-07 12:27:56 +00:00
|
|
|
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: {
|
2024-07-03 03:55:05 +00:00
|
|
|
store.setSenderAccount(currentAccountAddress)
|
2024-07-09 22:10:13 +00:00
|
|
|
|
2024-06-07 12:27:56 +00:00
|
|
|
if (d.isSelectedHoldingValidAsset) {
|
2024-07-09 22:10:13 +00:00
|
|
|
d.selectedHolding = ModelUtils.getByKey(
|
|
|
|
holdingSelector.assetsModel, "tokensKey",
|
|
|
|
d.selectedHolding.tokensKey)
|
2024-06-07 12:27:56 +00:00
|
|
|
}
|
2024-07-09 22:10:13 +00:00
|
|
|
|
2024-06-07 12:27:56 +00:00
|
|
|
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 {
|
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-07-09 22:10:13 +00:00
|
|
|
TokenSelectorNew {
|
2024-02-12 16:44:35 +00:00
|
|
|
id: holdingSelector
|
2024-07-09 22:10:13 +00:00
|
|
|
|
|
|
|
property var selectedItem
|
|
|
|
property bool onlyAssets: false
|
|
|
|
|
|
|
|
assetsModel: assetsAdaptor.outputAssetsModel
|
|
|
|
collectiblesModel: collectiblesAdaptorLoader.active
|
|
|
|
? collectiblesAdaptorLoader.item.model : null
|
|
|
|
|
|
|
|
TokenSelectorViewAdaptor {
|
|
|
|
id: assetsAdaptor
|
|
|
|
|
|
|
|
assetsModel: popup.store.walletAssetStore.groupedAccountAssetsModel
|
|
|
|
|
|
|
|
flatNetworksModel: popup.store.flatNetworksModel
|
|
|
|
currentCurrency: popup.store.currencyStore.currentCurrency
|
|
|
|
accountAddress: popup.preSelectedAccount ? popup.preSelectedAccount.address : ""
|
|
|
|
showCommunityAssets: popup.store.tokensStore.showCommunityAssetsInSend
|
2023-09-18 09:45:37 +00:00
|
|
|
}
|
2024-07-09 22:10:13 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: collectiblesAdaptorLoader
|
|
|
|
|
|
|
|
active: !d.isBridgeTx
|
|
|
|
|
|
|
|
sourceComponent: CollectiblesSelectionAdaptor {
|
|
|
|
accountKey: popup.preSelectedAccount ? popup.preSelectedAccount.address : ""
|
|
|
|
collectiblesModel: collectiblesStore
|
|
|
|
? collectiblesStore.jointCollectiblesBySymbolModel
|
|
|
|
: null
|
|
|
|
}
|
2023-11-28 19:16:18 +00:00
|
|
|
}
|
2024-07-09 22:10:13 +00:00
|
|
|
|
|
|
|
onAssetSelected: {
|
|
|
|
const entry = ModelUtils.getByKey(
|
|
|
|
assetsModel, "tokensKey", key)
|
|
|
|
d.selectedHoldingType = Constants.TokenType.ERC20
|
|
|
|
d.selectedHolding = entry
|
|
|
|
selectedItem = entry
|
2023-11-28 19:16:18 +00:00
|
|
|
}
|
2024-07-09 22:10:13 +00:00
|
|
|
|
|
|
|
onCollectibleSelected: {
|
|
|
|
const entry = ModelUtils.getByKey(
|
|
|
|
popup.store.collectiblesModel,
|
|
|
|
"uid", key)
|
|
|
|
d.selectedHoldingType = entry.tokenType
|
|
|
|
d.selectedHolding = entry
|
|
|
|
selectedItem = entry
|
|
|
|
}
|
|
|
|
|
|
|
|
onCollectionSelected: {
|
|
|
|
const entry = ModelUtils.getByKey(
|
|
|
|
popup.store.collectiblesModel,
|
|
|
|
"collectionUid", key)
|
|
|
|
d.selectedHoldingType = entry.tokenType
|
|
|
|
d.selectedHolding = entry
|
|
|
|
selectedItem = entry
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
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-07-02 11:19:37 +00:00
|
|
|
input.input.tabNavItem: recipientInputLoader.item
|
2024-02-12 16:44:35 +00:00
|
|
|
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
|
2024-07-09 22:10:13 +00:00
|
|
|
visible: !d.isBridgeTx
|
2024-02-12 16:44:35 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: label
|
|
|
|
elide: Text.ElideRight
|
|
|
|
text: qsTr("To")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
RecipientView {
|
2024-07-02 11:19:37 +00:00
|
|
|
id: recipientInputLoader
|
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
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
|
|
|
|
2024-07-02 11:19:37 +00:00
|
|
|
RecipientSelectorPanel {
|
|
|
|
id: recipientsPanel
|
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: Style.current.padding
|
|
|
|
Layout.leftMargin: Style.current.xlPadding
|
|
|
|
Layout.rightMargin: Style.current.xlPadding
|
2024-07-08 20:14:30 +00:00
|
|
|
Layout.bottomMargin: Style.current.padding
|
2024-02-12 16:44:35 +00:00
|
|
|
|
2024-07-09 22:10:13 +00:00
|
|
|
visible: !recipientInputLoader.ready && !d.isBridgeTx
|
2024-07-02 11:19:37 +00:00
|
|
|
|
|
|
|
savedAddressesModel: popup.store.savedAddressesModel
|
2024-07-03 20:46:00 +00:00
|
|
|
myAccountsModel: d.accountsAdaptor.model
|
2024-07-02 11:19:37 +00:00
|
|
|
recentRecipientsModel: popup.store.tempActivityController1Model // Use Layer1 controller since this could go on top of other activity lists
|
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
onRecipientSelected: {
|
2024-07-02 11:19:37 +00:00
|
|
|
popup.preSelectedRecipientType = type
|
|
|
|
popup.preSelectedRecipient = recipient
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only request transactions history update if visually needed:
|
|
|
|
onRecentRecipientsTabSelected: popup.store.updateRecentRecipientsActivity(popup.preSelectedAccount)
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: popup
|
|
|
|
function onPreSelectedAccountChanged() {
|
|
|
|
// Only request transactions history update if visually needed:
|
|
|
|
if(recipientsPanel.recentRecipientsTabVisible) {
|
|
|
|
popup.store.updateRecentRecipientsActivity(popup.preSelectedAccount)
|
|
|
|
}
|
|
|
|
}
|
2024-02-12 16:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusScrollView {
|
|
|
|
id: scrollView
|
|
|
|
|
|
|
|
padding: 0
|
2024-07-08 20:14:30 +00:00
|
|
|
bottomPadding: Style.current.padding
|
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.topMargin: Style.current.bigPadding
|
|
|
|
Layout.leftMargin: Style.current.xlPadding
|
|
|
|
Layout.rightMargin: Style.current.xlPadding
|
|
|
|
|
|
|
|
contentWidth: availableWidth
|
|
|
|
|
2024-07-09 22:10:13 +00:00
|
|
|
visible: recipientInputLoader.ready &&
|
|
|
|
(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-07-02 11:19:37 +00:00
|
|
|
selectedRecipient: popup.preSelectedRecipient
|
|
|
|
ensAddressOrEmpty: recipientInputLoader.resolvedENSAddress
|
2024-02-12 16:44:35 +00:00
|
|
|
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
|
2024-07-03 08:51:15 +00:00
|
|
|
fromNetworksList: fromNetworksRouteModel
|
|
|
|
toNetworksList: toNetworksRouteModel
|
2024-02-12 16:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
|
|
|
|
2024-07-08 20:14:30 +00:00
|
|
|
footer: TransactionModalFooter {
|
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")
|
2024-07-08 20:14:30 +00:00
|
|
|
nextButtonIconName: !!popup.selectedAccount && popup.selectedAccount.migratedToKeycard ? Constants.authenticationIconByType[Constants.LoginType.Keycard]
|
|
|
|
: Constants.authenticationIconByType[popup.loginType]
|
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-07-02 11:19:37 +00:00
|
|
|
visible: recipientInputLoader.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
|
2024-06-24 13:52:10 +00:00
|
|
|
d.totalTimeEstimate = WalletUtils.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
|
|
|
|
}
|
2024-07-03 08:51:15 +00:00
|
|
|
networkSelector.suggestedToNetworksList = txRoutes.toNetworksRouteModel
|
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
|
|
|
}
|
|
|
|
}
|