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
|
2024-07-12 09:46:43 +00:00
|
|
|
import StatusQ.Core.Backpressure 0.1
|
2022-03-18 14:47:51 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2024-07-11 17:05:55 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2023-05-10 11:19:25 +00:00
|
|
|
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-17 14:49:42 +00:00
|
|
|
property string preSelectedAccountAddress: store.selectedSenderAccountAddress
|
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-15 09:44:26 +00:00
|
|
|
// In case selected address is incorrect take first account from the list
|
2024-07-17 14:49:42 +00:00
|
|
|
readonly property alias selectedAccount: selectedSenderAccountEntry.item
|
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() {
|
2024-07-17 14:49:42 +00:00
|
|
|
if(!!popup.selectedAccount && !!popup.selectedAccount.address && !!holdingSelector.selectedItem
|
2024-07-17 15:48:56 +00:00
|
|
|
&& recipientInputLoader.ready && (amountToSend.ready || d.isCollectiblesTransfer)) {
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.isLoading = true
|
2024-07-17 15:48:56 +00:00
|
|
|
popup.store.suggestedRoutes(d.isCollectiblesTransfer ? "1" : amountToSend.amount)
|
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-07-17 15:48:56 +00:00
|
|
|
|
|
|
|
readonly property int errorType: {
|
|
|
|
if (amountToSend.balanceExceeded && !isCollectiblesTransfer)
|
|
|
|
return Constants.SendAmountExceedsBalance
|
|
|
|
|
|
|
|
if (popup.bestRoutes && popup.bestRoutes.count === 0
|
|
|
|
&& !amountToSend.empty && recipientInputLoader.ready
|
|
|
|
&& !popup.isLoading)
|
|
|
|
return Constants.NoRoute
|
|
|
|
|
|
|
|
return 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
|
2024-07-17 15:48:56 +00:00
|
|
|
readonly property double maxInputBalance: amountToSend.fiatMode ? maxFiatBalance : maxCryptoBalance
|
|
|
|
|
|
|
|
readonly property string tokenSymbol: !!d.selectedHolding && !!d.selectedHolding.symbol ? d.selectedHolding.symbol: ""
|
|
|
|
readonly property string inputSymbol: amountToSend.fiatMode ? currencyStore.currentCurrency : tokenSymbol
|
|
|
|
readonly property bool errorMode: {
|
|
|
|
if (popup.isLoading || !recipientInputLoader.ready)
|
|
|
|
return false
|
|
|
|
|
|
|
|
return errorType !== Constants.NoError
|
|
|
|
|| networkSelector.errorMode
|
|
|
|
|| !(amountToSend.ready || 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
|
|
|
|
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)
|
2024-07-17 15:48:56 +00:00
|
|
|
amountToSend.setValue("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: {
|
2024-07-17 15:48:56 +00:00
|
|
|
amountToSend.forceActiveFocus()
|
2021-06-29 13:25:05 +00:00
|
|
|
|
2024-07-16 14:36:44 +00:00
|
|
|
// IMPORTANT: This step must be the first one since it's storing the send type
|
|
|
|
// into the backend at this stage so that, before this assignement, some properties
|
|
|
|
// should not have the correct value, like `d.isBridgeTx`
|
2023-09-20 16:07:09 +00:00
|
|
|
if(popup.preSelectedSendType !== Constants.SendType.Unknown) {
|
|
|
|
store.setSendType(popup.preSelectedSendType)
|
|
|
|
}
|
2024-07-16 14:36:44 +00:00
|
|
|
|
|
|
|
// To be removed once bridge is splitted to a different component:
|
|
|
|
if(d.isBridgeTx && !!popup.preSelectedAccount) {
|
|
|
|
// Default preselected type is `Helpers.RecipientAddressObjectType.Address` coinciding with bridge usecase
|
|
|
|
popup.preSelectedRecipient = popup.preSelectedAccount.address
|
|
|
|
}
|
|
|
|
|
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) {
|
2024-07-11 17:05:55 +00:00
|
|
|
const entry = SQUtils.ModelUtils.getByKey(
|
2024-07-09 22:10:13 +00:00
|
|
|
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 {
|
2024-07-11 17:05:55 +00:00
|
|
|
const entry = SQUtils.ModelUtils.getByKey(
|
2024-07-17 14:49:42 +00:00
|
|
|
popup.collectiblesStore.allCollectiblesModel,
|
|
|
|
"symbol", popup.preSelectedHoldingID)
|
2024-07-09 22:10:13 +00:00
|
|
|
|
|
|
|
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-10-17 10:17:25 +00:00
|
|
|
if(!!popup.preDefinedAmountToSend) {
|
2024-07-17 15:48:56 +00:00
|
|
|
// TODO: At this stage the number should not be localized. However
|
|
|
|
// in many places when initializing popup the number is provided
|
|
|
|
// in localized version. It should be refactored to provide raw
|
|
|
|
// number consistently. Only the displaying component should apply
|
|
|
|
// final localized formatting.
|
|
|
|
const delocalized = popup.preDefinedAmountToSend.replace(",", ".")
|
|
|
|
|
|
|
|
amountToSend.setValue(delocalized)
|
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"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2024-07-17 14:49:42 +00:00
|
|
|
selectedAddress: popup.preSelectedAccountAddress
|
2024-06-07 12:27:56 +00:00
|
|
|
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-11 17:05:55 +00:00
|
|
|
d.selectedHolding = SQUtils.ModelUtils.getByKey(
|
2024-07-09 22:10:13 +00:00
|
|
|
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
|
2024-07-17 14:49:42 +00:00
|
|
|
accountAddress: popup.selectedAccount.address
|
2024-07-09 22:10:13 +00:00
|
|
|
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 {
|
2024-07-17 14:49:42 +00:00
|
|
|
accountKey: popup.selectedAccount.address
|
2024-07-12 12:07:20 +00:00
|
|
|
|
|
|
|
collectiblesModel: SortFilterProxyModel {
|
|
|
|
sourceModel: collectiblesStore ? collectiblesStore.jointCollectiblesBySymbolModel : null
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "soulbound"
|
|
|
|
value: false
|
|
|
|
}
|
|
|
|
}
|
2024-07-09 22:10:13 +00:00
|
|
|
}
|
2023-11-28 19:16:18 +00:00
|
|
|
}
|
2024-07-09 22:10:13 +00:00
|
|
|
|
|
|
|
onAssetSelected: {
|
2024-07-11 17:05:55 +00:00
|
|
|
const entry = SQUtils.ModelUtils.getByKey(
|
2024-07-09 22:10:13 +00:00
|
|
|
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: {
|
2024-07-11 17:05:55 +00:00
|
|
|
const entry = SQUtils.ModelUtils.getByKey(
|
2024-07-09 22:10:13 +00:00
|
|
|
popup.store.collectiblesModel,
|
|
|
|
"uid", key)
|
|
|
|
d.selectedHoldingType = entry.tokenType
|
|
|
|
d.selectedHolding = entry
|
|
|
|
selectedItem = entry
|
|
|
|
}
|
|
|
|
|
|
|
|
onCollectionSelected: {
|
2024-07-11 17:05:55 +00:00
|
|
|
const entry = SQUtils.ModelUtils.getByKey(
|
2024-07-09 22:10:13 +00:00
|
|
|
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-07-17 15:48:56 +00:00
|
|
|
id: maxButton
|
|
|
|
|
|
|
|
readonly property double maxSafeValue: WalletUtils.calculateMaxSafeSendAmount(
|
|
|
|
d.maxInputBalance, d.inputSymbol)
|
|
|
|
|
|
|
|
readonly property double maxSafeCryptoValue: WalletUtils.calculateMaxSafeSendAmount(
|
|
|
|
d.maxCryptoBalance, d.tokenSymbol)
|
|
|
|
|
|
|
|
formattedValue: d.currencyStore.formatCurrencyAmount(
|
|
|
|
maxSafeValue, d.inputSymbol,
|
|
|
|
{ noSymbol: !amountToSend.fiatMode })
|
|
|
|
|
|
|
|
markAsInvalid: amountToSend.markAsInvalid
|
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
Layout.maximumWidth: 300
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
2024-06-10 10:37:39 +00:00
|
|
|
|
2024-07-17 15:48:56 +00:00
|
|
|
visible: d.isSelectedHoldingValidAsset && !d.isCollectiblesTransfer
|
2024-06-10 10:37:39 +00:00
|
|
|
|
|
|
|
onClicked: {
|
2024-07-17 15:48:56 +00:00
|
|
|
if (maxSafeValue > 0) {
|
|
|
|
amountToSend.setValue(SQUtils.AmountsArithmetic.fromNumber(maxSafeValue).toString())
|
|
|
|
}else {
|
|
|
|
amountToSend.clear()
|
|
|
|
}
|
|
|
|
|
|
|
|
amountToSend.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
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2024-07-17 15:48:56 +00:00
|
|
|
AmountToSendNew {
|
|
|
|
id: amountToSend
|
|
|
|
|
|
|
|
caption: d.isBridgeTx ? qsTr("Amount to bridge")
|
|
|
|
: qsTr("Amount to send")
|
2024-02-12 16:44:35 +00:00
|
|
|
interactive: popup.interactive
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2024-07-17 15:48:56 +00:00
|
|
|
readonly property bool balanceExceeded:
|
|
|
|
SQUtils.AmountsArithmetic.cmp(
|
|
|
|
SQUtils.AmountsArithmetic.fromNumber(maxButton.maxSafeCryptoValue, multiplierIndex),
|
|
|
|
SQUtils.AmountsArithmetic.fromString(amount)) === -1
|
2023-09-15 08:51:06 +00:00
|
|
|
|
2024-07-17 15:48:56 +00:00
|
|
|
readonly property bool ready: valid && !empty && !balanceExceeded
|
|
|
|
&& amount !== "0"
|
|
|
|
|
|
|
|
readonly property string selectedSymbol:
|
|
|
|
!!d.selectedHolding && !!d.selectedHolding.symbol
|
|
|
|
? d.selectedHolding.symbol : ""
|
|
|
|
|
|
|
|
// For backward compatibility. To be removed when
|
|
|
|
// dependent components (NetworkSelector, AmountToReceive)
|
|
|
|
// are refactored.
|
|
|
|
readonly property double asNumber: {
|
|
|
|
if (!valid)
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return parseFloat(text.replace(",", "."))
|
|
|
|
}
|
|
|
|
readonly property int minSendCryptoDecimals:
|
|
|
|
!fiatMode ? LocaleUtils.fractionalPartLength(asNumber) : 0
|
|
|
|
readonly property int minReceiveCryptoDecimals:
|
|
|
|
!fiatMode ? minSendCryptoDecimals + 1 : 0
|
|
|
|
readonly property int minSendFiatDecimals:
|
|
|
|
fiatMode ? LocaleUtils.fractionalPartLength(asNumber) : 0
|
|
|
|
readonly property int minReceiveFiatDecimals:
|
|
|
|
fiatMode ? minSendFiatDecimals + 1 : 0
|
|
|
|
// End of to-be-removed part
|
|
|
|
|
|
|
|
decimalPoint: LocaleUtils.userInputLocale.decimalPoint
|
|
|
|
markAsInvalid: balanceExceeded
|
|
|
|
|
|
|
|
// Collectibles do not have decimals
|
|
|
|
multiplierIndex:
|
|
|
|
d.isSelectedHoldingValidAsset
|
|
|
|
&& !!holdingSelector.selectedItem
|
|
|
|
&& !!holdingSelector.selectedItem.decimals
|
|
|
|
? holdingSelector.selectedItem.decimals : 0
|
|
|
|
|
|
|
|
price: d.isSelectedHoldingValidAsset
|
|
|
|
? (d.selectedHolding ?
|
|
|
|
d.selectedHolding.marketDetails.currencyPrice.amount : 1)
|
|
|
|
: 1
|
|
|
|
|
|
|
|
formatFiat: amount => d.currencyStore.formatCurrencyAmount(
|
|
|
|
amount, d.currencyStore.currentCurrency)
|
|
|
|
formatBalance: amount => d.currencyStore.formatCurrencyAmount(
|
|
|
|
amount, selectedSymbol)
|
|
|
|
|
|
|
|
onAmountChanged: popup.recalculateRoutesAndFees()
|
2024-02-12 16:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Horizontal spacer
|
|
|
|
RowLayout {}
|
|
|
|
|
|
|
|
AmountToReceive {
|
|
|
|
id: amountToReceive
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
Layout.fillWidth:true
|
|
|
|
visible: !!popup.bestRoutes && popup.bestRoutes !== undefined &&
|
2024-07-17 15:48:56 +00:00
|
|
|
popup.bestRoutes.count > 0 && amountToSend.ready
|
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
|
2024-07-17 15:48:56 +00:00
|
|
|
inputIsFiat: amountToSend.fiatMode
|
|
|
|
minCryptoDecimals: amountToSend.minReceiveCryptoDecimals
|
|
|
|
minFiatDecimals: amountToSend.minReceiveFiatDecimals
|
2024-02-12 16:44:35 +00:00
|
|
|
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:
|
2024-07-17 14:49:42 +00:00
|
|
|
onRecentRecipientsTabSelected: popup.store.updateRecentRecipientsActivity(popup.selectedAccount.address)
|
2024-07-02 11:19:37 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: popup
|
2024-07-17 14:49:42 +00:00
|
|
|
function onSelectedAccountChanged() {
|
2024-07-02 11:19:37 +00:00
|
|
|
// Only request transactions history update if visually needed:
|
|
|
|
if(recipientsPanel.recentRecipientsTabVisible) {
|
2024-07-17 14:49:42 +00:00
|
|
|
popup.store.updateRecentRecipientsActivity(popup.selectedAccount.address)
|
2024-07-02 11:19:37 +00:00
|
|
|
}
|
|
|
|
}
|
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 &&
|
2024-07-17 15:48:56 +00:00
|
|
|
(amountToSend.ready || 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-07-17 15:48:56 +00:00
|
|
|
amountToSend: amountToSend.cryptoValueToSendFloat
|
|
|
|
minSendCryptoDecimals: amountToSend.minSendCryptoDecimals
|
|
|
|
minReceiveCryptoDecimals: amountToSend.minReceiveCryptoDecimals
|
2024-02-12 16:44:35 +00:00
|
|
|
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-17 15:48:56 +00:00
|
|
|
visible: recipientInputLoader.ready && (amountToSend.ready || 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
|
|
|
}
|
|
|
|
}
|