2024-07-09 22:10:13 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2024-10-15 19:26:12 +00:00
|
|
|
import QtGraphicalEffects 1.15
|
|
|
|
|
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
|
2024-05-22 08:13:39 +00:00
|
|
|
import shared.stores 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
|
2024-07-31 11:58:05 +00:00
|
|
|
property int preSelectedChainId: 0
|
2024-07-25 13:30:51 +00:00
|
|
|
property string stickersPackId
|
|
|
|
|
2024-08-14 12:49:17 +00:00
|
|
|
// needed for registering ENS
|
|
|
|
property string publicKey
|
|
|
|
property string ensName
|
|
|
|
|
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
|
2024-08-10 12:39:56 +00:00
|
|
|
property bool showCustomRoutingMode
|
2023-08-31 10:27:15 +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-29 06:11:32 +00:00
|
|
|
d.routerError = ""
|
|
|
|
d.routerErrorDetails = ""
|
2024-09-13 11:39:12 +00:00
|
|
|
popup.store.suggestedRoutes(d.uuid, d.isCollectiblesTransfer ? "1" : amountToSend.amount, "0", d.extraParamsJson)
|
2022-02-01 21:03:47 +00:00
|
|
|
}
|
2022-05-19 08:53:57 +00:00
|
|
|
})
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2024-09-09 11:29:40 +00:00
|
|
|
property var generateUuid: () => { return Utils.uuid() }
|
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
2023-11-09 08:21:25 +00:00
|
|
|
|
2024-07-25 13:30:51 +00:00
|
|
|
property string extraParamsJson: ""
|
|
|
|
|
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
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
readonly property CurrenciesStore 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-07-19 11:20:26 +00:00
|
|
|
readonly property double maxFiatBalance: isSelectedHoldingValidAsset ? selectedHolding.currencyBalance : 0
|
2024-01-30 13:15:58 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2024-07-29 06:11:32 +00:00
|
|
|
// This way of displaying errors is just first aid, we have to build better way of handilg errors on the UI side
|
|
|
|
// and remove `d.errorType`
|
|
|
|
property string routerError: ""
|
|
|
|
property string routerErrorDetails: ""
|
|
|
|
|
2024-09-09 11:29:40 +00:00
|
|
|
property string sendError: ""
|
|
|
|
|
|
|
|
readonly property string uuid: popup.generateUuid()
|
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
|
2024-08-02 08:37:02 +00:00
|
|
|
property int selectedHoldingType: Constants.TokenType.Unknown
|
2023-11-07 22:45:47 +00:00
|
|
|
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: {
|
2024-09-09 11:29:40 +00:00
|
|
|
d.sendError = ""
|
2024-07-31 11:58:05 +00:00
|
|
|
if (!selectedHolding) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
}
|
2024-09-30 08:34:28 +00:00
|
|
|
|
|
|
|
function addMetricsEvent(subEventName) {
|
|
|
|
Global.addCentralizedMetricIfEnabled(d.isBridgeTx ? "bridge" : "send", {subEvent: subEventName})
|
|
|
|
}
|
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:
|
2024-07-19 11:20:26 +00:00
|
|
|
if(d.isBridgeTx && !!popup.preSelectedAccountAddress) {
|
2024-07-16 14:36:44 +00:00
|
|
|
// Default preselected type is `Helpers.RecipientAddressObjectType.Address` coinciding with bridge usecase
|
2024-07-19 11:20:26 +00:00
|
|
|
popup.preSelectedRecipient = popup.preSelectedAccountAddress
|
2024-07-16 14:36:44 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2024-09-23 08:15:01 +00:00
|
|
|
holdingSelector.setSelection(entry.symbol, entry.iconSource,
|
|
|
|
popup.preSelectedHoldingID)
|
2024-07-09 22:10:13 +00:00
|
|
|
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
|
|
|
|
|
2024-09-23 08:15:01 +00:00
|
|
|
holdingSelector.setSelection(entry.name,
|
|
|
|
entry.imageUrl || entry.mediaUrl,
|
|
|
|
id)
|
2024-07-09 22:10:13 +00:00
|
|
|
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.
|
2024-07-31 10:04:51 +00:00
|
|
|
const delocalized = popup.preDefinedAmountToSend.replace(LocaleUtils.userInputLocale.decimalPoint, ".")
|
2024-07-17 15:48:56 +00:00
|
|
|
|
|
|
|
amountToSend.setValue(delocalized)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2024-07-31 11:58:05 +00:00
|
|
|
|
|
|
|
if (!!popup.preSelectedChainId) {
|
|
|
|
popup.preDefinedAmountToSend = popup.preDefinedAmountToSend.replace(Qt.locale().decimalPoint, '.')
|
|
|
|
store.updateRoutePreferredChains(popup.preSelectedChainId)
|
|
|
|
}
|
2024-07-25 13:30:51 +00:00
|
|
|
|
|
|
|
if (!!popup.stickersPackId) {
|
|
|
|
d.extraParamsJson = "{\"%1\":\"%2\"}".arg(Constants.suggestedRoutesExtraParamsProperties.packId).arg(popup.stickersPackId)
|
|
|
|
}
|
2024-08-14 12:49:17 +00:00
|
|
|
|
|
|
|
if (!!popup.ensName && !!popup.publicKey) {
|
|
|
|
d.extraParamsJson = "{\"%1\":\"%2\",\"%3\":\"%4\"}"
|
|
|
|
.arg(Constants.suggestedRoutesExtraParamsProperties.username)
|
|
|
|
.arg(popup.ensName)
|
|
|
|
.arg(Constants.suggestedRoutesExtraParamsProperties.publicKey)
|
|
|
|
.arg(popup.publicKey)
|
|
|
|
}
|
2024-09-30 08:34:28 +00:00
|
|
|
|
|
|
|
d.addMetricsEvent("popup opened")
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|
|
|
|
|
2024-08-30 09:16:40 +00:00
|
|
|
onClosed: {
|
|
|
|
popup.store.stopUpdatesForSuggestedRoute()
|
|
|
|
popup.store.resetStoredProperties()
|
2024-09-30 08:34:28 +00:00
|
|
|
d.addMetricsEvent("popup closed")
|
2024-08-30 09:16:40 +00:00
|
|
|
}
|
2023-08-31 10:27:15 +00:00
|
|
|
|
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 }
|
|
|
|
}
|
2024-07-17 14:49:42 +00:00
|
|
|
selectedAddress: popup.preSelectedAccountAddress
|
2024-06-07 12:27:56 +00:00
|
|
|
onCurrentAccountAddressChanged: {
|
2024-09-09 11:29:40 +00:00
|
|
|
d.sendError = ""
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
+ Theme.halfPadding
|
2023-05-10 11:19:25 +00:00
|
|
|
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-10-15 19:26:12 +00:00
|
|
|
anchors.leftMargin: Theme.xlPadding
|
|
|
|
anchors.rightMargin: Theme.xlPadding
|
2024-02-12 16:44:35 +00:00
|
|
|
|
|
|
|
z: 1
|
|
|
|
spacing: 16
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 8
|
|
|
|
Layout.preferredHeight: 44
|
2024-07-31 04:53:43 +00:00
|
|
|
Layout.maximumWidth: parent.width
|
2024-05-29 15:42:26 +00:00
|
|
|
|
|
|
|
HeaderTitleText {
|
2024-02-12 16:44:35 +00:00
|
|
|
id: modalHeader
|
2024-07-30 08:15:14 +00:00
|
|
|
objectName: "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-09-18 11:24:56 +00:00
|
|
|
TokenSelector {
|
2024-02-12 16:44:35 +00:00
|
|
|
id: holdingSelector
|
2024-07-30 08:15:14 +00:00
|
|
|
objectName: "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
|
2024-08-30 12:24:16 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.maximumWidth: implicitWidth
|
2024-07-09 22:10:13 +00:00
|
|
|
|
|
|
|
TokenSelectorViewAdaptor {
|
|
|
|
id: assetsAdaptor
|
|
|
|
|
2024-07-30 22:26:30 +00:00
|
|
|
assetsModel: d.isBridgeTx ?
|
|
|
|
popup.store.walletAssetStore.bridgeableGroupedAccountAssetsModel :
|
|
|
|
popup.store.walletAssetStore.groupedAccountAssetsModel
|
2024-07-09 22:10:13 +00:00
|
|
|
|
|
|
|
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-09-16 11:21:25 +00:00
|
|
|
popup.collectiblesStore.allCollectiblesModel,
|
|
|
|
"symbol", key)
|
2024-07-09 22:10:13 +00:00
|
|
|
d.selectedHoldingType = entry.tokenType
|
|
|
|
d.selectedHolding = entry
|
|
|
|
selectedItem = entry
|
|
|
|
}
|
|
|
|
|
|
|
|
onCollectionSelected: {
|
2024-07-11 17:05:55 +00:00
|
|
|
const entry = SQUtils.ModelUtils.getByKey(
|
2024-09-16 11:21:25 +00:00
|
|
|
popup.collectiblesStore.allCollectiblesModel,
|
2024-07-09 22:10:13 +00:00
|
|
|
"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-07-24 23:20:27 +00:00
|
|
|
// FIXME: This should be enabled after #15709 is resolved
|
|
|
|
enabled: false
|
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-08-14 21:56:48 +00:00
|
|
|
AmountToSend {
|
2024-07-17 15:48:56 +00:00
|
|
|
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:
|
2024-08-14 13:04:28 +00:00
|
|
|
SQUtils.AmountsArithmetic.fromNumber(maxButton.maxSafeCryptoValue, multiplierIndex).cmp(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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-07-31 10:04:51 +00:00
|
|
|
return parseFloat(text.replace(LocaleUtils.userInputLocale.decimalPoint, "."))
|
2024-07-17 15:48:56 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
2024-09-24 07:51:42 +00:00
|
|
|
onValidChanged: {
|
|
|
|
d.sendError = ""
|
|
|
|
popup.recalculateRoutesAndFees()
|
|
|
|
}
|
|
|
|
|
2024-09-09 11:29:40 +00:00
|
|
|
onAmountChanged: {
|
|
|
|
d.sendError = ""
|
|
|
|
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
|
2024-09-09 11:29:40 +00:00
|
|
|
onRecalculateRoutesAndFees: {
|
|
|
|
d.sendError = ""
|
|
|
|
popup.recalculateRoutesAndFees()
|
|
|
|
}
|
2024-02-12 16:44:35 +00:00
|
|
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.topMargin: Theme.padding
|
|
|
|
Layout.leftMargin: Theme.xlPadding
|
|
|
|
Layout.rightMargin: Theme.xlPadding
|
|
|
|
Layout.bottomMargin: Theme.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-10-04 15:23:26 +00:00
|
|
|
myAccountsModel: popup.store.accounts
|
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-10-15 19:26:12 +00:00
|
|
|
bottomPadding: Theme.padding
|
2024-07-08 20:14:30 +00:00
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.topMargin: Theme.bigPadding
|
|
|
|
Layout.leftMargin: Theme.xlPadding
|
|
|
|
Layout.rightMargin: Theme.xlPadding
|
2024-02-12 16:44:35 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2024-09-09 11:29:40 +00:00
|
|
|
onVisibleChanged: {
|
|
|
|
if (!visible)
|
|
|
|
d.sendError = ""
|
|
|
|
}
|
|
|
|
|
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
|
2024-09-18 08:04:59 +00:00
|
|
|
ensAddressOrEmpty: recipientInputLoader.ready ? recipientInputLoader.resolvedENSAddress : ""
|
2024-07-23 07:39:32 +00:00
|
|
|
amountToSend: amountToSend.asNumber
|
2024-07-17 15:48:56 +00:00
|
|
|
minSendCryptoDecimals: amountToSend.minSendCryptoDecimals
|
|
|
|
minReceiveCryptoDecimals: amountToSend.minReceiveCryptoDecimals
|
2024-02-12 16:44:35 +00:00
|
|
|
selectedAsset: d.selectedHolding
|
2024-09-09 11:29:40 +00:00
|
|
|
onReCalculateSuggestedRoute: {
|
|
|
|
d.sendError = ""
|
|
|
|
popup.recalculateRoutesAndFees()
|
|
|
|
}
|
2024-02-12 16:44:35 +00:00
|
|
|
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-08-10 12:39:56 +00:00
|
|
|
showCustomRoutingMode: popup.showCustomRoutingMode
|
2024-07-29 06:11:32 +00:00
|
|
|
|
|
|
|
routerError: d.routerError
|
|
|
|
routerErrorDetails: d.routerErrorDetails
|
2024-02-12 16:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
2024-09-09 11:29:40 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.topMargin: Theme.bigPadding
|
|
|
|
Layout.leftMargin: Theme.xlPadding
|
|
|
|
Layout.rightMargin: Theme.xlPadding
|
|
|
|
Layout.bottomMargin: Theme.xlPadding
|
|
|
|
implicitHeight: sendErrorColumn.height + Theme.padding
|
2024-09-09 11:29:40 +00:00
|
|
|
color: Theme.palette.dangerColor3
|
|
|
|
radius: 8
|
|
|
|
border.width: 1
|
|
|
|
border.color: Theme.palette.dangerColor2
|
|
|
|
|
|
|
|
visible: !!d.sendError
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: sendErrorColumn
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.leftMargin: Theme.padding
|
|
|
|
anchors.rightMargin: Theme.padding
|
|
|
|
spacing: Theme.padding
|
2024-09-09 11:29:40 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.topMargin: Theme.padding
|
|
|
|
font.pixelSize: Theme.secondaryTextFontSize
|
2024-09-09 11:29:40 +00:00
|
|
|
font.bold: true
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
text: qsTr("Error sending the transaction")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize
|
2024-09-09 11:29:40 +00:00
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
text: d.sendError
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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-27 16:21:14 +00:00
|
|
|
visible: recipientInputLoader.ready && (amountToSend.ready || d.isCollectiblesTransfer) && !d.errorMode && !d.routerError
|
2024-07-17 15:48:56 +00:00
|
|
|
|
2024-09-09 11:29:40 +00:00
|
|
|
onNextButtonClicked: {
|
|
|
|
d.sendError = ""
|
|
|
|
popup.sendTransaction()
|
2024-09-30 08:34:28 +00:00
|
|
|
d.addMetricsEvent("next button clicked")
|
2024-09-09 11:29:40 +00:00
|
|
|
}
|
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
|
2024-07-19 03:36:36 +00:00
|
|
|
function onSuggestedRoutesReady(txRoutes, errCode, errDescription) {
|
2023-08-15 18:21:51 +00:00
|
|
|
popup.bestRoutes = txRoutes.suggestedRoutes
|
2024-07-29 06:11:32 +00:00
|
|
|
|
2024-07-31 12:33:56 +00:00
|
|
|
d.routerError = WalletUtils.getRouterErrorBasedOnCode(errCode)
|
|
|
|
d.routerErrorDetails = "%1 - %2".arg(errCode).arg(WalletUtils.getRouterErrorDetailsOnCode(errCode, errDescription))
|
2024-07-29 06:11:32 +00:00
|
|
|
|
2023-08-15 18:21:51 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-09-13 11:39:12 +00:00
|
|
|
function onTransactionSent(uuid: string, chainId: int, approvalTx: bool, txHash: 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
|
|
|
}
|
2024-09-09 11:29:40 +00:00
|
|
|
d.sendError = error
|
2024-09-30 08:34:28 +00:00
|
|
|
d.addMetricsEvent("tx send error")
|
2024-09-09 11:29:40 +00:00
|
|
|
return
|
2022-02-24 19:24:58 +00:00
|
|
|
}
|
2024-09-30 08:34:28 +00:00
|
|
|
d.addMetricsEvent("tx send successful")
|
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
|
|
|
}
|
|
|
|
}
|