refactor: replace transaction modal `reset` functionality

The transaction component's `reset` functionality was meant ot reset a form when the modal was closed. It was difficult to manage and added extra overhead for each additional transaction modal created.

Instead of using reset functions, we can use Loaders to load and destroy the modal's as they are opened and closed. We do not need to keep them in memory and then also reset their functions. It creates a smaller memory footprint to destroy the object and reload on open.

feat: load gas prediction prices asynchronously
This commit is contained in:
emizzle 2020-11-03 21:29:56 +11:00 committed by Iuri Matias
parent d2ec9854ad
commit e0e1487643
31 changed files with 155 additions and 498 deletions

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strformat, strutils, chronicles, json, std/wrapnils, parseUtils, stint, tables import NimQml, Tables, strformat, strutils, chronicles, json, std/wrapnils, parseUtils, stint, tables, json_serialization
import ../../status/[status, wallet, threads] import ../../status/[status, wallet, threads]
import ../../status/wallet/collectibles as status_collectibles import ../../status/wallet/collectibles as status_collectibles
import ../../status/libstatus/accounts/constants import ../../status/libstatus/accounts/constants
@ -457,11 +457,16 @@ QtObject:
proc gasPricePredictionsChanged*(self: WalletView) {.signal.} proc gasPricePredictionsChanged*(self: WalletView) {.signal.}
proc getGasPricePredictions*(self: WalletView) {.slot.} = proc getGasPricePredictions*(self: WalletView) {.slot.} =
let prediction = self.status.wallet.getGasPricePredictions() let walletModel = self.status.wallet
self.safeLowGasPrice = $prediction.safeLow spawnAndSend(self, "getGasPricePredictionsResult") do:
self.standardGasPrice = $prediction.standard $ %walletModel.getGasPricePredictions()
self.fastGasPrice = $prediction.fast
self.fastestGasPrice = $prediction.fastest proc getGasPricePredictionsResult(self: WalletView, gasPricePredictionsJson: string) {.slot.} =
let prediction = Json.decode(gasPricePredictionsJson, GasPricePrediction)
self.safeLowGasPrice = fmt"{prediction.safeLow:.3f}"
self.standardGasPrice = fmt"{prediction.standard:.3f}"
self.fastGasPrice = fmt"{prediction.fast:.3f}"
self.fastestGasPrice = fmt"{prediction.fastest:.3f}"
self.gasPricePredictionsChanged() self.gasPricePredictionsChanged()
proc safeLowGasPrice*(self: WalletView): string {.slot.} = result = ?.self.safeLowGasPrice proc safeLowGasPrice*(self: WalletView): string {.slot.} = result = ?.self.safeLowGasPrice

View File

@ -118,10 +118,6 @@ Popup {
accounts: walletModel.accounts accounts: walletModel.accounts
selectedAccount: walletModel.currentAccount selectedAccount: walletModel.currentAccount
currency: walletModel.defaultCurrency currency: walletModel.defaultCurrency
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
selectedAccount = Qt.binding(function() { return walletModel.currentAccount })
}
onSelectedAccountChanged: { onSelectedAccountChanged: {
if (!root.currentAddress) { if (!root.currentAddress) {
// We just set the account for the first time. Nothing to do here // We just set the account for the first time. Nothing to do here

View File

@ -105,10 +105,6 @@ Popup {
accounts: walletModel.accounts accounts: walletModel.accounts
selectedAccount: walletModel.currentAccount selectedAccount: walletModel.currentAccount
currency: walletModel.defaultCurrency currency: walletModel.defaultCurrency
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
selectedAccount = Qt.binding(function() { return walletModel.currentAccount })
}
onSelectedAccountChanged: { onSelectedAccountChanged: {
if (!accountSelectorRow.currentAddress) { if (!accountSelectorRow.currentAddress) {
// We just set the account for the first time. Nothing to do here // We just set the account for the first time. Nothing to do here

View File

@ -80,9 +80,6 @@ ModalPopup {
anchors.top: messageToSign.bottom anchors.top: messageToSign.bottom
anchors.topMargin: Style.current.padding * 3 anchors.topMargin: Style.current.padding * 3
signingPhrase: walletModel.signingPhrase signingPhrase: walletModel.signingPhrase
reset: function() {
signingPhrase = Qt.binding(function() { return walletModel.signingPhrase })
}
} }
} }

View File

@ -55,7 +55,7 @@ StackLayout {
address, address,
amount, amount,
tokenAddress) tokenAddress)
chatCommandModal.close() txModalLoader.close()
} }
function requestTransaction(address, amount, tokenAddress, tokenDecimals = 18) { function requestTransaction(address, amount, tokenAddress, tokenDecimals = 18) {
amount = utilsModel.eth2Wei(amount.toString(), tokenDecimals) amount = utilsModel.eth2Wei(amount.toString(), tokenDecimals)
@ -63,7 +63,7 @@ StackLayout {
address, address,
amount, amount,
tokenAddress) tokenAddress)
chatCommandModal.close() txModalLoader.close()
} }
@ -226,7 +226,6 @@ StackLayout {
stickerPackList: chatsModel.stickerPacks stickerPackList: chatsModel.stickerPacks
chatType: chatsModel.activeChannel.chatType chatType: chatsModel.activeChannel.chatType
onSendTransactionCommandButtonClicked: { onSendTransactionCommandButtonClicked: {
txModalLoader.sourceComponent = undefined
if (chatsModel.activeChannel.ensVerified) { if (chatsModel.activeChannel.ensVerified) {
txModalLoader.sourceComponent = cmpSendTransactionWithEns txModalLoader.sourceComponent = cmpSendTransactionWithEns
} else { } else {
@ -235,7 +234,6 @@ StackLayout {
txModalLoader.item.open() txModalLoader.item.open()
} }
onReceiveTransactionCommandButtonClicked: { onReceiveTransactionCommandButtonClicked: {
txModalLoader.sourceComponent = undefined
txModalLoader.sourceComponent = cmpReceiveTransaction txModalLoader.sourceComponent = cmpReceiveTransaction
txModalLoader.item.open() txModalLoader.item.open()
} }
@ -250,11 +248,24 @@ StackLayout {
Loader { Loader {
id: txModalLoader id: txModalLoader
function close() {
if (!this.item) {
return
}
this.item.close()
this.closed()
}
function closed() {
this.sourceComponent = undefined
}
} }
Component { Component {
id: cmpSendTransactionNoEns id: cmpSendTransactionNoEns
ChatCommandModal { ChatCommandModal {
id: sendTransactionNoEns id: sendTransactionNoEns
onClosed: {
txModalLoader.closed()
}
sendChatCommand: chatColumnLayout.requestAddressForTransaction sendChatCommand: chatColumnLayout.requestAddressForTransaction
isRequested: false isRequested: false
//% "Send" //% "Send"
@ -273,25 +284,15 @@ StackLayout {
} }
selectRecipient.selectedType: RecipientSelector.Type.Contact selectRecipient.selectedType: RecipientSelector.Type.Contact
selectRecipient.readOnly: true selectRecipient.readOnly: true
onReset: {
selectRecipient.selectedRecipient = Qt.binding(function() {
return {
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
alias: chatsModel.activeChannel.alias,
identicon: chatsModel.activeChannel.identicon,
name: chatsModel.activeChannel.name,
type: RecipientSelector.Type.Contact
}
})
selectRecipient.selectedType = RecipientSelector.Type.Contact
selectRecipient.readOnly = true
}
} }
} }
Component { Component {
id: cmpReceiveTransaction id: cmpReceiveTransaction
ChatCommandModal { ChatCommandModal {
id: receiveTransaction id: receiveTransaction
onClosed: {
txModalLoader.closed()
}
sendChatCommand: chatColumnLayout.requestTransaction sendChatCommand: chatColumnLayout.requestTransaction
isRequested: true isRequested: true
//% "Request" //% "Request"
@ -310,19 +311,6 @@ StackLayout {
} }
selectRecipient.selectedType: RecipientSelector.Type.Contact selectRecipient.selectedType: RecipientSelector.Type.Contact
selectRecipient.readOnly: true selectRecipient.readOnly: true
onReset: {
selectRecipient.selectedRecipient = Qt.binding(function() {
return {
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
alias: chatsModel.activeChannel.alias,
identicon: chatsModel.activeChannel.identicon,
name: chatsModel.activeChannel.name,
type: RecipientSelector.Type.Contact
}
})
selectRecipient.selectedType = RecipientSelector.Type.Contact
selectRecipient.readOnly = true
}
} }
} }
Component { Component {
@ -332,6 +320,9 @@ StackLayout {
onOpened: { onOpened: {
walletModel.getGasPricePredictions() walletModel.getGasPricePredictions()
} }
onClosed: {
txModalLoader.closed()
}
selectRecipient.readOnly: true selectRecipient.readOnly: true
selectRecipient.selectedRecipient: { selectRecipient.selectedRecipient: {
return { return {
@ -344,20 +335,6 @@ StackLayout {
} }
} }
selectRecipient.selectedType: RecipientSelector.Type.Contact selectRecipient.selectedType: RecipientSelector.Type.Contact
onReset: {
selectRecipient.readOnly = true
selectRecipient.selectedRecipient = Qt.binding(function() {
return {
address: "",
alias: chatsModel.activeChannel.alias,
identicon: chatsModel.activeChannel.identicon,
name: chatsModel.activeChannel.name,
type: RecipientSelector.Type.Contact,
ensVerified: true
}
})
selectRecipient.selectedType = RecipientSelector.Type.Contact
}
} }
} }
} }

View File

@ -11,7 +11,6 @@ ModalPopup {
property string finalButtonLabel: "Request address" property string finalButtonLabel: "Request address"
property var sendChatCommand: function () {} property var sendChatCommand: function () {}
property bool isRequested: false property bool isRequested: false
signal reset
id: root id: root
title: root.commandTitle title: root.commandTitle
@ -19,11 +18,6 @@ ModalPopup {
property alias selectRecipient: selectRecipient property alias selectRecipient: selectRecipient
onClosed: {
stack.reset()
root.reset()
}
TransactionStackView { TransactionStackView {
id: stack id: stack
anchors.fill: parent anchors.fill: parent
@ -51,10 +45,6 @@ ModalPopup {
//% "From account" //% "From account"
qsTrId("from-account") qsTrId("from-account")
} }
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
selectedAccount = Qt.binding(function() { return walletModel.currentAccount })
}
} }
SeparatorWithIcon { SeparatorWithIcon {
id: separator id: separator
@ -86,9 +76,6 @@ ModalPopup {
onSelectedRecipientChanged: { onSelectedRecipientChanged: {
addressRequiredValidator.address = root.isRequested ? selectFromAccount.selectedAccount.address : selectRecipient.selectedRecipient.address addressRequiredValidator.address = root.isRequested ? selectFromAccount.selectedAccount.address : selectRecipient.selectedRecipient.address
} }
reset: function() {
isValid = true
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -105,9 +92,6 @@ ModalPopup {
getCryptoValue: walletModel.getCryptoValue getCryptoValue: walletModel.getCryptoValue
validateBalance: !root.isRequested validateBalance: !root.isRequested
width: stack.width width: stack.width
reset: function() {
selectedAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -127,20 +111,6 @@ ModalPopup {
amount: { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount } amount: { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount }
toWarn: addressRequiredValidator.isWarn toWarn: addressRequiredValidator.isWarn
currency: walletModel.defaultCurrency currency: walletModel.defaultCurrency
reset: function() {
fromAccount = Qt.binding(function() {
return root.isRequested ?
selectRecipient.selectedRecipient :
selectFromAccount.selectedAccount
})
toAccount = Qt.binding(function() {
return root.isRequested ?
selectFromAccount.selectedAccount :
selectRecipient.selectedRecipient
})
asset = Qt.binding(function() { return txtAmount.selectedAsset })
amount = Qt.binding(function() { return { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount } })
}
} }
AddressRequiredValidator { AddressRequiredValidator {

View File

@ -50,7 +50,6 @@ ModalPopup {
} }
onClosed: { onClosed: {
stack.reset()
stack.pop(groupPreview, StackView.Immediate) stack.pop(groupPreview, StackView.Immediate)
} }
@ -91,11 +90,6 @@ ModalPopup {
label: qsTrId("choose-account") label: qsTrId("choose-account")
showBalanceForAssetSymbol: root.selectedAsset.symbol showBalanceForAssetSymbol: root.selectedAsset.symbol
minRequiredAssetBalance: parseFloat(root.selectedAmount) minRequiredAssetBalance: parseFloat(root.selectedAmount)
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
showBalanceForAssetSymbol = Qt.binding(function() { return root.selectedAsset.symbol })
minRequiredAssetBalance = Qt.binding(function() { return parseFloat(root.selectedAmount) })
}
onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() } onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() }
} }
RecipientSelector { RecipientSelector {
@ -105,11 +99,6 @@ ModalPopup {
contacts: profileModel.addedContacts contacts: profileModel.addedContacts
selectedRecipient: root.selectedRecipient selectedRecipient: root.selectedRecipient
readOnly: true readOnly: true
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
contacts = Qt.binding(function() { return profileModel.addedContacts })
selectedRecipient = Qt.binding(function() { return root.selectedRecipient })
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -130,10 +119,6 @@ ModalPopup {
getFiatValue: walletModel.getFiatValue getFiatValue: walletModel.getFiatValue
defaultCurrency: walletModel.defaultCurrency defaultCurrency: walletModel.defaultCurrency
width: stack.width width: stack.width
reset: function() {
slowestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.safeLowGasPrice) })
fastestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.fastestGasPrice) })
}
property var estimateGas: Backpressure.debounce(gasSelector, 600, function() { property var estimateGas: Backpressure.debounce(gasSelector, 600, function() {
if (!(selectFromAccount.selectedAccount && selectFromAccount.selectedAccount.address && if (!(selectFromAccount.selectedAccount && selectFromAccount.selectedAccount.address &&
@ -167,12 +152,6 @@ ModalPopup {
selectedAmount: parseFloat(root.selectedAmount) selectedAmount: parseFloat(root.selectedAmount)
selectedAsset: root.selectedAsset selectedAsset: root.selectedAsset
selectedGasEthValue: gasSelector.selectedGasEthValue selectedGasEthValue: gasSelector.selectedGasEthValue
reset: function() {
selectedAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
selectedAmount = Qt.binding(function() { return parseFloat(root.selectedAmount) })
selectedAsset = Qt.binding(function() { return root.selectedAsset })
selectedGasEthValue = Qt.binding(function() { return gasSelector.selectedGasEthValue })
}
} }
} }
@ -205,21 +184,6 @@ ModalPopup {
isGasEditable: true isGasEditable: true
fromValid: balanceValidator.isValid fromValid: balanceValidator.isValid
gasValid: gasValidator.isValid gasValid: gasValidator.isValid
reset: function() {
fromAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
gas = Qt.binding(function() {
return {
"value": gasSelector.selectedGasEthValue,
"symbol": "ETH",
"fiatValue": gasSelector.selectedGasFiatValue
}
})
toAccount = Qt.binding(function() { return selectRecipient.selectedRecipient })
asset = Qt.binding(function() { return root.selectedAsset })
amount = Qt.binding(function() { return { "value": root.selectedAmount, "fiatValue": root.selectedFiatAmount } })
fromValid = Qt.binding(function() { return balanceValidator.isValid })
gasValid = Qt.binding(function() { return gasValidator.isValid })
}
onFromClicked: { stack.push(groupSelectAcct, StackView.Immediate) } onFromClicked: { stack.push(groupSelectAcct, StackView.Immediate) }
onGasClicked: { stack.push(groupSelectGas, StackView.Immediate) } onGasClicked: { stack.push(groupSelectGas, StackView.Immediate) }
} }
@ -230,11 +194,6 @@ ModalPopup {
account: selectFromAccount.selectedAccount account: selectFromAccount.selectedAccount
amount: !!root.selectedAmount ? parseFloat(root.selectedAmount) : 0.0 amount: !!root.selectedAmount ? parseFloat(root.selectedAmount) : 0.0
asset: root.selectedAsset asset: root.selectedAsset
reset: function() {
account = Qt.binding(function() { return selectFromAccount.selectedAccount })
amount = Qt.binding(function() { return !!root.selectedAmount ? parseFloat(root.selectedAmount) : 0.0 })
asset = Qt.binding(function() { return root.selectedAsset })
}
} }
GasValidator { GasValidator {
id: gasValidator2 id: gasValidator2
@ -245,12 +204,6 @@ ModalPopup {
selectedAmount: parseFloat(root.selectedAmount) selectedAmount: parseFloat(root.selectedAmount)
selectedAsset: root.selectedAsset selectedAsset: root.selectedAsset
selectedGasEthValue: gasSelector.selectedGasEthValue selectedGasEthValue: gasSelector.selectedGasEthValue
reset: function() {
selectedAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
selectedAmount = Qt.binding(function() { return parseFloat(root.selectedAmount) })
selectedAsset = Qt.binding(function() { return root.selectedAsset })
selectedGasEthValue = Qt.binding(function() { return gasSelector.selectedGasEthValue })
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -267,9 +220,6 @@ ModalPopup {
id: transactionSigner id: transactionSigner
width: stack.width width: stack.width
signingPhrase: walletModel.signingPhrase signingPhrase: walletModel.signingPhrase
reset: function() {
signingPhrase = Qt.binding(function() { return walletModel.signingPhrase })
}
} }
} }
} }

View File

@ -77,11 +77,22 @@ Item {
} }
} }
SignTransactionModal { Loader {
id: signTransactionModal id: signTransactionModal
function open() {
this.active = true
this.item.open()
}
function closed() {
this.active = false // kill an opened instance
}
sourceComponent: SignTransactionModal {
onOpened: { onOpened: {
walletModel.getGasPricePredictions() walletModel.getGasPricePredictions()
} }
onClosed: {
signTransactionModal.closed()
}
selectedAccount: {} selectedAccount: {}
selectedRecipient: { selectedRecipient: {
return { return {
@ -94,7 +105,7 @@ Item {
selectedAsset: token selectedAsset: token
selectedAmount: tokenAmount selectedAmount: tokenAmount
selectedFiatAmount: fiatValue selectedFiatAmount: fiatValue
//outgoing: root.outgoing }
} }
SelectAccountModal { SelectAccountModal {

View File

@ -24,9 +24,6 @@ ModalPopup {
width: parent.width width: parent.width
//% "Choose account" //% "Choose account"
label: qsTr("Select account to share and receive assets") label: qsTr("Select account to share and receive assets")
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
}
} }
} }

View File

@ -42,11 +42,22 @@ Item {
} }
} }
SignTransactionModal { Loader {
id: signTransactionModal id: signTransactionModal
function open() {
this.active = true
this.item.open()
}
function closed() {
this.active = false // kill an opened instance
}
sourceComponent: SignTransactionModal {
onOpened: { onOpened: {
walletModel.getGasPricePredictions() walletModel.getGasPricePredictions()
} }
onClosed: {
signTransactionModal.closed()
}
selectedRecipient: { selectedRecipient: {
return { return {
address: commandParametersObject.address, address: commandParametersObject.address,
@ -60,6 +71,7 @@ Item {
selectedFiatAmount: fiatValue selectedFiatAmount: fiatValue
} }
} }
}
/*##^## /*##^##
Designer { Designer {

View File

@ -23,10 +23,6 @@ ModalPopup {
standardButtons: StandardButton.Ok standardButtons: StandardButton.Ok
} }
onClosed: {
stack.reset()
}
function sendTransaction() { function sendTransaction() {
let responseStr = profileModel.ens.registerENS(root.ensUsername, let responseStr = profileModel.ens.registerENS(root.ensUsername,
selectFromAccount.selectedAccount.address, selectFromAccount.selectedAccount.address,
@ -75,12 +71,6 @@ ModalPopup {
label: qsTrId("choose-account") label: qsTrId("choose-account")
showBalanceForAssetSymbol: root.asset.symbol showBalanceForAssetSymbol: root.asset.symbol
minRequiredAssetBalance: root.ensPrice minRequiredAssetBalance: root.ensPrice
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
selectedAccount = Qt.binding(function() { return walletModel.currentAccount })
showBalanceForAssetSymbol = Qt.binding(function() { return root.asset.symbol })
minRequiredAssetBalance = Qt.binding(function() { return root.ensPrice })
}
onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() } onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() }
} }
RecipientSelector { RecipientSelector {
@ -100,10 +90,6 @@ ModalPopup {
getGasEthValue: walletModel.getGasEthValue getGasEthValue: walletModel.getGasEthValue
getFiatValue: walletModel.getFiatValue getFiatValue: walletModel.getFiatValue
defaultCurrency: walletModel.defaultCurrency defaultCurrency: walletModel.defaultCurrency
reset: function() {
slowestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.safeLowGasPrice) })
fastestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.fastestGasPrice) })
}
property var estimateGas: Backpressure.debounce(gasSelector, 600, function() { property var estimateGas: Backpressure.debounce(gasSelector, 600, function() {
if (!(root.ensUsername !== "" && selectFromAccount.selectedAccount)) { if (!(root.ensUsername !== "" && selectFromAccount.selectedAccount)) {
selectedGasLimit = 380000 selectedGasLimit = 380000
@ -120,12 +106,6 @@ ModalPopup {
selectedAsset: root.asset selectedAsset: root.asset
selectedAmount: parseFloat(ensPrice) selectedAmount: parseFloat(ensPrice)
selectedGasEthValue: gasSelector.selectedGasEthValue selectedGasEthValue: gasSelector.selectedGasEthValue
reset: function() {
selectedAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
selectedAsset = Qt.binding(function() { return root.asset })
selectedAmount = Qt.binding(function() { return parseFloat(ensPrice) })
selectedGasEthValue = Qt.binding(function() { return gasSelector.selectedGasEthValue })
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -151,19 +131,6 @@ ModalPopup {
const fiatValue = walletModel.getFiatValue(root.ensPrice || 0, root.asset.symbol, currency) const fiatValue = walletModel.getFiatValue(root.ensPrice || 0, root.asset.symbol, currency)
return { "value": root.ensPrice, "fiatValue": fiatValue } return { "value": root.ensPrice, "fiatValue": fiatValue }
} }
reset: function() {
fromAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
toAccount = Qt.binding(function() { return selectRecipient.selectedRecipient })
asset = Qt.binding(function() { return root.asset })
amount = Qt.binding(function() { return { "value": root.ensPrice, "fiatValue": walletModel.getFiatValue(root.ensPrice, root.asset.symbol, currency) } })
gas = Qt.binding(function() {
return {
"value": gasSelector.selectedGasEthValue,
"symbol": "ETH",
"fiatValue": gasSelector.selectedGasFiatValue
}
})
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -177,9 +144,6 @@ ModalPopup {
id: transactionSigner id: transactionSigner
width: stack.width width: stack.width
signingPhrase: walletModel.signingPhrase signingPhrase: walletModel.signingPhrase
reset: function() {
signingPhrase = Qt.binding(function() { return walletModel.signingPhrase })
}
} }
} }
} }

View File

@ -46,12 +46,24 @@ Item {
Qt.callLater(validateENS, ensUsername, isStatus) Qt.callLater(validateENS, ensUsername, isStatus)
} }
SetPubKeyModal { Loader {
id: transactionDialog id: transactionDialog
function open() {
this.active = true
this.item.open()
}
function closed() {
this.active = false // kill an opened instance
}
sourceComponent: SetPubKeyModal {
onClosed: {
transactionDialog.closed()
}
ensUsername: ensUsername.text ensUsername: ensUsername.text
width: 400 width: 400
height: 400 height: 400
} }
}
StyledText { StyledText {
id: sectionTitle id: sectionTitle

View File

@ -21,10 +21,6 @@ ModalPopup {
standardButtons: StandardButton.Ok standardButtons: StandardButton.Ok
} }
onClosed: {
stack.reset()
}
function sendTransaction() { function sendTransaction() {
try { try {
let responseStr = profileModel.ens.setPubKey(root.ensUsername, let responseStr = profileModel.ens.setPubKey(root.ensUsername,
@ -79,12 +75,6 @@ ModalPopup {
label: qsTrId("choose-account") label: qsTrId("choose-account")
showBalanceForAssetSymbol: "ETH" showBalanceForAssetSymbol: "ETH"
minRequiredAssetBalance: 0 minRequiredAssetBalance: 0
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
selectedAccount = Qt.binding(function() { return walletModel.currentAccount })
showBalanceForAssetSymbol = Qt.binding(function() { return "ETH" })
minRequiredAssetBalance = Qt.binding(function() { return 0 })
}
onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() } onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() }
} }
RecipientSelector { RecipientSelector {
@ -104,10 +94,6 @@ ModalPopup {
getGasEthValue: walletModel.getGasEthValue getGasEthValue: walletModel.getGasEthValue
getFiatValue: walletModel.getFiatValue getFiatValue: walletModel.getFiatValue
defaultCurrency: walletModel.defaultCurrency defaultCurrency: walletModel.defaultCurrency
reset: function() {
slowestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.safeLowGasPrice) })
fastestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.fastestGasPrice) })
}
property var estimateGas: Backpressure.debounce(gasSelector, 600, function() { property var estimateGas: Backpressure.debounce(gasSelector, 600, function() {
if (!(root.ensUsername !== "" && selectFromAccount.selectedAccount)) { if (!(root.ensUsername !== "" && selectFromAccount.selectedAccount)) {
selectedGasLimit = 80000; selectedGasLimit = 80000;
@ -124,12 +110,6 @@ ModalPopup {
selectedAsset: root.asset selectedAsset: root.asset
selectedAmount: 0 selectedAmount: 0
selectedGasEthValue: gasSelector.selectedGasEthValue selectedGasEthValue: gasSelector.selectedGasEthValue
reset: function() {
selectedAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
selectedAsset = Qt.binding(function() { return root.asset })
selectedAmount = Qt.binding(function() { return 0 })
selectedGasEthValue = Qt.binding(function() { return gasSelector.selectedGasEthValue })
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -155,19 +135,6 @@ ModalPopup {
const fiatValue = walletModel.getFiatValue(0, root.asset.symbol, currency) const fiatValue = walletModel.getFiatValue(0, root.asset.symbol, currency)
return { "value": 0, "fiatValue": fiatValue } return { "value": 0, "fiatValue": fiatValue }
} }
reset: function() {
fromAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
toAccount = Qt.binding(function() { return selectRecipient.selectedRecipient })
asset = Qt.binding(function() { return root.asset })
amount = Qt.binding(function() { return { "value": 0, "fiatValue": walletModel.getFiatValue(0, root.asset.symbol, currency) } })
gas = Qt.binding(function() {
return {
"value": gasSelector.selectedGasEthValue,
"symbol": "ETH",
"fiatValue": gasSelector.selectedGasFiatValue
}
})
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -181,9 +148,6 @@ ModalPopup {
id: transactionSigner id: transactionSigner
width: stack.width width: stack.width
signingPhrase: walletModel.signingPhrase signingPhrase: walletModel.signingPhrase
reset: function() {
signingPhrase = Qt.binding(function() { return walletModel.signingPhrase })
}
} }
} }
} }

View File

@ -23,12 +23,24 @@ Item {
font.pixelSize: 20 font.pixelSize: 20
} }
RegisterENSModal { Loader {
id: transactionDialog id: transactionDialog
function open() {
this.active = true
this.item.open()
}
function closed() {
this.active = false // kill an opened instance
}
sourceComponent: RegisterENSModal {
onClosed: {
transactionDialog.closed()
}
ensUsername: username ensUsername: username
width: 400 width: 400
height: 400 height: 400
} }
}
ModalPopup { ModalPopup {
id: popup id: popup

View File

@ -12,7 +12,6 @@ ModalPopup {
property alias selectFromAccount: selectFromAccount property alias selectFromAccount: selectFromAccount
property alias selectRecipient: selectRecipient property alias selectRecipient: selectRecipient
property alias stack: stack property alias stack: stack
signal reset
//% "Send" //% "Send"
title: qsTrId("command-button-send") title: qsTrId("command-button-send")
@ -26,11 +25,6 @@ ModalPopup {
standardButtons: StandardButton.Ok standardButtons: StandardButton.Ok
} }
onClosed: {
stack.reset()
root.reset()
}
function sendTransaction() { function sendTransaction() {
stack.currentGroup.isPending = true stack.currentGroup.isPending = true
walletModel.sendTransaction(selectFromAccount.selectedAccount.address, walletModel.sendTransaction(selectFromAccount.selectedAccount.address,
@ -67,10 +61,6 @@ ModalPopup {
width: stack.width width: stack.width
//% "From account" //% "From account"
label: qsTrId("from-account") label: qsTrId("from-account")
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
selectedAccount = Qt.binding(function() { return walletModel.currentAccount })
}
onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() } onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() }
} }
SeparatorWithIcon { SeparatorWithIcon {
@ -87,11 +77,6 @@ ModalPopup {
anchors.top: separator.bottom anchors.top: separator.bottom
anchors.topMargin: 10 anchors.topMargin: 10
width: stack.width width: stack.width
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
contacts = Qt.binding(function() { return profileModel.addedContacts })
selectedRecipient = undefined
}
onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() } onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() }
} }
} }
@ -109,9 +94,6 @@ ModalPopup {
getFiatValue: walletModel.getFiatValue getFiatValue: walletModel.getFiatValue
getCryptoValue: walletModel.getCryptoValue getCryptoValue: walletModel.getCryptoValue
width: stack.width width: stack.width
reset: function() {
selectedAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
}
onSelectedAssetChanged: if (isValid) { gasSelector.estimateGas() } onSelectedAssetChanged: if (isValid) { gasSelector.estimateGas() }
onSelectedAmountChanged: if (isValid) { gasSelector.estimateGas() } onSelectedAmountChanged: if (isValid) { gasSelector.estimateGas() }
} }
@ -125,10 +107,6 @@ ModalPopup {
getFiatValue: walletModel.getFiatValue getFiatValue: walletModel.getFiatValue
defaultCurrency: walletModel.defaultCurrency defaultCurrency: walletModel.defaultCurrency
width: stack.width width: stack.width
reset: function() {
slowestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.safeLowGasPrice) })
fastestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.fastestGasPrice) })
}
property var estimateGas: Backpressure.debounce(gasSelector, 600, function() { property var estimateGas: Backpressure.debounce(gasSelector, 600, function() {
if (!(selectFromAccount.selectedAccount && selectFromAccount.selectedAccount.address && if (!(selectFromAccount.selectedAccount && selectFromAccount.selectedAccount.address &&
selectRecipient.selectedRecipient && selectRecipient.selectedRecipient.address && selectRecipient.selectedRecipient && selectRecipient.selectedRecipient.address &&
@ -158,12 +136,6 @@ ModalPopup {
selectedAmount: parseFloat(txtAmount.selectedAmount) selectedAmount: parseFloat(txtAmount.selectedAmount)
selectedAsset: txtAmount.selectedAsset selectedAsset: txtAmount.selectedAsset
selectedGasEthValue: gasSelector.selectedGasEthValue selectedGasEthValue: gasSelector.selectedGasEthValue
reset: function() {
selectedAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
selectedAmount = Qt.binding(function() { return parseFloat(txtAmount.selectedAmount) })
selectedAsset = Qt.binding(function() { return txtAmount.selectedAsset })
selectedGasEthValue = Qt.binding(function() { return gasSelector.selectedGasEthValue })
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -186,27 +158,11 @@ ModalPopup {
asset: txtAmount.selectedAsset asset: txtAmount.selectedAsset
amount: { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount } amount: { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount }
currency: walletModel.defaultCurrency currency: walletModel.defaultCurrency
reset: function() {
fromAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
toAccount = Qt.binding(function() { return selectRecipient.selectedRecipient })
asset = Qt.binding(function() { return txtAmount.selectedAsset })
amount = Qt.binding(function() { return { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount } })
gas = Qt.binding(function() {
return {
"value": gasSelector.selectedGasEthValue,
"symbol": "ETH",
"fiatValue": gasSelector.selectedGasFiatValue
}
})
}
} }
SendToContractWarning { SendToContractWarning {
id: sendToContractWarning id: sendToContractWarning
anchors.top: pvwTransaction.bottom anchors.top: pvwTransaction.bottom
selectedRecipient: selectRecipient.selectedRecipient selectedRecipient: selectRecipient.selectedRecipient
reset: function() {
selectedRecipient = Qt.binding(function() { return selectRecipient.selectedRecipient })
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -220,9 +176,6 @@ ModalPopup {
id: transactionSigner id: transactionSigner
width: stack.width width: stack.width
signingPhrase: walletModel.signingPhrase signingPhrase: walletModel.signingPhrase
reset: function() {
signingPhrase = Qt.binding(function() { return walletModel.signingPhrase })
}
} }
} }
} }

View File

@ -18,11 +18,25 @@ RowLayout {
} }
// Add SenmdModal here as it is used by the Wallet as well as the Browser // Add SenmdModal here as it is used by the Wallet as well as the Browser
SendModal{ Loader {
id: sendModal id: sendModal
function open() {
this.active = true
this.item.open()
}
function closed() {
// this.sourceComponent = undefined // kill an opened instance
this.active = false
}
sourceComponent: SendModal {
onOpened: { onOpened: {
walletModel.getGasPricePredictions() walletModel.getGasPricePredictions()
} }
onClosed: {
sendModal.closed()
}
}
} }
function changeAppSection(section) { function changeAppSection(section) {

View File

@ -25,17 +25,6 @@ Item {
property alias dropdownAlignment: select.menuAlignment property alias dropdownAlignment: select.menuAlignment
property bool isValid: true property bool isValid: true
property bool readOnly: false property bool readOnly: false
property var reset: function() {}
function resetInternal() {
accounts = undefined
selectedAccount = undefined
showBalanceForAssetSymbol = ""
minRequiredAssetBalance = 0
assetFound = undefined
isValid = true
readOnly = false
}
function validate() { function validate() {
if (showBalanceForAssetSymbol == "" || minRequiredAssetBalance == 0 || !assetFound) { if (showBalanceForAssetSymbol == "" || minRequiredAssetBalance == 0 || !assetFound) {

View File

@ -9,14 +9,8 @@ Item {
property var sources: [] property var sources: []
property var selectedSource: sources.length ? sources[0] : null property var selectedSource: sources.length ? sources[0] : null
property int dropdownWidth: 220 property int dropdownWidth: 220
property var reset: function() {}
height: select.height height: select.height
function resetInternal() {
sources = []
selectedSource = sources.length ? sources[0] : null
}
Select { Select {
id: select id: select
anchors.left: parent.left anchors.left: parent.left

View File

@ -23,17 +23,6 @@ Item {
property bool isDirty: false property bool isDirty: false
property bool validateBalance: true property bool validateBalance: true
property bool isValid: false property bool isValid: false
property var reset: function() {}
function resetInternal() {
selectAsset.resetInternal()
selectedAccount = undefined
txtFiatBalance.text = "0.00"
inputAmount.resetInternal()
txtBalanceDesc.color = Style.current.secondaryText
txtBalance.color = Qt.binding(function() { return txtBalance.hovered ? Style.current.textColor : Style.current.secondaryText })
isValid = false
}
id: root id: root

View File

@ -14,20 +14,12 @@ Column {
property double amount property double amount
property var asset property var asset
property bool isValid: false property bool isValid: false
property var reset: function() {}
property alias errorMessage: txtValidationError.text property alias errorMessage: txtValidationError.text
onAccountChanged: validate() onAccountChanged: validate()
onAmountChanged: validate() onAmountChanged: validate()
onAssetChanged: validate() onAssetChanged: validate()
function resetInternal() {
account = undefined
amount = 0
asset = undefined
isValid = false
}
function validate() { function validate() {
let isValid = true let isValid = true
if (!(account && account.assets && asset && amount > 0)) { if (!(account && account.assets && asset && amount > 0)) {

View File

@ -16,22 +16,12 @@ Item {
property alias validationErrorAlignment: select.validationErrorAlignment property alias validationErrorAlignment: select.validationErrorAlignment
property bool isValid: false property bool isValid: false
property alias isPending: ensResolver.isPending property alias isPending: ensResolver.isPending
property var reset: function() {}
property bool readOnly: false property bool readOnly: false
property bool isResolvedAddress: false property bool isResolvedAddress: false
//% "Select a contact" //% "Select a contact"
property string selectAContact: qsTrId("select-a-contact") property string selectAContact: qsTrId("select-a-contact")
property string noEnsAddressMessage: qsTr("Contact does not have an ENS address. Please send a transaction in chat.") property string noEnsAddressMessage: qsTr("Contact does not have an ENS address. Please send a transaction in chat.")
function resetInternal() {
contacts = undefined
selectedContact = undefined
select.validationError = ""
isValid = false
readOnly = false
isResolvedAddress = false
}
function resolveEns() { function resolveEns() {
if (selectedContact.ensVerified) { if (selectedContact.ensVerified) {
root.isResolvedAddress = false root.isResolvedAddress = false
@ -139,7 +129,7 @@ Item {
anchors.top: select.bottom anchors.top: select.bottom
anchors.right: select.right anchors.right: select.right
anchors.topMargin: Style.current.halfPadding anchors.topMargin: Style.current.halfPadding
debounceDelay: root.readOnly ? 0 : 600 debounceDelay: 0
onResolved: { onResolved: {
root.isResolvedAddress = true root.isResolvedAddress = true
var selectedContact = root.selectedContact var selectedContact = root.selectedContact

View File

@ -22,22 +22,6 @@ Rectangle {
return { isValid, isPending } return { isValid, isPending }
} }
color: Style.current.background color: Style.current.background
function reset() {
for (let i=0; i<children.length; i++) {
const component = children[i]
try {
if (component.hasOwnProperty("resetInternal") && typeof component.resetInternal === "function") {
component.resetInternal()
}
if (component.hasOwnProperty("reset") && typeof component.reset === "function") {
component.reset()
}
} catch (e) {
console.warn("Error resetting component", i, ":", e.message)
continue
}
}
}
StackView.onActivated: { StackView.onActivated: {
// parent refers to the StackView // parent refers to the StackView
parent.groupActivated(this) parent.groupActivated(this)

View File

@ -27,21 +27,11 @@ Item {
//% "Please enter an amount" //% "Please enter an amount"
property string noInputErrorMessage: qsTrId("please-enter-an-amount") property string noInputErrorMessage: qsTrId("please-enter-an-amount")
property bool isValid: true property bool isValid: true
property var reset: function() {}
function defaultGasPrice() { function defaultGasPrice() {
return ((50 * (root.fastestGasPrice - root.slowestGasPrice) / 100) + root.slowestGasPrice) return ((50 * (root.fastestGasPrice - root.slowestGasPrice) / 100) + root.slowestGasPrice)
} }
function resetInternal() {
slowestGasPrice = 0
fastestGasPrice = 100
inputGasLimit.text = "21000"
customNetworkFeeDialog.isValid = true
inputGasPrice.text = Qt.binding(defaultGasPrice)
gasSlider.value = Qt.binding(defaultGasPrice)
}
function updateGasEthValue() { function updateGasEthValue() {
// causes error on application load without this null check // causes error on application load without this null check
if (!inputGasPrice || !inputGasLimit) { if (!inputGasPrice || !inputGasLimit) {

View File

@ -16,21 +16,12 @@ Column {
property var selectedAsset property var selectedAsset
property double selectedGasEthValue property double selectedGasEthValue
property bool isValid: false property bool isValid: false
property var reset: function() {}
onSelectedAccountChanged: validate() onSelectedAccountChanged: validate()
onSelectedAmountChanged: validate() onSelectedAmountChanged: validate()
onSelectedAssetChanged: validate() onSelectedAssetChanged: validate()
onSelectedGasEthValueChanged: validate() onSelectedGasEthValueChanged: validate()
function resetInternal() {
selectedAccount = undefined
selectedAmount = 0
selectedAsset = undefined
selectedGasEthValue = 0
isValid = false
}
function validate() { function validate() {
let isValid = true let isValid = true
if (!(selectedAccount && selectedAccount.assets && selectedAsset && selectedGasEthValue > 0)) { if (!(selectedAccount && selectedAccount.assets && selectedAsset && selectedGasEthValue > 0)) {

View File

@ -28,11 +28,10 @@ Item {
return inpAddress.isPending return inpAddress.isPending
case RecipientSelector.Type.Contact: case RecipientSelector.Type.Contact:
return selContact.isPending return selContact.isPending
default: case RecipientSelector.Type.Account:
return false return false // AccountSelector is never pending
} }
} }
property var reset: function() {}
readonly property var sources: [ readonly property var sources: [
//% "Address" //% "Address"
{ text: qsTrId("address"), value: RecipientSelector.Type.Address, visible: true }, { text: qsTrId("address"), value: RecipientSelector.Type.Address, visible: true },
@ -42,34 +41,6 @@ Item {
] ]
property var selectedType: RecipientSelector.Type.Address property var selectedType: RecipientSelector.Type.Address
function resetInternal() {
inpAddress.resetInternal()
selContact.resetInternal()
selAccount.resetInternal()
selAddressSource.resetInternal()
isValid = false
isPending = Qt.binding(function() {
if (!selAddressSource.selectedSource) {
return false
}
switch (selAddressSource.selectedSource.value) {
case RecipientSelector.Type.Address:
return inpAddress.isPending
case RecipientSelector.Type.Contact:
return selContact.isPending
case RecipientSelector.Type.Account:
return selAccount.isPending
}
})
selectedType = RecipientSelector.Type.Address
selectedRecipient = undefined
accounts = undefined
contacts = undefined
selContact.reset()
selAccount.reset()
selAddressSource.reset()
}
enum Type { enum Type {
Address, Address,
Contact, Contact,
@ -78,7 +49,10 @@ Item {
function validate() { function validate() {
let isValid = true let isValid = true
switch (root.selectedType) { if (!selAddressSource.selectedSource) {
return root.isValid
}
switch (selAddressSource.selectedSource.value) {
case RecipientSelector.Type.Address: case RecipientSelector.Type.Address:
isValid = inpAddress.isValid isValid = inpAddress.isValid
break break
@ -190,10 +164,6 @@ Item {
Layout.preferredWidth: selAddressSource.visible ? root.inputWidth : parent.width Layout.preferredWidth: selAddressSource.visible ? root.inputWidth : parent.width
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
Layout.fillWidth: true Layout.fillWidth: true
reset: function() {
contacts = Qt.binding(function() { return root.contacts })
readOnly = Qt.binding(function() { return root.readOnly })
}
onSelectedContactChanged: { onSelectedContactChanged: {
if (!selectedContact || !selAddressSource.selectedSource || !selectedContact.address || (selAddressSource.selectedSource && selAddressSource.selectedSource.value !== RecipientSelector.Type.Contact)) { if (!selectedContact || !selAddressSource.selectedSource || !selectedContact.address || (selAddressSource.selectedSource && selAddressSource.selectedSource.value !== RecipientSelector.Type.Contact)) {
return return
@ -214,9 +184,6 @@ Item {
Layout.preferredWidth: selAddressSource.visible ? root.inputWidth : parent.width Layout.preferredWidth: selAddressSource.visible ? root.inputWidth : parent.width
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
Layout.fillWidth: true Layout.fillWidth: true
reset: function() {
accounts = Qt.binding(function() { return root.accounts })
}
onSelectedAccountChanged: { onSelectedAccountChanged: {
if (!selectedAccount || !selAddressSource.selectedSource || (selAddressSource.selectedSource && selAddressSource.selectedSource.value !== RecipientSelector.Type.Account)) { if (!selectedAccount || !selAddressSource.selectedSource || (selAddressSource.selectedSource && selAddressSource.selectedSource.value !== RecipientSelector.Type.Account)) {
return return
@ -233,10 +200,6 @@ Item {
width: sourceSelectWidth width: sourceSelectWidth
Layout.preferredWidth: root.sourceSelectWidth Layout.preferredWidth: root.sourceSelectWidth
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
reset: function() {
sources = Qt.binding(function() { return root.sources.filter(source => source.visible) })
selectedSource = root.getSourceByType(root.selectedType)
}
onSelectedSourceChanged: { onSelectedSourceChanged: {
if (root.readOnly || !selectedSource) { if (root.readOnly || !selectedSource) {

View File

@ -11,15 +11,9 @@ Item {
property string sendToContractWarningMessage: qsTr("Tokens will be sent directly to a contract address, which may result in a loss of funds. To transfer ERC-20 tokens, ensure the recipient address is the address of the destination wallet.") property string sendToContractWarningMessage: qsTr("Tokens will be sent directly to a contract address, which may result in a loss of funds. To transfer ERC-20 tokens, ensure the recipient address is the address of the destination wallet.")
property var selectedRecipient property var selectedRecipient
property bool isValid: true property bool isValid: true
property var reset: function() {}
onSelectedRecipientChanged: validate() onSelectedRecipientChanged: validate()
function resetInternal() {
selectedRecipient = undefined
isValid = true
}
function validate() { function validate() {
let isValid = true let isValid = true
if (!(selectedRecipient && selectedRecipient.address)) { if (!(selectedRecipient && selectedRecipient.address)) {

View File

@ -14,7 +14,6 @@ Item {
property string currency: "USD" property string currency: "USD"
property var gas property var gas
height: content.height height: content.height
property var reset: function() {}
signal fromClicked signal fromClicked
signal gasClicked signal gasClicked
// Creates a mouse area around the "from account". When clicked, triggers // Creates a mouse area around the "from account". When clicked, triggers
@ -29,14 +28,6 @@ Item {
property bool toWarn: false property bool toWarn: false
property bool gasValid: true property bool gasValid: true
function resetInternal() {
fromAccount = undefined
toAccount = undefined
asset = undefined
amount = undefined
gas = undefined
}
Column { Column {
id: content id: content
anchors.left: parent.left anchors.left: parent.left

View File

@ -16,14 +16,6 @@ Item {
//% "Password needs to be 4 characters or more" //% "Password needs to be 4 characters or more"
property string invalidInputErrorMessage: qsTrId("password-needs-to-be-4-characters-or-more") property string invalidInputErrorMessage: qsTrId("password-needs-to-be-4-characters-or-more")
property bool isValid: false property bool isValid: false
property var reset: function() {}
function resetInternal() {
signingPhrase.text = ""
enteredPassword = ""
txtPassword.resetInternal()
isValid = false
}
function forceActiveFocus(reason) { function forceActiveFocus(reason) {
txtPassword.forceActiveFocus(reason) txtPassword.forceActiveFocus(reason)

View File

@ -27,14 +27,6 @@ StackView {
currentIdx-- currentIdx--
} }
function reset() {
for (let i=0; i<groups.length; i++) {
groups[i].reset()
}
this.pop(null)
currentIdx = 0
}
initialItem: groups[currentIdx] initialItem: groups[currentIdx]
anchors.fill: parent anchors.fill: parent

View File

@ -92,14 +92,26 @@ Item {
height: 350 height: 350
} }
} }
StatusStickerPackPurchaseModal { Loader {
id: stickerPackPurchaseModal id: stickerPackPurchaseModal
function open() {
this.active = true
this.item.open()
}
function closed() {
this.active = false // kill an opened instance
}
sourceComponent: StatusStickerPackPurchaseModal {
onClosed: {
stickerPackPurchaseModal.closed()
}
stickerPackId: packId stickerPackId: packId
packPrice: price packPrice: price
width: stickerPackDetailsPopup.width width: stickerPackDetailsPopup.width
height: stickerPackDetailsPopup.height height: stickerPackDetailsPopup.height
showBackBtn: stickerPackDetailsPopup.opened showBackBtn: stickerPackDetailsPopup.opened
} }
}
StatusStickerPackDetails { StatusStickerPackDetails {
id: stickerPackDetails id: stickerPackDetails
height: 64 - (Style.current.smallPadding * 2) height: 64 - (Style.current.smallPadding * 2)

View File

@ -23,10 +23,6 @@ ModalPopup {
standardButtons: StandardButton.Ok standardButtons: StandardButton.Ok
} }
onClosed: {
stack.reset()
}
function sendTransaction() { function sendTransaction() {
let responseStr = chatsModel.buyStickerPack(root.stickerPackId, let responseStr = chatsModel.buyStickerPack(root.stickerPackId,
selectFromAccount.selectedAccount.address, selectFromAccount.selectedAccount.address,
@ -79,12 +75,6 @@ ModalPopup {
label: qsTrId("choose-account") label: qsTrId("choose-account")
showBalanceForAssetSymbol: root.asset.symbol showBalanceForAssetSymbol: root.asset.symbol
minRequiredAssetBalance: root.packPrice minRequiredAssetBalance: root.packPrice
reset: function() {
accounts = Qt.binding(function() { return walletModel.accounts })
selectedAccount = Qt.binding(function() { return walletModel.currentAccount })
showBalanceForAssetSymbol = Qt.binding(function() { return root.asset.symbol })
minRequiredAssetBalance = Qt.binding(function() { return root.packPrice })
}
onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() } onSelectedAccountChanged: if (isValid) { gasSelector.estimateGas() }
} }
RecipientSelector { RecipientSelector {
@ -104,10 +94,6 @@ ModalPopup {
getGasEthValue: walletModel.getGasEthValue getGasEthValue: walletModel.getGasEthValue
getFiatValue: walletModel.getFiatValue getFiatValue: walletModel.getFiatValue
defaultCurrency: walletModel.defaultCurrency defaultCurrency: walletModel.defaultCurrency
reset: function() {
slowestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.safeLowGasPrice) })
fastestGasPrice = Qt.binding(function(){ return parseFloat(walletModel.fastestGasPrice) })
}
property var estimateGas: Backpressure.debounce(gasSelector, 600, function() { property var estimateGas: Backpressure.debounce(gasSelector, 600, function() {
if (!(root.stickerPackId > -1 && selectFromAccount.selectedAccount && root.packPrice && parseFloat(root.packPrice) > 0)) { if (!(root.stickerPackId > -1 && selectFromAccount.selectedAccount && root.packPrice && parseFloat(root.packPrice) > 0)) {
selectedGasLimit = 325000 selectedGasLimit = 325000
@ -124,12 +110,6 @@ ModalPopup {
selectedAsset: root.asset selectedAsset: root.asset
selectedAmount: parseFloat(packPrice) selectedAmount: parseFloat(packPrice)
selectedGasEthValue: gasSelector.selectedGasEthValue selectedGasEthValue: gasSelector.selectedGasEthValue
reset: function() {
selectedAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
selectedAsset = Qt.binding(function() { return root.asset })
selectedAmount = Qt.binding(function() { return parseFloat(packPrice) })
selectedGasEthValue = Qt.binding(function() { return gasSelector.selectedGasEthValue })
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -159,19 +139,6 @@ ModalPopup {
const fiatValue = walletModel.getFiatValue(root.packPrice || 0, root.asset.symbol, currency) const fiatValue = walletModel.getFiatValue(root.packPrice || 0, root.asset.symbol, currency)
return { "value": root.packPrice, "fiatValue": fiatValue } return { "value": root.packPrice, "fiatValue": fiatValue }
} }
reset: function() {
fromAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
toAccount = Qt.binding(function() { return selectRecipient.selectedRecipient })
asset = Qt.binding(function() { return root.asset })
amount = Qt.binding(function() { return { "value": root.packPrice, "fiatValue": walletModel.getFiatValue(root.packPrice, root.asset.symbol, currency) } })
gas = Qt.binding(function() {
return {
"value": gasSelector.selectedGasEthValue,
"symbol": "ETH",
"fiatValue": gasSelector.selectedGasFiatValue
}
})
}
} }
} }
TransactionFormGroup { TransactionFormGroup {
@ -185,9 +152,6 @@ ModalPopup {
id: transactionSigner id: transactionSigner
width: stack.width width: stack.width
signingPhrase: walletModel.signingPhrase signingPhrase: walletModel.signingPhrase
reset: function() {
signingPhrase = Qt.binding(function() { return walletModel.signingPhrase })
}
} }
} }
} }