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-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-08-25 19:20:21 +00:00
|
|
|
let recipientAddress = Utils.isValidAddress(popup.addressText) ? popup.addressText : d.resolvedENSAddress
|
2022-08-29 16:28:54 +00:00
|
|
|
d.isPending = 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,
|
|
|
|
amountToSendInput.text,
|
|
|
|
gasSelector.selectedGasLimit,
|
|
|
|
gasSelector.suggestedFees.eip1559Enabled ? "" : gasSelector.selectedGasPrice,
|
|
|
|
gasSelector.selectedTipLimit,
|
|
|
|
gasSelector.selectedOverallLimit,
|
|
|
|
networkSelector.selectedNetwork.chainId,
|
|
|
|
d.uuid,
|
|
|
|
gasSelector.suggestedFees.eip1559Enabled,
|
|
|
|
)
|
2022-05-19 08:53:57 +00:00
|
|
|
}
|
|
|
|
|
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-08-29 16:28:54 +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-08-29 16:28:54 +00:00
|
|
|
enum StackGroup {
|
2022-09-28 08:43:37 +00:00
|
|
|
SendDetailsGroup = 0
|
2022-08-29 16:28:54 +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))
|
2022-07-27 21:10:00 +00:00
|
|
|
readonly property bool isReady: amountToSendInput.valid && !amountToSendInput.pending && recipientReady
|
2022-07-01 11:24:32 +00:00
|
|
|
readonly property bool errorMode: networkSelector.suggestedRoutes && networkSelector.suggestedRoutes.length <= 0 || networkSelector.errorMode
|
2022-08-25 19:20:21 +00:00
|
|
|
readonly property bool recipientReady: (isAddressValid || isENSValid) && !recipientSelector.isPending
|
|
|
|
readonly property bool isAddressValid: Utils.isValidAddress(recipientSelector.input.text)
|
|
|
|
property bool isENSValid: false
|
|
|
|
readonly property var resolveENS: Backpressure.debounce(popup, 500, function (ensName) {
|
|
|
|
store.resolveENS(ensName)
|
|
|
|
})
|
|
|
|
property string resolvedENSAddress
|
2022-06-27 13:41:47 +00:00
|
|
|
onIsReadyChanged: {
|
2022-08-29 16:28:54 +00:00
|
|
|
if(!isReady && isLastGroup)
|
|
|
|
stack.currentIndex = SendModal.StackGroup.SendDetailsGroup
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
readonly property string uuid: Utils.uuid()
|
|
|
|
readonly property bool isLastGroup: stack.currentIndex === (stack.count - 1)
|
|
|
|
property bool isPending: false
|
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-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) {
|
2022-08-25 19:20:21 +00:00
|
|
|
recipientSelector.input.edit.readOnly = true
|
|
|
|
recipientSelector.input.text = popup.preSelectedRecipient.name
|
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-07-27 21:10:00 +00:00
|
|
|
header: SendModalHeader {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: -height - 18
|
2022-06-27 13:41:47 +00:00
|
|
|
model: popup.store.accounts
|
|
|
|
selectedAccount: popup.selectedAccount
|
2022-08-01 17:04:23 +00:00
|
|
|
changeSelectedAccount: function(newIndex) {
|
|
|
|
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
|
|
|
|
spacing: Style.current.padding
|
2022-06-27 13:41:47 +00:00
|
|
|
|
2022-08-29 16:28:54 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
Layout.preferredHeight: assetAndAmmountSelector.height + Style.current.padding
|
|
|
|
color: Theme.palette.baseColor3
|
|
|
|
|
|
|
|
layer.enabled: scrollView.contentY > -8
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
verticalOffset: 2
|
|
|
|
radius: 16
|
|
|
|
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
|
|
|
|
|
|
|
|
Row {
|
|
|
|
spacing: 16
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
text: qsTr("Send")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
StatusListItemTag {
|
|
|
|
height: 22
|
|
|
|
width: childrenRect.width
|
|
|
|
title: assetSelector.selectedAsset.totalBalance > 0 ? qsTr("Max: %1").arg(assetSelector.selectedAsset ? d.maxFiatBalance : "0.00") : qsTr("No balances active")
|
|
|
|
closeButtonVisible: false
|
|
|
|
titleText.font.pixelSize: 12
|
|
|
|
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
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
}
|
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: amountToSendInput.height
|
|
|
|
AmountInputWithCursor {
|
|
|
|
id: amountToSendInput
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
width: parent.width - assetSelector.width
|
|
|
|
placeholderText: "0.00 %1".arg(assetSelector.selectedAsset.symbol)
|
|
|
|
input.edit.color: d.errorMode ? Theme.palette.dangerColor1 : Theme.palette.directColor1
|
|
|
|
validators: [
|
|
|
|
StatusFloatValidator{
|
|
|
|
id: floatValidator
|
|
|
|
bottom: 0
|
|
|
|
top: d.maxFiatBalance
|
|
|
|
errorMessage: ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
Keys.onReleased: {
|
|
|
|
let amount = amountToSendInput.text.trim()
|
|
|
|
|
|
|
|
if (!Utils.containsOnlyDigits(amount) || 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()
|
2022-08-18 20:49:50 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
StatusAssetSelector {
|
|
|
|
id: assetSelector
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
assets: popup.selectedAccount.assets
|
|
|
|
defaultToken: Style.png("tokens/DEFAULT-TOKEN@3x")
|
|
|
|
getCurrencyBalanceString: function (currencyBalance) {
|
|
|
|
return "%1 %2".arg(Utils.toLocaleString(currencyBalance.toFixed(2), popup.store.locale, {"currency": true})).arg(popup.store.currentCurrency.toUpperCase())
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
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 ""
|
|
|
|
}
|
|
|
|
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()
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
StatusInput {
|
2022-06-27 13:41:47 +00:00
|
|
|
id: txtFiatBalance
|
2022-08-29 16:28:54 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -12
|
|
|
|
leftPadding: 0
|
|
|
|
rightPadding: 0
|
2022-06-27 13:41:47 +00:00
|
|
|
font.weight: Font.Medium
|
2022-08-29 16:28:54 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
input.placeholderFont.pixelSize: 13
|
|
|
|
input.leftPadding: 0
|
|
|
|
input.rightPadding: 0
|
|
|
|
input.topPadding: 0
|
|
|
|
input.bottomPadding: 0
|
|
|
|
input.edit.padding: 0
|
|
|
|
input.background.color: "transparent"
|
|
|
|
input.background.border.width: 0
|
|
|
|
input.edit.color: txtFiatBalance.input.edit.activeFocus ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
2022-06-27 13:41:47 +00:00
|
|
|
text: "0.00"
|
2022-08-29 16:28:54 +00:00
|
|
|
placeholderText: "0.00"
|
|
|
|
input.implicitHeight: 15
|
|
|
|
implicitWidth: txtFiatBalance.input.edit.contentWidth + 50
|
|
|
|
input.rightComponent: StatusBaseText {
|
|
|
|
id: currencyText
|
|
|
|
text: popup.store.currentCurrency.toUpperCase()
|
|
|
|
font.pixelSize: 13
|
|
|
|
color: Theme.palette.directColor5
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2022-06-27 13:41:47 +00:00
|
|
|
id: scrollView
|
2022-08-29 16:28:54 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
contentHeight: layout.height
|
|
|
|
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
|
|
|
|
spacing: Style.current.halfPadding
|
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-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
|
|
|
|
input.clearable: true
|
|
|
|
multiline: false
|
|
|
|
input.rightComponent: RowLayout {
|
|
|
|
StatusButton {
|
|
|
|
visible: recipientSelector.text === ""
|
2022-09-13 07:37:09 +00:00
|
|
|
borderColor: Theme.palette.primaryColor1
|
2022-08-25 19:20:21 +00:00
|
|
|
size: StatusBaseButton.Size.Tiny
|
|
|
|
text: qsTr("Paste")
|
|
|
|
onClicked: recipientSelector.input.edit.paste()
|
|
|
|
}
|
|
|
|
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"
|
|
|
|
onClicked: recipientSelector.input.edit.clear()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Keys.onReleased: {
|
|
|
|
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-07-27 21:10:00 +00:00
|
|
|
visible: !d.recipientReady
|
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
|
|
|
|
selectedAccount: popup.selectedAccount
|
|
|
|
amountToSend: isNaN(parseFloat(amountToSendInput.text)) ? 0 : parseFloat(amountToSendInput.text)
|
|
|
|
requiredGasInEth: gasSelector.selectedGasEthValue
|
|
|
|
assets: popup.selectedAccount.assets
|
|
|
|
selectedAsset: assetSelector.selectedAsset
|
|
|
|
onNetworkChanged: function(chainId) {
|
|
|
|
gasSelector.suggestedFees = popup.store.suggestedFees(chainId)
|
|
|
|
gasSelector.updateGasEthValue()
|
2022-07-01 11:24:32 +00:00
|
|
|
}
|
2022-07-20 11:15:05 +00:00
|
|
|
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees(disabledChainIds)
|
2022-07-27 21:10:00 +00:00
|
|
|
visible: d.recipientReady
|
2022-07-20 11:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: fees
|
|
|
|
radius: 13
|
|
|
|
color: Theme.palette.indirectColor1
|
2022-08-29 16:28:54 +00:00
|
|
|
height: text.height + gasSelector.height + gasValidator.height + Style.current.xlPadding
|
|
|
|
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
|
|
|
visible: d.recipientReady
|
2022-07-20 11:15:05 +00:00
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: feesLayout
|
|
|
|
spacing: 10
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.margins: Style.current.padding
|
|
|
|
|
|
|
|
StatusRoundIcon {
|
|
|
|
id: feesIcon
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
radius: 8
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.name: "fees"
|
2022-07-01 11:24:32 +00:00
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
Column {
|
2022-07-26 18:14:55 +00:00
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
|
|
|
Layout.preferredWidth: fees.width - feesIcon.width - Style.current.xlPadding
|
2022-07-27 21:10:00 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: text
|
2022-08-29 16:28:54 +00:00
|
|
|
width: 410
|
2022-07-27 21:10:00 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
font.weight: Font.Medium
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
text: qsTr("Fees")
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
}
|
2022-07-20 11:15:05 +00:00
|
|
|
GasSelector {
|
|
|
|
id: gasSelector
|
2022-08-29 16:28:54 +00:00
|
|
|
width: parent.width
|
2022-07-20 11:15:05 +00:00
|
|
|
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 &&
|
2022-08-25 19:20:21 +00:00
|
|
|
popup.addressText && assetSelector.selectedAsset &&
|
|
|
|
assetSelector.selectedAsset.symbol && amountToSendInput.text)) {
|
2022-07-20 11:15:05 +00:00
|
|
|
selectedGasLimit = 250000
|
|
|
|
defaultGasLimit = selectedGasLimit
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var chainID = networkSelector.selectedNetwork ? networkSelector.selectedNetwork.chainId: 1
|
|
|
|
|
2022-08-25 19:20:21 +00:00
|
|
|
var recipientAddress = popup.launchedFromChat ? popup.preSelectedRecipient.address : popup.addressText
|
|
|
|
|
2022-07-20 11:15:05 +00:00
|
|
|
let gasEstimate = JSON.parse(popup.store.estimateGas(
|
2022-08-29 16:28:54 +00:00
|
|
|
popup.selectedAccount.address,
|
|
|
|
recipientAddress,
|
|
|
|
assetSelector.selectedAsset.symbol,
|
|
|
|
amountToSendInput.text,
|
|
|
|
chainID,
|
|
|
|
""))
|
2022-07-20 11:15:05 +00:00
|
|
|
|
|
|
|
if (!gasEstimate.success) {
|
2022-07-26 18:14:55 +00:00
|
|
|
console.warn("error estimating gas: ", gasEstimate.error.message)
|
2022-07-20 11:15:05 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedGasLimit = gasEstimate.result
|
|
|
|
defaultGasLimit = selectedGasLimit
|
|
|
|
})
|
|
|
|
}
|
|
|
|
GasValidator {
|
|
|
|
id: gasValidator
|
2022-08-29 16:28:54 +00:00
|
|
|
width: parent.width
|
2022-07-20 11:15:05 +00:00
|
|
|
selectedAccount: popup.selectedAccount
|
|
|
|
selectedAmount: amountToSendInput.text === "" ? 0.0 :
|
2022-08-29 16:28:54 +00:00
|
|
|
parseFloat(amountToSendInput.text)
|
2022-07-20 11:15:05 +00:00
|
|
|
selectedAsset: assetSelector.selectedAsset
|
|
|
|
selectedGasEthValue: gasSelector.selectedGasEthValue
|
|
|
|
selectedNetwork: networkSelector.selectedNetwork ? networkSelector.selectedNetwork: null
|
|
|
|
}
|
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-03-18 14:47:51 +00:00
|
|
|
maxFiatFees: gasSelector.maxFiatFees
|
2022-06-02 17:47:42 +00:00
|
|
|
estimatedTxTimeFlag: gasSelector.estimatedTxTimeFlag
|
2022-08-29 16:28:54 +00:00
|
|
|
pending: d.isPending
|
|
|
|
isLastGroup: d.isLastGroup
|
2022-07-27 21:10:00 +00:00
|
|
|
visible: d.isReady && !isNaN(parseFloat(amountToSendInput.text)) && gasValidator.isValid
|
2022-03-18 14:47:51 +00:00
|
|
|
onNextButtonClicked: {
|
2022-08-29 16:28:54 +00:00
|
|
|
if(gasSelector.suggestedFees.eip1559Enabled && gasSelector.advancedMode){
|
|
|
|
if(gasSelector.showPriceLimitWarning || gasSelector.showTipLimitWarning){
|
|
|
|
Global.openPopup(transactionSettingsConfirmationPopupComponent, {
|
|
|
|
currentBaseFee: gasSelector.suggestedFees.baseFee,
|
|
|
|
currentMinimumTip: gasSelector.perGasTipLimitFloor,
|
|
|
|
currentAverageTip: gasSelector.perGasTipLimitAverage,
|
|
|
|
tipLimit: gasSelector.selectedTipLimit,
|
|
|
|
suggestedTipLimit: gasSelector.perGasTipLimitFloor,
|
|
|
|
priceLimit: gasSelector.selectedOverallLimit,
|
|
|
|
suggestedPriceLimit: gasSelector.suggestedFees.baseFee + gasSelector.perGasTipLimitFloor,
|
|
|
|
showPriceLimitWarning: gasSelector.showPriceLimitWarning,
|
|
|
|
showTipLimitWarning: gasSelector.showTipLimitWarning,
|
|
|
|
onConfirm: function(){
|
2022-09-28 08:43:37 +00:00
|
|
|
if (isLastGroup) {
|
|
|
|
return popup.sendTransaction()
|
|
|
|
}
|
2022-08-29 16:28:54 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2021-07-05 12:34:56 +00:00
|
|
|
}
|
2022-09-28 08:43:37 +00:00
|
|
|
|
|
|
|
if (isLastGroup) {
|
|
|
|
return popup.sendTransaction()
|
|
|
|
}
|
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: {
|
2022-08-29 16:28:54 +00:00
|
|
|
d.isPending = 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) {
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|