2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2020-08-13 08:24:51 +00:00
|
|
|
import QtQuick.Layouts 1.13
|
2020-08-20 04:45:29 +00:00
|
|
|
import QtQuick.Dialogs 1.3
|
2022-03-18 14:47:51 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-12-08 21:20:43 +00:00
|
|
|
import shared.stores 1.0
|
2022-07-21 08:40:49 +00:00
|
|
|
import shared.panels 1.0
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2022-07-27 21:10:00 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2022-03-18 14:47:51 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-07-27 21:10:00 +00:00
|
|
|
import StatusQ.Controls.Validators 0.1
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2021-10-14 09:20:18 +00:00
|
|
|
import "../panels"
|
2021-10-14 10:12:22 +00:00
|
|
|
import "../controls"
|
2021-10-14 13:45:08 +00:00
|
|
|
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
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
property bool isBridgeTx: false
|
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property string preSelectedRecipient
|
|
|
|
property string preDefinedAmountToSend
|
|
|
|
property var preSelectedAsset
|
|
|
|
property bool interactive: true
|
2020-06-26 16:08:51 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property alias modalHeader: modalHeader.text
|
|
|
|
|
|
|
|
property var store: TransactionStore{}
|
|
|
|
property var contactsStore: store.contactStore
|
2023-01-08 22:23:51 +00:00
|
|
|
property var currencyStore: store.currencyStore
|
2022-06-27 13:41:47 +00:00
|
|
|
property var selectedAccount: store.currentAccount
|
2022-10-17 10:17:25 +00:00
|
|
|
property var bestRoutes
|
|
|
|
property string addressText
|
|
|
|
property bool isLoading: false
|
2022-11-23 17:58:22 +00:00
|
|
|
property int sendType: isBridgeTx ? Constants.SendType.Bridge : Constants.SendType.Transfer
|
2020-08-20 04:45:29 +00:00
|
|
|
property MessageDialog sendingError: MessageDialog {
|
|
|
|
id: sendingError
|
2022-04-04 11:26:30 +00:00
|
|
|
title: qsTr("Error sending the transaction")
|
2020-08-20 04:45:29 +00:00
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
2020-08-20 04:45:29 +00:00
|
|
|
|
2022-10-20 12:58:56 +00:00
|
|
|
Connections {
|
|
|
|
target: store.currentAccount.assets
|
|
|
|
onModelReset: {
|
|
|
|
popup.selectedAccount = null
|
|
|
|
popup.selectedAccount = store.currentAccount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property var sendTransaction: function() {
|
2022-08-25 19:20:21 +00:00
|
|
|
let recipientAddress = Utils.isValidAddress(popup.addressText) ? popup.addressText : d.resolvedENSAddress
|
2022-10-17 10:17:25 +00:00
|
|
|
d.isPendingTx = true
|
2022-09-28 08:43:37 +00:00
|
|
|
popup.store.authenticateAndTransfer(
|
2022-08-29 16:28:54 +00:00
|
|
|
popup.selectedAccount.address,
|
|
|
|
recipientAddress,
|
|
|
|
assetSelector.selectedAsset.symbol,
|
2023-01-08 22:23:51 +00:00
|
|
|
amountToSendInput.cryptoValueToSend.amount,
|
2022-08-29 16:28:54 +00:00
|
|
|
d.uuid,
|
2022-10-17 10:17:25 +00:00
|
|
|
JSON.stringify(popup.bestRoutes)
|
2022-08-29 16:28:54 +00:00
|
|
|
)
|
2022-05-19 08:53:57 +00:00
|
|
|
}
|
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
|
2022-12-19 13:02:56 +00:00
|
|
|
if(!!popup.selectedAccount && !!assetSelector.selectedAsset && d.recipientReady && amountToSendInput.input.valid) {
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.isLoading = true
|
2023-01-08 22:23:51 +00:00
|
|
|
let amount = Math.round(amountToSendInput.cryptoValueToSend.amount * Math.pow(10, assetSelector.selectedAsset.decimals))
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.store.suggestedRoutes(popup.selectedAccount.address, amount.toString(16), assetSelector.selectedAsset.symbol,
|
|
|
|
store.disabledChainIdsFromList, store.disabledChainIdsToList,
|
2022-11-25 09:13:02 +00:00
|
|
|
store.preferredChainIds, popup.sendType, store.lockedInAmounts)
|
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
|
2022-12-19 13:02:56 +00:00
|
|
|
readonly property int errorType: !amountToSendInput.input.valid ? Constants.SendAmountExceedsBalance :
|
|
|
|
(networkSelector.bestRoutes && networkSelector.bestRoutes.length <= 0 && !!amountToSendInput.input.text && recipientReady && !popup.isLoading) ?
|
|
|
|
Constants.NoRoute : Constants.NoError
|
2023-01-08 22:23:51 +00:00
|
|
|
readonly property var maxFiatBalance: !!assetSelector.selectedAsset ? (amountToSendInput.inputIsFiat ?
|
2022-12-14 21:06:14 +00:00
|
|
|
assetSelector.selectedAsset.totalCurrencyBalance :
|
2022-12-29 16:44:51 +00:00
|
|
|
assetSelector.selectedAsset.totalBalance): undefined
|
2022-12-19 13:02:56 +00:00
|
|
|
readonly property bool errorMode: popup.isLoading || !recipientReady ? false : errorType !== Constants.NoError || networkSelector.errorMode || isNaN(amountToSendInput.input.text)
|
2022-08-25 19:20:21 +00:00
|
|
|
readonly property bool recipientReady: (isAddressValid || isENSValid) && !recipientSelector.isPending
|
2022-11-25 09:13:02 +00:00
|
|
|
property bool isAddressValid: Utils.isValidAddress(popup.addressText)
|
2022-08-25 19:20:21 +00:00
|
|
|
property bool isENSValid: false
|
|
|
|
readonly property var resolveENS: Backpressure.debounce(popup, 500, function (ensName) {
|
|
|
|
store.resolveENS(ensName)
|
|
|
|
})
|
|
|
|
property string resolvedENSAddress
|
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-01-08 22:23:51 +00:00
|
|
|
property var totalFeesInEth
|
|
|
|
property var totalFeesInFiat
|
|
|
|
property var totalAmountToReceive
|
2022-10-17 10:17:25 +00:00
|
|
|
|
|
|
|
property Timer waitTimer: Timer {
|
2022-11-25 09:13:02 +00:00
|
|
|
interval: 1500
|
2022-10-17 10:17:25 +00:00
|
|
|
onTriggered: {
|
2022-11-25 09:13:02 +00:00
|
|
|
let result = store.splitAndFormatAddressPrefix(recipientSelector.input.text, isBridgeTx, networkSelector.showUnpreferredNetworks)
|
|
|
|
popup.addressText = result.address
|
|
|
|
recipientSelector.input.text = result.formattedText
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.recalculateRoutesAndFees()
|
|
|
|
}
|
|
|
|
}
|
2022-12-19 13:02:56 +00:00
|
|
|
|
|
|
|
onErrorTypeChanged: {
|
|
|
|
if(errorType === Constants.SendAmountExceedsBalance)
|
|
|
|
bestRoutes = []
|
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
width: 556
|
2022-08-29 16:28:54 +00:00
|
|
|
topMargin: 64 + header.height
|
2022-07-27 21:10:00 +00:00
|
|
|
|
|
|
|
padding: 0
|
|
|
|
background: StatusDialogBackground {
|
|
|
|
color: Theme.palette.baseColor3
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
onSelectedAccountChanged: popup.recalculateRoutesAndFees()
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
onOpened: {
|
2022-12-09 09:10:05 +00:00
|
|
|
if(!isBridgeTx) {
|
2022-11-25 09:13:02 +00:00
|
|
|
store.setDefaultPreferredDisabledChains()
|
2022-12-09 09:10:05 +00:00
|
|
|
}
|
2022-12-01 15:48:44 +00:00
|
|
|
|
2022-12-14 21:06:14 +00:00
|
|
|
amountToSendInput.input.input.edit.forceActiveFocus()
|
2021-06-29 13:25:05 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
if(!!popup.preSelectedAsset) {
|
|
|
|
assetSelector.selectedAsset = popup.preSelectedAsset
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-05-19 08:53:57 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
if(!!popup.preDefinedAmountToSend) {
|
2022-12-14 21:06:14 +00:00
|
|
|
amountToSendInput.input.text = popup.preDefinedAmountToSend
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!!popup.preSelectedRecipient) {
|
|
|
|
recipientSelector.input.text = popup.preSelectedRecipient
|
|
|
|
d.waitTimer.restart()
|
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
|
|
|
|
if(popup.isBridgeTx) {
|
|
|
|
recipientSelector.input.text = popup.selectedAccount.address
|
|
|
|
d.waitTimer.restart()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-25 09:13:02 +00:00
|
|
|
onClosed: popup.store.resetTxStoreProperties()
|
2020-08-20 04:45:29 +00:00
|
|
|
|
2022-11-11 09:24:26 +00:00
|
|
|
header: AccountsModalHeader {
|
2022-07-27 21:10:00 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: -height - 18
|
2022-06-27 13:41:47 +00:00
|
|
|
model: popup.store.accounts
|
|
|
|
selectedAccount: popup.selectedAccount
|
2022-11-11 09:24:26 +00:00
|
|
|
changeSelectedAccount: function(newAccount, newIndex) {
|
2022-08-01 17:04:23 +00:00
|
|
|
if (newIndex > popup.store.accounts) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
popup.store.switchAccount(newIndex)
|
2022-05-19 08:53:57 +00:00
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
StackLayout {
|
2022-03-18 14:47:51 +00:00
|
|
|
id: stack
|
2022-08-29 16:28:54 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
currentIndex: 0
|
|
|
|
clip: true
|
|
|
|
ColumnLayout {
|
2020-08-20 04:45:29 +00:00
|
|
|
id: group1
|
2022-08-29 16:28:54 +00:00
|
|
|
Layout.preferredWidth: parent.width
|
2022-06-27 13:41:47 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.preferredWidth: parent.width
|
2022-11-30 18:57:00 +00:00
|
|
|
Layout.preferredHeight: assetAndAmmountSelector.height + Style.current.halfPadding
|
2022-08-29 16:28:54 +00:00
|
|
|
color: Theme.palette.baseColor3
|
2022-11-30 18:57:00 +00:00
|
|
|
z: 100
|
2022-08-29 16:28:54 +00:00
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
layer.enabled: scrollView.contentY > 0
|
2022-08-29 16:28:54 +00:00
|
|
|
layer.effect: DropShadow {
|
2022-11-30 18:57:00 +00:00
|
|
|
verticalOffset: 0
|
|
|
|
radius: 8
|
2022-08-29 16:28:54 +00:00
|
|
|
samples: 17
|
|
|
|
color: Theme.palette.dropShadow
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
Column {
|
|
|
|
id: assetAndAmmountSelector
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.xlPadding
|
|
|
|
anchors.rightMargin: Style.current.xlPadding
|
|
|
|
z: 1
|
2022-12-14 21:06:14 +00:00
|
|
|
spacing: 16
|
2022-08-29 16:28:54 +00:00
|
|
|
|
2022-12-14 21:06:14 +00:00
|
|
|
RowLayout {
|
|
|
|
width: parent.width
|
|
|
|
spacing: 8
|
2022-08-29 16:28:54 +00:00
|
|
|
StatusBaseText {
|
2022-10-17 10:17:25 +00:00
|
|
|
id: modalHeader
|
2022-12-14 21:06:14 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
2022-11-23 17:58:22 +00:00
|
|
|
text: popup.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
|
2022-12-14 21:06:14 +00:00
|
|
|
font.pixelSize: 28
|
|
|
|
lineHeight: 38
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
font.letterSpacing: -0.4
|
2022-08-29 16:28:54 +00:00
|
|
|
color: Theme.palette.directColor1
|
2022-12-14 21:06:14 +00:00
|
|
|
Layout.maximumWidth: contentWidth
|
2022-08-18 20:49:50 +00:00
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
StatusAssetSelector {
|
|
|
|
id: assetSelector
|
2022-12-14 21:06:14 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
2022-10-17 10:17:25 +00:00
|
|
|
enabled: popup.interactive
|
|
|
|
assets: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : []
|
2022-08-29 16:28:54 +00:00
|
|
|
defaultToken: Style.png("tokens/DEFAULT-TOKEN@3x")
|
2022-12-14 21:06:14 +00:00
|
|
|
placeholderText: qsTr("Select token")
|
2022-12-16 08:50:56 +00:00
|
|
|
currentCurrencySymbol: RootStore.currencyStore.currentCurrencySymbol
|
2022-08-29 16:28:54 +00:00
|
|
|
tokenAssetSourceFn: function (symbol) {
|
|
|
|
return symbol ? Style.png("tokens/%1".arg(symbol)) : defaultToken
|
|
|
|
}
|
|
|
|
searchTokenSymbolByAddressFn: function (address) {
|
|
|
|
if(popup.selectedAccount) {
|
|
|
|
return popup.selectedAccount.findTokenSymbolByAddress(address)
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
2022-12-16 08:50:56 +00:00
|
|
|
getNetworkIcon: function(chainId){
|
|
|
|
return RootStore.getNetworkIcon(chainId)
|
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
onSelectedAssetChanged: {
|
2022-12-19 13:02:56 +00:00
|
|
|
if (!assetSelector.selectedAsset || !amountToSendInput.input.text || isNaN(amountToSendInput.input.text)) {
|
2022-08-29 16:28:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
popup.recalculateRoutesAndFees()
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-14 21:06:14 +00:00
|
|
|
StatusListItemTag {
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
|
|
|
Layout.preferredHeight: 22
|
2023-01-08 22:23:51 +00:00
|
|
|
title: d.maxFiatBalance && d.maxFiatBalance.amount > 0 ? qsTr("Max: %1").arg(LocaleUtils.currencyAmountToLocaleString(d.maxFiatBalance)) : qsTr("No balances active")
|
2022-12-14 21:06:14 +00:00
|
|
|
closeButtonVisible: false
|
|
|
|
titleText.font.pixelSize: 12
|
2022-12-19 13:02:56 +00:00
|
|
|
bgColor: amountToSendInput.input.valid ? Theme.palette.primaryColor3 : Theme.palette.dangerColor2
|
|
|
|
titleText.color: amountToSendInput.input.valid ? Theme.palette.primaryColor1 : Theme.palette.dangerColor1
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2022-12-14 21:06:14 +00:00
|
|
|
}
|
|
|
|
RowLayout {
|
|
|
|
width: parent.width
|
|
|
|
AmountToSend {
|
|
|
|
id: amountToSendInput
|
|
|
|
Layout.fillWidth:true
|
|
|
|
isBridgeTx: popup.isBridgeTx
|
|
|
|
interactive: popup.interactive
|
|
|
|
selectedAsset: assetSelector.selectedAsset
|
|
|
|
maxFiatBalance: d.maxFiatBalance
|
2022-12-19 13:02:56 +00:00
|
|
|
currentCurrency: popup.store.currentCurrency
|
|
|
|
getFiatValue: function(cryptoValue) {
|
2023-01-08 22:23:51 +00:00
|
|
|
return selectedAsset ? popup.currencyStore.getFiatValue(cryptoValue, selectedAsset.symbol, currentCurrency) : undefined
|
2022-12-19 13:02:56 +00:00
|
|
|
}
|
|
|
|
getCryptoValue: function(fiatValue) {
|
2023-01-08 22:23:51 +00:00
|
|
|
return selectedAsset ? popup.currencyStore.getCryptoValue(fiatValue, selectedAsset.symbol, currentCurrency) : undefined
|
|
|
|
}
|
|
|
|
getFiatCurrencyAmount: function(fiatValue) {
|
|
|
|
return popup.currencyStore.getCurrencyAmount(fiatValue, currentCurrency)
|
|
|
|
}
|
|
|
|
getCryptoCurrencyAmount: function(cryptoValue) {
|
|
|
|
return selectedAsset ? popup.currencyStore.getCurrencyAmount(cryptoValue, selectedAsset.symbol) : undefined
|
2022-12-19 13:02:56 +00:00
|
|
|
}
|
2022-12-14 21:06:14 +00:00
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
2022-12-14 21:06:14 +00:00
|
|
|
AmountToReceive {
|
|
|
|
id: amountToReceive
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
Layout.fillWidth:true
|
|
|
|
visible: popup.bestRoutes !== undefined && popup.bestRoutes.length > 0
|
|
|
|
store: popup.store
|
|
|
|
isLoading: popup.isLoading
|
|
|
|
selectedAsset: assetSelector.selectedAsset
|
|
|
|
isBridgeTx: popup.isBridgeTx
|
2023-01-08 22:23:51 +00:00
|
|
|
cryptoValueToReceive: d.totalAmountToReceive
|
|
|
|
inputIsFiat: amountToSendInput.inputIsFiat
|
|
|
|
currentCurrency: popup.store.currentCurrency
|
|
|
|
getFiatValue: function(cryptoValue) {
|
|
|
|
return popup.currencyStore.getFiatValue(cryptoValue, selectedAsset.symbol, currentCurrency)
|
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
TokenListView {
|
|
|
|
id: tokenListRect
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
visible: !assetSelector.selectedAsset
|
|
|
|
assets: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : []
|
|
|
|
searchTokenSymbolByAddressFn: function (address) {
|
|
|
|
if(popup.selectedAccount) {
|
|
|
|
return popup.selectedAccount.findTokenSymbolByAddress(address)
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
2022-12-16 08:50:56 +00:00
|
|
|
getNetworkIcon: function(chainId){
|
|
|
|
return RootStore.getNetworkIcon(chainId)
|
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
onTokenSelected: {
|
|
|
|
assetSelector.userSelectedToken = selectedToken.symbol
|
|
|
|
assetSelector.selectedAsset = selectedToken
|
|
|
|
}
|
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2022-06-27 13:41:47 +00:00
|
|
|
id: scrollView
|
2022-12-14 21:06:14 +00:00
|
|
|
topPadding: 12
|
2022-08-29 16:28:54 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.preferredWidth: parent.width
|
2022-11-23 17:58:22 +00:00
|
|
|
contentHeight: layout.height + Style.current.padding
|
2022-08-29 16:28:54 +00:00
|
|
|
contentWidth: parent.width
|
2022-07-21 08:40:49 +00:00
|
|
|
z: 0
|
2022-07-21 12:15:02 +00:00
|
|
|
objectName: "sendModalScroll"
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
Column {
|
|
|
|
id: layout
|
2022-07-20 11:15:05 +00:00
|
|
|
width: scrollView.availableWidth
|
2022-11-23 17:58:22 +00:00
|
|
|
spacing: Style.current.bigPadding
|
2022-07-14 17:47:59 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
|
2022-08-25 19:20:21 +00:00
|
|
|
StatusInput {
|
2022-07-20 11:15:05 +00:00
|
|
|
id: recipientSelector
|
2022-08-25 19:20:21 +00:00
|
|
|
property bool isPending: false
|
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
height: visible ? implicitHeight: 0
|
|
|
|
visible: !isBridgeTx && !!assetSelector.selectedAsset
|
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
width: parent.width
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2022-07-27 21:10:00 +00:00
|
|
|
|
2022-08-25 19:20:21 +00:00
|
|
|
label: qsTr("To")
|
|
|
|
placeholderText: qsTr("Enter an ENS name or address")
|
|
|
|
input.background.color: Theme.palette.indirectColor1
|
|
|
|
input.background.border.width: 0
|
|
|
|
input.implicitHeight: 56
|
2022-10-17 10:17:25 +00:00
|
|
|
input.clearable: popup.interactive
|
|
|
|
input.edit.readOnly: !popup.interactive
|
2022-08-25 19:20:21 +00:00
|
|
|
multiline: false
|
2022-10-17 10:17:25 +00:00
|
|
|
input.edit.textFormat: TextEdit.RichText
|
2022-08-25 19:20:21 +00:00
|
|
|
input.rightComponent: RowLayout {
|
2022-11-25 09:13:02 +00:00
|
|
|
StatusIcon {
|
|
|
|
Layout.preferredWidth: 16
|
|
|
|
Layout.preferredHeight: 16
|
|
|
|
icon: "tiny/checkmark"
|
|
|
|
color: Theme.palette.primaryColor1
|
|
|
|
visible: d.recipientReady
|
2022-08-25 19:20:21 +00:00
|
|
|
}
|
|
|
|
StatusFlatRoundButton {
|
|
|
|
visible: recipientSelector.text !== ""
|
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
Layout.preferredWidth: 24
|
|
|
|
Layout.preferredHeight: 24
|
|
|
|
icon.name: "clear"
|
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
|
|
|
icon.color: Theme.palette.baseColor1
|
|
|
|
backgroundHoverColor: "transparent"
|
2022-10-17 10:17:25 +00:00
|
|
|
onClicked: {
|
|
|
|
recipientSelector.input.edit.clear()
|
|
|
|
d.waitTimer.restart()
|
|
|
|
}
|
2022-08-25 19:20:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Keys.onReleased: {
|
2022-10-17 10:17:25 +00:00
|
|
|
d.waitTimer.restart()
|
2022-08-25 19:20:21 +00:00
|
|
|
if(!d.isAddressValid) {
|
|
|
|
isPending = true
|
|
|
|
Qt.callLater(d.resolveENS, input.edit.text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-27 21:10:00 +00:00
|
|
|
|
2022-08-25 19:20:21 +00:00
|
|
|
Connections {
|
|
|
|
target: store.mainModuleInst
|
|
|
|
onResolvedENS: {
|
|
|
|
recipientSelector.isPending = false
|
|
|
|
if(Utils.isValidAddress(resolvedAddress)) {
|
|
|
|
d.resolvedENSAddress = resolvedAddress
|
|
|
|
d.isENSValid = true
|
|
|
|
}
|
2022-07-27 21:10:00 +00:00
|
|
|
}
|
2021-04-22 04:03:46 +00:00
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-07-20 11:15:05 +00:00
|
|
|
TabAddressSelectorView {
|
|
|
|
id: addressSelector
|
2022-08-29 16:28:54 +00:00
|
|
|
width: parent.width
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2022-07-20 11:15:05 +00:00
|
|
|
store: popup.store
|
|
|
|
onContactSelected: {
|
|
|
|
recipientSelector.input.text = address
|
2022-10-17 10:17:25 +00:00
|
|
|
d.waitTimer.restart()
|
2022-07-20 11:15:05 +00:00
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
visible: !d.recipientReady && !isBridgeTx && !!assetSelector.selectedAsset
|
2022-05-19 08:53:57 +00:00
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-07-20 11:15:05 +00:00
|
|
|
NetworkSelector {
|
|
|
|
id: networkSelector
|
2022-08-29 16:28:54 +00:00
|
|
|
width: parent.width
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2022-07-20 11:15:05 +00:00
|
|
|
store: popup.store
|
2022-10-17 10:17:25 +00:00
|
|
|
interactive: popup.interactive
|
2022-07-20 11:15:05 +00:00
|
|
|
selectedAccount: popup.selectedAccount
|
2023-01-08 22:23:51 +00:00
|
|
|
amountToSend: amountToSendInput.cryptoValueToSend
|
|
|
|
requiredGasInEth: d.totalFeesInEth
|
2022-07-20 11:15:05 +00:00
|
|
|
selectedAsset: assetSelector.selectedAsset
|
2022-10-17 10:17:25 +00:00
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
|
2022-11-23 17:58:22 +00:00
|
|
|
visible: d.recipientReady && !!assetSelector.selectedAsset
|
2022-12-19 13:02:56 +00:00
|
|
|
errorType: d.errorType
|
2022-10-17 10:17:25 +00:00
|
|
|
isLoading: popup.isLoading
|
|
|
|
bestRoutes: popup.bestRoutes
|
2022-11-23 17:58:22 +00:00
|
|
|
isBridgeTx: popup.isBridgeTx
|
2022-07-20 11:15:05 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
FeesView {
|
2022-07-20 11:15:05 +00:00
|
|
|
id: fees
|
2022-08-29 16:28:54 +00:00
|
|
|
width: parent.width
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2022-11-30 12:59:21 +00:00
|
|
|
visible: d.recipientReady && !!assetSelector.selectedAsset && networkSelector.advancedOrCustomMode
|
2022-11-23 17:58:22 +00:00
|
|
|
selectedTokenSymbol: assetSelector.selectedAsset ? assetSelector.selectedAsset.symbol: ""
|
|
|
|
isLoading: popup.isLoading
|
|
|
|
bestRoutes: popup.bestRoutes
|
|
|
|
store: popup.store
|
2022-11-30 12:59:21 +00:00
|
|
|
gasFiatAmount: d.totalFeesInFiat
|
2022-12-19 13:02:56 +00:00
|
|
|
errorType: d.errorType
|
2022-07-01 11:24:32 +00:00
|
|
|
}
|
2020-08-20 04:45:29 +00:00
|
|
|
}
|
2020-10-19 09:39:07 +00:00
|
|
|
}
|
2020-08-20 04:45:29 +00:00
|
|
|
}
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
|
|
|
|
2022-07-27 21:10:00 +00:00
|
|
|
footer: SendModalFooter {
|
2022-11-23 17:58:22 +00:00
|
|
|
nextButtonText: popup.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
|
2023-01-08 22:23:51 +00:00
|
|
|
maxFiatFees: popup.isLoading ? "..." : LocaleUtils.currencyAmountToLocaleString(d.totalFeesInFiat)
|
2022-11-30 12:59:21 +00:00
|
|
|
totalTimeEstimate: popup.isLoading? "..." : d.totalTimeEstimate
|
2022-10-20 12:58:56 +00:00
|
|
|
pending: d.isPendingTx || popup.isLoading
|
2023-01-17 20:05:21 +00:00
|
|
|
visible: d.recipientReady && amountToSendInput.cryptoValueToSend && amountToSendInput.cryptoValueToSend.amount > 0 && !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-03-18 14:47:51 +00:00
|
|
|
Component {
|
|
|
|
id: transactionSettingsConfirmationPopupComponent
|
|
|
|
TransactionSettingsConfirmationPopup {}
|
|
|
|
}
|
2021-07-05 12:34:56 +00:00
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
Connections {
|
|
|
|
target: popup.store.walletSectionTransactionsInst
|
|
|
|
onSuggestedRoutesReady: {
|
|
|
|
let response = JSON.parse(suggestedRoutes)
|
|
|
|
if(!!response.error) {
|
|
|
|
popup.isLoading = false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
popup.bestRoutes = response.suggestedRoutes.best
|
2022-11-30 12:59:21 +00:00
|
|
|
let gasTimeEstimate = response.suggestedRoutes.gasTimeEstimate
|
|
|
|
d.totalTimeEstimate = popup.store.getLabelForEstimatedTxTime(gasTimeEstimate.totalTime)
|
2023-01-08 22:23:51 +00:00
|
|
|
d.totalFeesInEth = popup.currencyStore.getCurrencyAmount(gasTimeEstimate.totalFeesInEth, "ETH")
|
|
|
|
let totalFeesInFiat = popup.currencyStore.getFiatValue( gasTimeEstimate.totalFeesInEth, "ETH", popup.store.currentCurrency).amount +
|
|
|
|
popup.currencyStore.getFiatValue(gasTimeEstimate.totalTokenFees, fees.selectedTokenSymbol, popup.store.currentCurrency).amount
|
|
|
|
d.totalFeesInFiat = popup.currencyStore.getCurrencyAmount(totalFeesInFiat, popup.store.currentCurrency)
|
|
|
|
d.totalAmountToReceive = popup.currencyStore.getCurrencyAmount(popup.store.getWei2Eth(response.suggestedRoutes.amountToReceive, assetSelector.selectedAsset.decimals), fees.selectedTokenSymbol)
|
2022-12-14 21:06:14 +00:00
|
|
|
networkSelector.toNetworksList = response.suggestedRoutes.toNetworks
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.isLoading = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
Connections {
|
|
|
|
target: popup.store.walletSectionTransactionsInst
|
|
|
|
onTransactionSent: {
|
2022-10-17 10:17:25 +00:00
|
|
|
d.isPendingTx = false
|
2022-03-18 14:47:51 +00:00
|
|
|
try {
|
|
|
|
let response = JSON.parse(txResult)
|
2022-08-29 16:28:54 +00:00
|
|
|
if (response.uuid !== d.uuid) return
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
if (!response.success) {
|
2022-11-30 18:57:00 +00:00
|
|
|
if (response.error.includes(Constants.walletSection.cancelledMessage)) {
|
2022-10-17 10:17:25 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
sendingError.text = response.error
|
2022-03-18 14:47:51 +00:00
|
|
|
return sendingError.open()
|
2022-02-24 19:24:58 +00:00
|
|
|
}
|
2022-10-17 10:17:25 +00:00
|
|
|
for(var i=0; i<popup.bestRoutes.length; i++) {
|
|
|
|
let txHash = response.result[popup.bestRoutes[i].fromNetwork.chainId]
|
2022-12-08 15:56:02 +00:00
|
|
|
let url = "%1/%2".arg(popup.store.getEtherscanLink(popup.bestRoutes[i].fromNetwork.chainId)).arg(txHash)
|
2022-10-17 10:17:25 +00:00
|
|
|
Global.displayToastMessage(qsTr("Transaction pending..."),
|
|
|
|
qsTr("View on etherscan"),
|
|
|
|
"",
|
|
|
|
true,
|
|
|
|
Constants.ephemeralNotificationType.normal,
|
|
|
|
url)
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
|
|
|
|
popup.close()
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Error parsing the response', e)
|
2022-02-24 19:24:58 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|