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-03-18 14:47:51 +00:00
|
|
|
import StatusQ.Components 0.1
|
2023-05-10 11:19:25 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
2022-03-18 14:47:51 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-05-10 11:19:25 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2021-10-21 15:07:13 +00:00
|
|
|
|
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
|
2023-05-04 12:55:39 +00:00
|
|
|
property var selectedAccount: store.selectedSenderAccount
|
2022-10-17 10:17:25 +00:00
|
|
|
property var bestRoutes
|
2023-04-18 16:05:24 +00:00
|
|
|
property alias addressText: recipientLoader.addressText
|
2022-10-17 10:17:25 +00:00
|
|
|
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-17 10:17:25 +00:00
|
|
|
property var sendTransaction: function() {
|
2023-04-18 16:05:24 +00:00
|
|
|
let recipientAddress = Utils.isValidAddress(popup.addressText) ? popup.addressText : recipientLoader.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,
|
2023-02-17 12:56:31 +00:00
|
|
|
d.selectedSymbol,
|
|
|
|
amountToSendInput.cryptoValueToSend,
|
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() {
|
2023-04-18 16:05:24 +00:00
|
|
|
if(!!popup.selectedAccount && !!assetSelector.selectedAsset && recipientLoader.ready && amountToSendInput.inputNumberValid) {
|
2022-10-17 10:17:25 +00:00
|
|
|
popup.isLoading = true
|
2023-02-17 12:56:31 +00:00
|
|
|
let amount = Math.round(amountToSendInput.cryptoValueToSend * 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 :
|
2023-04-18 16:05:24 +00:00
|
|
|
(networkSelector.bestRoutes && networkSelector.bestRoutes.length <= 0 && !!amountToSendInput.input.text && recipientLoader.ready && !popup.isLoading) ?
|
2022-12-19 13:02:56 +00:00
|
|
|
Constants.NoRoute : Constants.NoError
|
2023-02-17 12:56:31 +00:00
|
|
|
readonly property double maxFiatBalance: !!assetSelector.selectedAsset ? assetSelector.selectedAsset.totalCurrencyBalance.amount : 0
|
|
|
|
readonly property double maxCryptoBalance: !!assetSelector.selectedAsset ? assetSelector.selectedAsset.totalBalance.amount : 0
|
|
|
|
readonly property double maxInputBalance: amountToSendInput.inputIsFiat ? maxFiatBalance : maxCryptoBalance
|
|
|
|
readonly property string selectedSymbol: !!assetSelector.selectedAsset ? assetSelector.selectedAsset.symbol : ""
|
|
|
|
readonly property string inputSymbol: amountToSendInput.inputIsFiat ? popup.store.currentCurrency : selectedSymbol
|
2023-04-18 16:05:24 +00:00
|
|
|
readonly property bool errorMode: popup.isLoading || !recipientLoader.ready ? false : errorType !== Constants.NoError || networkSelector.errorMode || !amountToSendInput.inputNumberValid
|
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 totalFeesInEth
|
|
|
|
property double totalFeesInFiat
|
|
|
|
property double totalAmountToReceive
|
2022-10-17 10:17:25 +00:00
|
|
|
|
2023-03-15 09:17:25 +00:00
|
|
|
readonly property NetworkConnectionStore networkConnectionStore: NetworkConnectionStore {}
|
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
|
2023-04-18 16:05:24 +00:00
|
|
|
bottomPadding: footer.visible ? 0 : 32
|
2022-07-27 21:10:00 +00:00
|
|
|
|
|
|
|
padding: 0
|
|
|
|
background: StatusDialogBackground {
|
|
|
|
color: Theme.palette.baseColor3
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2023-01-27 13:16:42 +00:00
|
|
|
onIsLoadingChanged: if(isLoading) bestRoutes = []
|
|
|
|
|
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
|
|
|
}
|
2023-01-27 13:16:42 +00:00
|
|
|
else {
|
|
|
|
store.setAllNetworksAsPreferredChains()
|
|
|
|
}
|
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) {
|
2023-04-18 16:05:24 +00:00
|
|
|
recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address
|
|
|
|
recipientLoader.selectedRecipient = {address: popup.preSelectedRecipient}
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
|
|
|
|
if(popup.isBridgeTx) {
|
2023-04-18 16:05:24 +00:00
|
|
|
recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address
|
|
|
|
recipientLoader.selectedRecipient = {address: popup.selectedAccount.address}
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|
2023-03-15 09:17:25 +00:00
|
|
|
|
|
|
|
// add networks that are down to disabled list
|
2023-04-25 07:39:42 +00:00
|
|
|
if(d.networkConnectionStore.blockchainNetworksDown.length !== 0) {
|
2023-03-15 09:17:25 +00:00
|
|
|
for(let i in d.networkConnectionStore.blockchainNetworksDown) {
|
|
|
|
store.addRemoveDisabledToChain(parseInt(d.networkConnectionStore.blockchainNetworksDown[i]), true)
|
|
|
|
}
|
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|
|
|
|
|
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
|
2023-05-04 12:55:39 +00:00
|
|
|
model: popup.store.senderAccounts
|
2023-04-24 18:35:34 +00:00
|
|
|
selectedAccount: !!popup.selectedAccount ? popup.selectedAccount: {}
|
2023-04-26 15:53:49 +00:00
|
|
|
chainShortNames: store.getAllNetworksSupportedPrefix()
|
2023-05-04 12:55:39 +00:00
|
|
|
onSelectedIndexChanged: store.switchSenderAccount(selectedIndex)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
|
2023-05-10 11:19:25 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: group1
|
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
anchors.fill: parent
|
2023-05-10 11:19:25 +00:00
|
|
|
|
|
|
|
// Workaround for https://bugreports.qt.io/browse/QTBUG-87804
|
|
|
|
onImplicitHeightChanged: {
|
|
|
|
margins--
|
|
|
|
margins++
|
|
|
|
}
|
|
|
|
|
|
|
|
ClippingWrapper {
|
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
|
|
|
|
|
|
|
|
clipBottomMargin: 20
|
2022-06-27 13:41:47 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
Rectangle {
|
2023-05-10 11:19:25 +00:00
|
|
|
anchors.fill: parent
|
2023-02-02 15:28:39 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
color: Theme.palette.baseColor3
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-02-02 15:28:39 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: assetAndAmountSelector
|
|
|
|
|
|
|
|
anchors.fill: parent
|
2022-08-29 16:28:54 +00:00
|
|
|
anchors.leftMargin: Style.current.xlPadding
|
|
|
|
anchors.rightMargin: Style.current.xlPadding
|
2023-02-02 15:28:39 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
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 {
|
|
|
|
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
|
2023-04-06 12:59:24 +00:00
|
|
|
assets: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : null
|
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) {
|
2023-04-06 12:59:24 +00:00
|
|
|
return store.findTokenSymbolByAddress(address)
|
2022-08-29 16:28:54 +00:00
|
|
|
}
|
2022-12-16 08:50:56 +00:00
|
|
|
getNetworkIcon: function(chainId){
|
|
|
|
return RootStore.getNetworkIcon(chainId)
|
|
|
|
}
|
2023-05-04 12:55:39 +00:00
|
|
|
onAssetsChanged: {
|
|
|
|
// Todo we should not need to do this, this should be automatic when selected account changes
|
|
|
|
if(!!selectedAccount && !!assetSelector.selectedAsset)
|
|
|
|
assetSelector.selectedAsset = store.getAsset(selectedAccount.assets, assetSelector.selectedAsset.symbol)
|
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
onSelectedAssetChanged: {
|
2023-03-08 19:35:18 +00:00
|
|
|
if (!assetSelector.selectedAsset || !amountToSendInput.inputNumberValid) {
|
2022-08-29 16:28:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
popup.recalculateRoutesAndFees()
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
visible: !!assetSelector.selectedAsset || !!assetSelector.hoveredToken
|
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-04-18 16:05:24 +00:00
|
|
|
visible: !!assetSelector.selectedAsset || !!assetSelector.hoveredToken
|
2023-01-27 12:19:23 +00:00
|
|
|
title: {
|
2023-04-18 16:05:24 +00:00
|
|
|
if(!!assetSelector.hoveredToken) {
|
2023-04-24 18:35:34 +00:00
|
|
|
const balance = popup.currencyStore.formatCurrencyAmount((amountToSendInput.inputIsFiat ? assetSelector.hoveredToken.totalCurrencyBalance.amount : assetSelector.hoveredToken.totalBalance.amount) , assetSelector.hoveredToken.symbol)
|
2023-04-18 16:05:24 +00:00
|
|
|
return qsTr("Max: %1").arg(balance)
|
|
|
|
}
|
2023-02-17 12:56:31 +00:00
|
|
|
if (d.maxInputBalance <= 0)
|
2023-01-27 12:19:23 +00:00
|
|
|
return qsTr("No balances active")
|
2023-02-17 12:56:31 +00:00
|
|
|
const balance = popup.currencyStore.formatCurrencyAmount(d.maxInputBalance, d.inputSymbol)
|
2023-01-27 12:19:23 +00:00
|
|
|
return qsTr("Max: %1").arg(balance)
|
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
tagClickable: true
|
2022-12-14 21:06:14 +00:00
|
|
|
closeButtonVisible: false
|
|
|
|
titleText.font.pixelSize: 12
|
2023-04-18 16:05:24 +00:00
|
|
|
bgColor: amountToSendInput.input.valid || !amountToSendInput.input.text ? Theme.palette.primaryColor3 : Theme.palette.dangerColor2
|
|
|
|
titleText.color: amountToSendInput.input.valid || !amountToSendInput.input.text ? Theme.palette.primaryColor1 : Theme.palette.dangerColor1
|
|
|
|
onTagClicked: amountToSendInput.input.text = d.maxInputBalance
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TokenListView {
|
|
|
|
id: tokenListRect
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
visible: !assetSelector.selectedAsset
|
|
|
|
assets: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : null
|
|
|
|
searchTokenSymbolByAddressFn: function (address) {
|
|
|
|
return store.findTokenSymbolByAddress(address)
|
|
|
|
}
|
|
|
|
getNetworkIcon: function(chainId){
|
|
|
|
return RootStore.getNetworkIcon(chainId)
|
|
|
|
}
|
|
|
|
onTokenSelected: {
|
|
|
|
assetSelector.selectedAsset = selectedToken
|
|
|
|
}
|
|
|
|
onTokenHovered: {
|
|
|
|
if(hovered)
|
|
|
|
assetSelector.hoveredToken = selectedToken
|
|
|
|
else
|
|
|
|
assetSelector.hoveredToken = null
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2022-12-14 21:06:14 +00:00
|
|
|
}
|
|
|
|
RowLayout {
|
2023-04-18 16:05:24 +00:00
|
|
|
visible: !!assetSelector.selectedAsset
|
2022-12-14 21:06:14 +00:00
|
|
|
AmountToSend {
|
|
|
|
id: amountToSendInput
|
|
|
|
Layout.fillWidth:true
|
|
|
|
isBridgeTx: popup.isBridgeTx
|
|
|
|
interactive: popup.interactive
|
2023-02-17 12:56:31 +00:00
|
|
|
selectedSymbol: d.selectedSymbol
|
|
|
|
maxInputBalance: d.maxInputBalance
|
2022-12-19 13:02:56 +00:00
|
|
|
currentCurrency: popup.store.currentCurrency
|
|
|
|
getFiatValue: function(cryptoValue) {
|
2023-02-17 12:56:31 +00:00
|
|
|
return selectedSymbol ? popup.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency) : 0.0
|
2022-12-19 13:02:56 +00:00
|
|
|
}
|
|
|
|
getCryptoValue: function(fiatValue) {
|
2023-02-17 12:56:31 +00:00
|
|
|
return selectedSymbol ? popup.currencyStore.getCryptoValue(fiatValue, selectedSymbol, currentCurrency) : 0.0
|
2022-12-19 13:02:56 +00:00
|
|
|
}
|
2023-02-17 12:56:31 +00:00
|
|
|
formatCurrencyAmount: popup.currencyStore.formatCurrencyAmount
|
2022-12-14 21:06:14 +00:00
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
2023-02-02 15:28:39 +00:00
|
|
|
|
|
|
|
// Horizontal spacer
|
|
|
|
RowLayout {}
|
|
|
|
|
2022-12-14 21:06:14 +00:00
|
|
|
AmountToReceive {
|
|
|
|
id: amountToReceive
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
Layout.fillWidth:true
|
2023-03-08 19:35:18 +00:00
|
|
|
visible: popup.bestRoutes !== undefined && popup.bestRoutes.length > 0 && amountToSendInput.inputNumberValid
|
2022-12-14 21:06:14 +00:00
|
|
|
store: popup.store
|
|
|
|
isLoading: popup.isLoading
|
2023-02-17 12:56:31 +00:00
|
|
|
selectedSymbol: d.selectedSymbol
|
2022-12-14 21:06:14 +00:00
|
|
|
isBridgeTx: popup.isBridgeTx
|
2023-01-08 22:23:51 +00:00
|
|
|
cryptoValueToReceive: d.totalAmountToReceive
|
|
|
|
inputIsFiat: amountToSendInput.inputIsFiat
|
2023-02-17 14:09:15 +00:00
|
|
|
minCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals
|
|
|
|
minFiatDecimals: amountToSendInput.minReceiveFiatDecimals
|
2023-01-08 22:23:51 +00:00
|
|
|
currentCurrency: popup.store.currentCurrency
|
|
|
|
getFiatValue: function(cryptoValue) {
|
2023-02-17 12:56:31 +00:00
|
|
|
return popup.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency)
|
2023-01-08 22:23:51 +00:00
|
|
|
}
|
2023-02-17 12:56:31 +00:00
|
|
|
formatCurrencyAmount: popup.currencyStore.formatCurrencyAmount
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-10 11:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ClippingWrapper {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
implicitWidth: scrollView.implicitWidth
|
|
|
|
implicitHeight: scrollView.implicitHeight
|
|
|
|
|
|
|
|
clipTopMargin: 40
|
|
|
|
clipBottomMargin: popup.bottomPadding
|
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
|
2023-05-10 11:19:25 +00:00
|
|
|
|
2022-12-14 21:06:14 +00:00
|
|
|
topPadding: 12
|
2023-05-10 11:19:25 +00:00
|
|
|
anchors.fill: parent
|
2023-02-09 14:50:30 +00:00
|
|
|
|
|
|
|
implicitWidth: contentWidth + leftPadding + rightPadding
|
|
|
|
implicitHeight: contentHeight + topPadding + bottomPadding
|
|
|
|
|
2023-05-10 11:19:25 +00:00
|
|
|
contentHeight: layout.implicitHeight
|
2023-02-15 14:55:16 +00:00
|
|
|
|
2023-05-10 11:19:25 +00:00
|
|
|
clip: false
|
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
|
|
|
|
|
2023-04-18 16:05:24 +00:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: 8
|
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
|
2023-04-18 16:05:24 +00:00
|
|
|
visible: !isBridgeTx && !!assetSelector.selectedAsset
|
|
|
|
StatusBaseText {
|
|
|
|
id: label
|
|
|
|
elide: Text.ElideRight
|
|
|
|
text: qsTr("To")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
2022-08-25 19:20:21 +00:00
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
RecipientView {
|
|
|
|
id: recipientLoader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
store: popup.store
|
|
|
|
isBridgeTx: popup.isBridgeTx
|
|
|
|
interactive: popup.interactive
|
|
|
|
selectedAsset: assetSelector.selectedAsset
|
|
|
|
showUnpreferredNetworks: networkSelector.showUnpreferredNetworks
|
|
|
|
onIsLoading: popup.isLoading = true
|
|
|
|
onRecalculateRoutesAndFees: popup.recalculateRoutesAndFees()
|
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
|
2023-04-06 12:59:24 +00:00
|
|
|
selectedAccount: popup.selectedAccount
|
2023-04-18 16:05:24 +00:00
|
|
|
onRecipientSelected: {
|
|
|
|
recipientLoader.selectedRecipientType = type
|
|
|
|
recipientLoader.selectedRecipient = recipient
|
2022-07-20 11:15:05 +00:00
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
visible: !recipientLoader.ready && !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-04-18 16:05:24 +00:00
|
|
|
ensAddressOrEmpty: recipientLoader.isENSValid ? recipientLoader.resolvedENSAddress : ""
|
2023-01-08 22:23:51 +00:00
|
|
|
amountToSend: amountToSendInput.cryptoValueToSend
|
2023-02-17 14:09:15 +00:00
|
|
|
minSendCryptoDecimals: amountToSendInput.minSendCryptoDecimals
|
|
|
|
minReceiveCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals
|
2023-01-08 22:23:51 +00:00
|
|
|
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()
|
2023-04-18 16:05:24 +00:00
|
|
|
visible: recipientLoader.ready && !!assetSelector.selectedAsset && amountToSendInput.inputNumberValid
|
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
|
2023-04-18 16:05:24 +00:00
|
|
|
visible: recipientLoader.ready && !!assetSelector.selectedAsset && networkSelector.advancedOrCustomMode && amountToSendInput.inputNumberValid
|
2023-02-17 12:56:31 +00:00
|
|
|
selectedTokenSymbol: d.selectedSymbol
|
2022-11-23 17:58:22 +00:00
|
|
|
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-02-17 12:56:31 +00:00
|
|
|
maxFiatFees: popup.isLoading ? "..." : popup.currencyStore.formatCurrencyAmount(d.totalFeesInFiat, popup.store.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
|
2023-04-18 16:05:24 +00:00
|
|
|
visible: recipientLoader.ready && amountToSendInput.inputNumberValid && !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 {
|
2023-04-20 08:41:45 +00:00
|
|
|
target: popup.store.walletSectionSendInst
|
2023-01-18 09:25:36 +00:00
|
|
|
function onSuggestedRoutesReady(suggestedRoutes: string) {
|
2022-10-17 10:17:25 +00:00
|
|
|
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-02-17 12:56:31 +00:00
|
|
|
d.totalFeesInEth = gasTimeEstimate.totalFeesInEth
|
|
|
|
d.totalFeesInFiat = popup.currencyStore.getFiatValue( gasTimeEstimate.totalFeesInEth, "ETH", popup.store.currentCurrency) +
|
|
|
|
popup.currencyStore.getFiatValue(gasTimeEstimate.totalTokenFees, fees.selectedTokenSymbol, popup.store.currentCurrency)
|
|
|
|
d.totalAmountToReceive = popup.store.getWei2Eth(response.suggestedRoutes.amountToReceive, assetSelector.selectedAsset.decimals)
|
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 {
|
2023-04-20 08:41:45 +00:00
|
|
|
target: popup.store.walletSectionSendInst
|
2023-01-18 09:25:36 +00:00
|
|
|
function onTransactionSent(txResult: string) {
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|