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
|
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
|
2020-09-14 12:12:47 +00:00
|
|
|
//% "Error sending the transaction"
|
|
|
|
title: qsTrId("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,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
|
|
|
|
networkSelector.suggestedRoutes = popup.store.suggestedRoutes(
|
2022-06-27 13:41:47 +00:00
|
|
|
popup.selectedAccount.address, amountToSendInput.text, assetSelector.selectedAsset.symbol
|
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
|
|
|
|
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-06-27 13:41:47 +00:00
|
|
|
showAdvancedFooter: d.isReady && 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
|
|
|
assetSelector.assets = Qt.binding(function() {
|
|
|
|
if (popup.selectedAccount) {
|
|
|
|
return popup.selectedAccount.assets
|
2022-03-18 14:47:51 +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 {
|
|
|
|
//% "Send"
|
|
|
|
text: qsTrId("command-button-send")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
}
|
|
|
|
StatusListItemTag {
|
|
|
|
//% "No balances active"
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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-03-18 14:47:51 +00:00
|
|
|
ScrollView {
|
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
|
|
|
|
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
2022-06-27 13:41:47 +00:00
|
|
|
contentHeight: recipientSelector.height + addressSelector.height + networkSelector.height + gasSelector.height + gasValidator.height
|
2022-03-18 14:47:51 +00:00
|
|
|
clip: true
|
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
// To-do use standard StatusInput component once the flow for ens name resolution is clear
|
|
|
|
RecipientSelector {
|
|
|
|
anchors.top: assetAndAmmountSelector.bottom
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
|
|
|
id: recipientSelector
|
|
|
|
accounts: popup.store.accounts
|
|
|
|
contactsStore: popup.contactsStore
|
|
|
|
//% To
|
|
|
|
label: qsTr("To")
|
|
|
|
Layout.fillWidth: true
|
|
|
|
//% "Enter an ENS name or address"
|
|
|
|
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-03-18 14:47:51 +00:00
|
|
|
anchors.top: addressSelector.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
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-03-18 14:47:51 +00:00
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
GasSelector {
|
|
|
|
id: gasSelector
|
2022-05-19 08:53:57 +00:00
|
|
|
anchors.top: networkSelector.bottom
|
2022-03-18 14:47:51 +00:00
|
|
|
getGasEthValue: popup.store.getGasEthValue
|
|
|
|
getFiatValue: popup.store.getFiatValue
|
2022-06-02 17:47:42 +00:00
|
|
|
getEstimatedTime: popup.store.getEstimatedTime
|
2022-03-18 14:47:51 +00:00
|
|
|
defaultCurrency: popup.store.currentCurrency
|
2022-06-07 13:57:09 +00:00
|
|
|
chainId: networkSelector.selectedNetwork.chainId
|
2022-03-18 14:47:51 +00:00
|
|
|
width: stack.width
|
|
|
|
property var estimateGas: Backpressure.debounce(gasSelector, 600, function() {
|
2022-06-27 13:41:47 +00:00
|
|
|
if (!(popup.selectedAccount && popup.selectedAccount.address &&
|
|
|
|
recipientSelector.selectedRecipient && recipientSelector.selectedRecipient.address &&
|
|
|
|
assetSelector.selectedAsset && assetSelector.selectedAsset.symbol &&
|
|
|
|
amountToSendInput.text)) {
|
2022-03-18 14:47:51 +00:00
|
|
|
selectedGasLimit = 250000
|
|
|
|
defaultGasLimit = selectedGasLimit
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
let gasEstimate = JSON.parse(popup.store.estimateGas(
|
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
|
|
|
networkSelector.selectedNetwork.chainId || Global.currentChainId,
|
|
|
|
""))
|
2022-03-18 14:47:51 +00:00
|
|
|
|
|
|
|
if (!gasEstimate.success) {
|
2022-05-19 08:53:57 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
//% "Error estimating gas: %1"
|
|
|
|
console.warn(qsTrId("error-estimating-gas---1").arg(gasEstimate.error.message))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedGasLimit = gasEstimate.result
|
|
|
|
defaultGasLimit = selectedGasLimit
|
|
|
|
})
|
|
|
|
}
|
2022-05-19 08:53:57 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
GasValidator {
|
|
|
|
id: gasValidator
|
|
|
|
anchors.top: gasSelector.bottom
|
2022-06-27 13:41:47 +00:00
|
|
|
selectedAccount: popup.selectedAccount
|
|
|
|
selectedAmount: amountToSendInput.text === "" ? 0.0
|
|
|
|
: parseFloat(amountToSendInput.text)
|
|
|
|
selectedAsset: assetSelector.selectedAsset
|
2022-03-18 14:47:51 +00:00
|
|
|
selectedGasEthValue: gasSelector.selectedGasEthValue
|
2022-05-19 08:53:57 +00:00
|
|
|
selectedNetwork: networkSelector.selectedNetwork
|
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)){
|
|
|
|
//% "Wrong password"
|
|
|
|
transactionSigner.validationError = qsTrId("wrong-password")
|
|
|
|
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"
|
|
|
|
// Global.toastMessage.title = qsTrId("transaction-completed")
|
|
|
|
// Global.toastMessage.source = Style.svg("check-circle")
|
|
|
|
// Global.toastMessage.iconColor = Style.current.success
|
|
|
|
// } else {
|
|
|
|
// //% "Transaction failed"
|
|
|
|
// Global.toastMessage.title = qsTrId("ens-registration-failed-title")
|
|
|
|
// 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|