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
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
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
|
2021-10-21 15:07:13 +00:00
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
2022-03-18 14:47:51 +00:00
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 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-03-18 14:47:51 +00:00
|
|
|
StatusModal {
|
|
|
|
id: popup
|
2022-01-04 12:06:05 +00:00
|
|
|
|
2020-10-28 07:44:09 +00:00
|
|
|
property alias stack: stack
|
2022-07-19 15:09:20 +00:00
|
|
|
property alias addressText: recipientSelector.input.text
|
2020-06-26 16:08:51 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
property var store
|
|
|
|
property var contactsStore
|
2022-06-27 13:41:47 +00:00
|
|
|
property var selectedAccount: store.currentAccount
|
2022-03-18 14:47:51 +00:00
|
|
|
property var preSelectedRecipient
|
|
|
|
property bool launchedFromChat: false
|
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
|
|
|
|
|
|
|
function sendTransaction() {
|
2022-02-01 21:03:47 +00:00
|
|
|
stack.currentGroup.isPending = true
|
|
|
|
let success = false
|
2022-05-19 08:53:57 +00:00
|
|
|
success = popup.store.transfer(
|
2022-06-27 13:41:47 +00:00
|
|
|
popup.selectedAccount.address,
|
|
|
|
recipientSelector.selectedRecipient.address,
|
|
|
|
assetSelector.selectedAsset.symbol,
|
|
|
|
amountToSendInput.text,
|
2022-05-19 08:53:57 +00:00
|
|
|
gasSelector.selectedGasLimit,
|
|
|
|
gasSelector.suggestedFees.eip1559Enabled ? "" : gasSelector.selectedGasPrice,
|
|
|
|
gasSelector.selectedTipLimit,
|
|
|
|
gasSelector.selectedOverallLimit,
|
|
|
|
transactionSigner.enteredPassword,
|
|
|
|
networkSelector.selectedNetwork.chainId || Global.currentChainId,
|
|
|
|
stack.uuid,
|
|
|
|
gasSelector.suggestedFees.eip1559Enabled,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-07-01 11:24:32 +00:00
|
|
|
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function(disabledChainIds) {
|
|
|
|
if (disabledChainIds === undefined) disabledChainIds = []
|
2022-05-19 08:53:57 +00:00
|
|
|
networkSelector.suggestedRoutes = popup.store.suggestedRoutes(
|
2022-07-01 11:24:32 +00:00
|
|
|
popup.selectedAccount.address, amountToSendInput.text, assetSelector.selectedAsset.symbol, disabledChainIds
|
2022-05-19 08:53:57 +00:00
|
|
|
)
|
|
|
|
if (networkSelector.suggestedRoutes.length) {
|
|
|
|
networkSelector.selectedNetwork = networkSelector.suggestedRoutes[0]
|
|
|
|
gasSelector.suggestedFees = popup.store.suggestedFees(networkSelector.suggestedRoutes[0].chainId)
|
|
|
|
gasSelector.checkOptimal()
|
|
|
|
gasSelector.visible = true
|
2022-02-01 21:03:47 +00:00
|
|
|
} else {
|
2022-05-19 08:53:57 +00:00
|
|
|
networkSelector.selectedNetwork = ""
|
|
|
|
gasSelector.visible = false
|
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
|
|
|
|
readonly property string maxFiatBalance: Utils.stripTrailingZeros(parseFloat(assetSelector.selectedAsset.totalBalance).toFixed(4))
|
|
|
|
readonly property bool isReady: amountToSendInput.valid && !amountToSendInput.pending && recipientSelector.isValid && !recipientSelector.isPending
|
2022-07-01 11:24:32 +00:00
|
|
|
readonly property bool errorMode: networkSelector.suggestedRoutes && networkSelector.suggestedRoutes.length <= 0 || networkSelector.errorMode
|
2022-06-27 13:41:47 +00:00
|
|
|
onIsReadyChanged: {
|
|
|
|
if(!isReady && stack.isLastGroup)
|
|
|
|
stack.back()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
width: 556
|
2022-06-27 13:41:47 +00:00
|
|
|
height: 595
|
2022-03-18 14:47:51 +00:00
|
|
|
showHeader: false
|
|
|
|
showFooter: false
|
2022-07-01 11:24:32 +00:00
|
|
|
showAdvancedFooter: d.isReady && !isNaN(parseFloat(amountToSendInput.text)) && gasValidator.isValid
|
2022-03-18 14:47:51 +00:00
|
|
|
showAdvancedHeader: true
|
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
onSelectedAccountChanged: popup.recalculateRoutesAndFees()
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
onOpened: {
|
2022-06-27 13:41:47 +00:00
|
|
|
amountToSendInput.input.edit.forceActiveFocus()
|
2021-06-29 13:25:05 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
if(popup.launchedFromChat) {
|
|
|
|
recipientSelector.selectedType = RecipientSelector.Type.Contact
|
|
|
|
recipientSelector.readOnly = true
|
|
|
|
recipientSelector.selectedRecipient = popup.preSelectedRecipient
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-05-19 08:53:57 +00:00
|
|
|
|
2022-06-07 13:57:09 +00:00
|
|
|
popup.recalculateRoutesAndFees()
|
2020-08-20 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
hasFloatingButtons: true
|
2022-03-18 14:47:51 +00:00
|
|
|
advancedHeaderComponent: SendModalHeader {
|
2022-06-27 13:41:47 +00:00
|
|
|
model: popup.store.accounts
|
|
|
|
selectedAccount: popup.selectedAccount
|
|
|
|
onUpdatedSelectedAccount: {
|
|
|
|
popup.selectedAccount = account
|
2022-05-19 08:53:57 +00:00
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
TransactionStackView {
|
2022-03-18 14:47:51 +00:00
|
|
|
id: stack
|
|
|
|
property alias currentGroup: stack.currentGroup
|
|
|
|
anchors.leftMargin: Style.current.xlPadding
|
2022-06-27 13:41:47 +00:00
|
|
|
anchors.topMargin: Style.current.xlPadding
|
2022-03-18 14:47:51 +00:00
|
|
|
anchors.rightMargin: Style.current.xlPadding
|
|
|
|
anchors.bottomMargin: popup.showAdvancedFooter && !!advancedFooter ? advancedFooter.height : Style.current.padding
|
2020-08-20 04:45:29 +00:00
|
|
|
TransactionFormGroup {
|
|
|
|
id: group1
|
2022-03-18 14:47:51 +00:00
|
|
|
anchors.fill: parent
|
2022-06-27 13:41:47 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: assetAndAmmountSelector
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
RowLayout {
|
|
|
|
spacing: 16
|
|
|
|
StatusBaseText {
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Send")
|
2022-06-27 13:41:47 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
}
|
|
|
|
StatusListItemTag {
|
|
|
|
title: assetSelector.selectedAsset.totalBalance > 0 ? qsTr("Max: ") + (assetSelector.selectedAsset ? d.maxFiatBalance : "0.00") : qsTr("No balances active")
|
|
|
|
closeButtonVisible: false
|
|
|
|
titleText.font.pixelSize: 12
|
|
|
|
Layout.preferredHeight: 22
|
|
|
|
Layout.preferredWidth: childrenRect.width
|
2022-07-01 11:24:32 +00:00
|
|
|
color: d.errorMode ? Theme.palette.dangerColor2 : Theme.palette.primaryColor3
|
|
|
|
titleText.color: d.errorMode ? Theme.palette.dangerColor1 : Theme.palette.primaryColor1
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: childrenRect.height
|
|
|
|
AmountInputWithCursor {
|
|
|
|
id: amountToSendInput
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
width: parent.width - assetSelector.width
|
|
|
|
input.placeholderText: "0.00" + " " + assetSelector.selectedAsset.symbol
|
|
|
|
errorMessageCmp.anchors.rightMargin: -100
|
2022-07-01 11:24:32 +00:00
|
|
|
input.edit.color: d.errorMode ? Theme.palette.dangerColor1 : Theme.palette.directColor1
|
2022-06-27 13:41:47 +00:00
|
|
|
validators: [
|
|
|
|
StatusFloatValidator{
|
|
|
|
id: floatValidator
|
|
|
|
bottom: 0
|
|
|
|
top: d.maxFiatBalance
|
|
|
|
errorMessage: qsTr("Please enter a valid amount")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
Keys.onReleased: {
|
|
|
|
let amount = amountToSendInput.text.trim()
|
|
|
|
|
|
|
|
if (isNaN(amount)) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (amount === "") {
|
|
|
|
txtFiatBalance.text = "0.00"
|
|
|
|
} else {
|
|
|
|
txtFiatBalance.text = popup.store.getFiatValue(amount, assetSelector.selectedAsset.symbol, popup.store.currentCurrency)
|
|
|
|
}
|
|
|
|
gasSelector.estimateGas()
|
|
|
|
popup.recalculateRoutesAndFees()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusAssetSelector {
|
|
|
|
id: assetSelector
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
2022-07-01 11:24:32 +00:00
|
|
|
assets: popup.selectedAccount.assets
|
2022-06-27 13:41:47 +00:00
|
|
|
defaultToken: Style.png("tokens/DEFAULT-TOKEN@3x")
|
|
|
|
getCurrencyBalanceString: function (currencyBalance) {
|
|
|
|
return Utils.toLocaleString(currencyBalance.toFixed(2), popup.store.locale, {"currency": true}) + " " + popup.store.currentCurrency.toUpperCase()
|
|
|
|
}
|
|
|
|
tokenAssetSourceFn: function (symbol) {
|
|
|
|
return symbol ? Style.png("tokens/" + symbol) : defaultToken
|
|
|
|
}
|
|
|
|
onSelectedAssetChanged: {
|
|
|
|
if (!assetSelector.selectedAsset) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (amountToSendInput.text === "" || isNaN(amountToSendInput.text)) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
txtFiatBalance.text = popup.store.getFiatValue(amountToSendInput.text, assetSelector.selectedAsset.symbol, popup.store.currentCurrency)
|
|
|
|
gasSelector.estimateGas()
|
|
|
|
popup.recalculateRoutesAndFees()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RowLayout {
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
StyledTextField {
|
|
|
|
id: txtFiatBalance
|
|
|
|
color: txtFiatBalance.activeFocus ? Style.current.textColor : Style.current.secondaryText
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 12
|
|
|
|
inputMethodHints: Qt.ImhFormattedNumbersOnly
|
|
|
|
text: "0.00"
|
|
|
|
selectByMouse: true
|
|
|
|
background: Rectangle {
|
|
|
|
color: Style.current.transparent
|
|
|
|
}
|
|
|
|
padding: 0
|
|
|
|
Keys.onReleased: {
|
|
|
|
let balance = txtFiatBalance.text.trim()
|
|
|
|
if (balance === "" || isNaN(balance)) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// To-Do Not refactored yet
|
|
|
|
// amountToSendInput.text = root.getCryptoValue(balance, popup.store.currentCurrency, assetSelector.selectedAsset.symbol)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
id: currencyText
|
|
|
|
text: popup.store.currentCurrency.toUpperCase()
|
|
|
|
font.pixelSize: 13
|
|
|
|
color: Theme.palette.directColor5
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: border
|
|
|
|
anchors.top: assetAndAmmountSelector.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -Style.current.xlPadding
|
|
|
|
|
|
|
|
width: popup.width
|
|
|
|
height: 1
|
|
|
|
color: Theme.palette.directColor8
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
|
|
|
|
DropShadow {
|
|
|
|
anchors.fill: border
|
|
|
|
horizontalOffset: 0
|
|
|
|
verticalOffset: 2
|
|
|
|
radius: 8.0
|
|
|
|
samples: 17
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
source: border
|
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2022-06-27 13:41:47 +00:00
|
|
|
id: scrollView
|
|
|
|
height: stack.height - assetAndAmmountSelector.height
|
2022-03-18 14:47:51 +00:00
|
|
|
width: parent.width
|
2022-06-27 13:41:47 +00:00
|
|
|
anchors.top: border.bottom
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
2022-03-18 14:47:51 +00:00
|
|
|
anchors.left: parent.left
|
2022-07-13 12:29:38 +00:00
|
|
|
contentHeight: recipientSelector.height + addressSelector.height + networkSelector.height +
|
|
|
|
fees.height + Style.current.halfPadding
|
2022-03-18 14:47:51 +00:00
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
// To-do use standard StatusInput component once the flow for ens name resolution is clear
|
|
|
|
RecipientSelector {
|
2022-07-01 11:24:32 +00:00
|
|
|
anchors.top: parent.top
|
2022-06-27 13:41:47 +00:00
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
|
|
|
id: recipientSelector
|
|
|
|
accounts: popup.store.accounts
|
|
|
|
contactsStore: popup.contactsStore
|
|
|
|
label: qsTr("To")
|
|
|
|
Layout.fillWidth: true
|
|
|
|
input.placeholderText: qsTr("Enter an ENS name or address")
|
|
|
|
input.anchors.leftMargin: 0
|
|
|
|
input.anchors.rightMargin: 0
|
|
|
|
labelFont.pixelSize: 15
|
|
|
|
labelFont.weight: Font.Normal
|
|
|
|
input.height: 56
|
|
|
|
isSelectorVisible: false
|
|
|
|
addContactEnabled: false
|
|
|
|
onSelectedRecipientChanged: gasSelector.estimateGas()
|
|
|
|
}
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
TabAddressSelectorView {
|
|
|
|
id: addressSelector
|
2022-06-27 13:41:47 +00:00
|
|
|
anchors.top: recipientSelector.bottom
|
2022-03-18 14:47:51 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
store: popup.store
|
|
|
|
onContactSelected: {
|
2022-06-27 13:41:47 +00:00
|
|
|
recipientSelector.input.text = address
|
2021-04-22 04:03:46 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-05-19 08:53:57 +00:00
|
|
|
NetworkSelector {
|
|
|
|
id: networkSelector
|
2022-07-01 11:24:32 +00:00
|
|
|
store: popup.store
|
|
|
|
selectedAccount: popup.selectedAccount
|
2022-03-18 14:47:51 +00:00
|
|
|
anchors.top: addressSelector.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
2022-07-01 11:24:32 +00:00
|
|
|
amountToSend: isNaN(parseFloat(amountToSendInput.text)) ? 0 : parseFloat(amountToSendInput.text)
|
|
|
|
requiredGasInEth: gasSelector.selectedGasEthValue
|
|
|
|
assets: popup.selectedAccount.assets
|
|
|
|
selectedAsset: assetSelector.selectedAsset
|
2022-05-19 08:53:57 +00:00
|
|
|
onNetworkChanged: function(chainId) {
|
|
|
|
gasSelector.suggestedFees = popup.store.suggestedFees(chainId)
|
2022-06-07 13:57:09 +00:00
|
|
|
gasSelector.updateGasEthValue()
|
2022-05-19 08:53:57 +00:00
|
|
|
}
|
2022-07-01 11:24:32 +00:00
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees(disabledChainIds)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-07-01 11:24:32 +00:00
|
|
|
Rectangle {
|
|
|
|
id: fees
|
|
|
|
radius: 13
|
|
|
|
color: Theme.palette.indirectColor1
|
2022-05-19 08:53:57 +00:00
|
|
|
anchors.top: networkSelector.bottom
|
2022-07-01 11:24:32 +00:00
|
|
|
width: parent.width
|
|
|
|
height: gasSelector.visible || gasValidator.visible ? feesLayout.height + gasValidator.height : 0
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-07-01 11:24:32 +00:00
|
|
|
RowLayout {
|
|
|
|
id: feesLayout
|
|
|
|
spacing: 10
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.margins: Style.current.padding
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-07-01 11:24:32 +00:00
|
|
|
StatusRoundIcon {
|
|
|
|
id: feesIcon
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
radius: 8
|
|
|
|
icon.name: "fees"
|
|
|
|
}
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
GasSelector {
|
|
|
|
id: gasSelector
|
|
|
|
Layout.preferredWidth: fees.width - feesIcon.width - Style.current.xlPadding
|
|
|
|
getGasEthValue: popup.store.getGasEthValue
|
|
|
|
getFiatValue: popup.store.getFiatValue
|
|
|
|
getEstimatedTime: popup.store.getEstimatedTime
|
|
|
|
defaultCurrency: popup.store.currentCurrency
|
|
|
|
chainId: networkSelector.selectedNetwork && networkSelector.selectedNetwork.chainId ? networkSelector.selectedNetwork.chainId : 1
|
|
|
|
property var estimateGas: Backpressure.debounce(gasSelector, 600, function() {
|
|
|
|
if (!(popup.selectedAccount && popup.selectedAccount.address &&
|
|
|
|
recipientSelector.selectedRecipient && recipientSelector.selectedRecipient.address &&
|
|
|
|
assetSelector.selectedAsset && assetSelector.selectedAsset.symbol &&
|
|
|
|
amountToSendInput.text)) {
|
|
|
|
selectedGasLimit = 250000
|
|
|
|
defaultGasLimit = selectedGasLimit
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var chainID = networkSelector.selectedNetwork ? networkSelector.selectedNetwork.chainId: 1
|
|
|
|
|
|
|
|
let gasEstimate = JSON.parse(popup.store.estimateGas(
|
|
|
|
popup.selectedAccount.address,
|
|
|
|
recipientSelector.selectedRecipient.address,
|
|
|
|
assetSelector.selectedAsset.symbol,
|
|
|
|
amountToSendInput.text,
|
|
|
|
chainID || Global.currentChainId,
|
|
|
|
""))
|
|
|
|
|
|
|
|
if (!gasEstimate.success) {
|
2022-07-19 08:34:27 +00:00
|
|
|
console.warn("error estimating gas: %1").arg(gasEstimate.error.message)
|
2022-07-01 11:24:32 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedGasLimit = gasEstimate.result
|
|
|
|
defaultGasLimit = selectedGasLimit
|
|
|
|
})
|
|
|
|
}
|
|
|
|
GasValidator {
|
|
|
|
id: gasValidator
|
|
|
|
anchors.horizontalCenter: undefined
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
selectedAccount: popup.selectedAccount
|
|
|
|
selectedAmount: amountToSendInput.text === "" ? 0.0 :
|
|
|
|
parseFloat(amountToSendInput.text)
|
|
|
|
selectedAsset: assetSelector.selectedAsset
|
|
|
|
selectedGasEthValue: gasSelector.selectedGasEthValue
|
|
|
|
selectedNetwork: networkSelector.selectedNetwork ? networkSelector.selectedNetwork: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 04:45:29 +00:00
|
|
|
}
|
2020-10-19 09:39:07 +00:00
|
|
|
}
|
2020-08-20 04:45:29 +00:00
|
|
|
}
|
|
|
|
TransactionFormGroup {
|
|
|
|
id: group4
|
2022-03-18 14:47:51 +00:00
|
|
|
|
|
|
|
StackView.onActivated: {
|
|
|
|
transactionSigner.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
2020-05-27 20:50:39 +00:00
|
|
|
|
2020-08-20 04:45:29 +00:00
|
|
|
TransactionSigner {
|
|
|
|
id: transactionSigner
|
2022-03-18 14:47:51 +00:00
|
|
|
Layout.topMargin: Style.current.smallPadding
|
2020-08-20 04:45:29 +00:00
|
|
|
width: stack.width
|
2022-03-18 14:47:51 +00:00
|
|
|
signingPhrase: popup.store.signingPhrase
|
2020-08-20 04:45:29 +00:00
|
|
|
}
|
2020-07-01 14:24:07 +00:00
|
|
|
}
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
advancedFooterComponent: SendModalFooter {
|
|
|
|
maxFiatFees: gasSelector.maxFiatFees
|
2022-06-02 17:47:42 +00:00
|
|
|
estimatedTxTimeFlag: gasSelector.estimatedTxTimeFlag
|
2022-06-27 13:41:47 +00:00
|
|
|
currentGroupPending: stack.currentGroup.isPending
|
|
|
|
currentGroupValid: stack.currentGroup.isValid
|
|
|
|
isLastGroup: stack.isLastGroup
|
2022-03-18 14:47:51 +00:00
|
|
|
onNextButtonClicked: {
|
2022-06-27 13:41:47 +00:00
|
|
|
const validity = stack.currentGroup.validate()
|
2022-03-18 14:47:51 +00:00
|
|
|
if (validity.isValid && !validity.isPending) {
|
2022-06-27 13:41:47 +00:00
|
|
|
if (stack.isLastGroup) {
|
2022-03-18 14:47:51 +00:00
|
|
|
return popup.sendTransaction()
|
|
|
|
}
|
2021-07-05 12:34:56 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
if(gasSelector.suggestedFees.eip1559Enabled && stack.currentGroup === group1 && gasSelector.advancedMode){
|
2022-03-18 14:47:51 +00:00
|
|
|
if(gasSelector.showPriceLimitWarning || gasSelector.showTipLimitWarning){
|
|
|
|
Global.openPopup(transactionSettingsConfirmationPopupComponent, {
|
2022-03-23 08:32:25 +00:00
|
|
|
currentBaseFee: gasSelector.suggestedFees.baseFee,
|
2022-03-18 14:47:51 +00:00
|
|
|
currentMinimumTip: gasSelector.perGasTipLimitFloor,
|
|
|
|
currentAverageTip: gasSelector.perGasTipLimitAverage,
|
|
|
|
tipLimit: gasSelector.selectedTipLimit,
|
|
|
|
suggestedTipLimit: gasSelector.perGasTipLimitFloor,
|
|
|
|
priceLimit: gasSelector.selectedOverallLimit,
|
2022-03-23 08:32:25 +00:00
|
|
|
suggestedPriceLimit: gasSelector.suggestedFees.baseFee + gasSelector.perGasTipLimitFloor,
|
2022-03-18 14:47:51 +00:00
|
|
|
showPriceLimitWarning: gasSelector.showPriceLimitWarning,
|
|
|
|
showTipLimitWarning: gasSelector.showTipLimitWarning,
|
|
|
|
onConfirm: function(){
|
2022-06-27 13:41:47 +00:00
|
|
|
stack.next();
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
stack.next()
|
2021-07-05 12:34:56 +00:00
|
|
|
}
|
|
|
|
}
|
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-03-18 14:47:51 +00:00
|
|
|
Connections {
|
|
|
|
target: popup.store.walletSectionTransactionsInst
|
|
|
|
onTransactionSent: {
|
|
|
|
try {
|
|
|
|
let response = JSON.parse(txResult)
|
|
|
|
if (response.uuid !== stack.uuid) return
|
|
|
|
|
|
|
|
stack.currentGroup.isPending = false
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
if (!response.success) {
|
|
|
|
if (Utils.isInvalidPasswordMessage(response.result)){
|
2022-04-04 11:26:30 +00:00
|
|
|
transactionSigner.validationError = qsTr("Wrong password")
|
2022-03-18 14:47:51 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
sendingError.text = response.result
|
|
|
|
return sendingError.open()
|
2022-02-24 19:24:58 +00:00
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-05-05 10:28:54 +00:00
|
|
|
let url = `${popup.store.getEtherscanLink()}/${response.result}`
|
|
|
|
Global.displayToastMessage(qsTr("Transaction pending..."),
|
2022-05-19 08:53:57 +00:00
|
|
|
qsTr("View on etherscan"),
|
2022-05-05 10:28:54 +00:00
|
|
|
"",
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// onTransactionCompleted: {
|
|
|
|
// if (success) {
|
|
|
|
// //% "Transaction completed"
|
2022-04-04 11:26:30 +00:00
|
|
|
// Global.toastMessage.title = qsTr("Wrong password")
|
2022-03-18 14:47:51 +00:00
|
|
|
// Global.toastMessage.source = Style.svg("check-circle")
|
|
|
|
// Global.toastMessage.iconColor = Style.current.success
|
|
|
|
// } else {
|
|
|
|
// //% "Transaction failed"
|
2022-04-04 11:26:30 +00:00
|
|
|
// Global.toastMessage.title = qsTr("Wrong password")
|
2022-03-18 14:47:51 +00:00
|
|
|
// Global.toastMessage.source = Style.svg("block-icon")
|
|
|
|
// Global.toastMessage.iconColor = Style.current.danger
|
|
|
|
// }
|
|
|
|
// Global.toastMessage.link = `${walletModel.utilsView.etherscanLink}/${txHash}`
|
|
|
|
// Global.toastMessage.open()
|
|
|
|
// }
|
2020-05-27 20:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|