2020-09-01 03:49:05 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import "../imports"
|
2020-10-22 12:06:35 +00:00
|
|
|
import "./status"
|
2020-09-01 03:49:05 +00:00
|
|
|
|
2020-10-22 12:06:35 +00:00
|
|
|
Column {
|
2020-09-01 03:49:05 +00:00
|
|
|
id: root
|
2020-10-22 12:06:35 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
visible: !isValid
|
|
|
|
spacing: 5
|
|
|
|
|
|
|
|
property alias errorMessage: txtValidationError.text
|
2020-09-01 03:49:05 +00:00
|
|
|
property var selectedAccount
|
|
|
|
property double selectedAmount
|
|
|
|
property var selectedAsset
|
|
|
|
property double selectedGasEthValue
|
|
|
|
property bool isValid: false
|
|
|
|
|
|
|
|
onSelectedAccountChanged: validate()
|
|
|
|
onSelectedAmountChanged: validate()
|
|
|
|
onSelectedAssetChanged: validate()
|
|
|
|
onSelectedGasEthValueChanged: validate()
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
let isValid = true
|
2020-09-17 20:20:19 +00:00
|
|
|
if (!(selectedAccount && selectedAccount.assets && selectedAsset && selectedGasEthValue > 0)) {
|
2020-09-01 03:49:05 +00:00
|
|
|
return root.isValid
|
|
|
|
}
|
2020-10-22 12:06:35 +00:00
|
|
|
isValid = true
|
2020-09-01 03:49:05 +00:00
|
|
|
let gasTotal = selectedGasEthValue
|
feat: enable token transactions
Fixes #788.
Fixes #853.
Fixes #856.
refactor: gas estimation and transaction sends have been abstracted to allow calling `estimateGas`, `send`, and `call` on the contract method (similar to the web3 API).
Moved sticker pack gas estimation and purchase tx over to the new API
*Sticker purchase:*
- gas estimate is done using new API and debounced using a timer
*Wallet send transaction:*
- tokens can now be sent
- gas is estimated correctly for a token tx, and debounced using a timer
***NOTE***
1. If attempting to send tokens on testnet, you must use a custom token as the token addresses in the pre-built list are for mainnet and will not work on testnet.
2. The new API should support all existing gas estimates, send txs, and calls. The loading of sticker pack data, balance, count, purchased sticker packs, etc, can be moved over to the new API. Almost all of the `eth_sendTransaction`, `eth_gasEstimate`, and `eth_call` could be move over as well (that's the idea at least).
2020-09-07 09:39:17 +00:00
|
|
|
if (selectedAsset && selectedAsset.symbol && selectedAsset.symbol.toUpperCase() === "ETH") {
|
2020-09-01 03:49:05 +00:00
|
|
|
gasTotal += selectedAmount
|
|
|
|
}
|
|
|
|
const currAcctGasAsset = Utils.findAssetBySymbol(selectedAccount.assets, "ETH")
|
2020-09-23 18:01:33 +00:00
|
|
|
if (currAcctGasAsset && currAcctGasAsset.value < gasTotal) {
|
2020-09-01 03:49:05 +00:00
|
|
|
isValid = false
|
|
|
|
}
|
|
|
|
root.isValid = isValid
|
|
|
|
return isValid
|
|
|
|
}
|
2020-10-22 12:06:35 +00:00
|
|
|
SVGImage {
|
|
|
|
id: imgExclamation
|
|
|
|
width: 13.33
|
|
|
|
height: 13.33
|
|
|
|
sourceSize.height: height * 2
|
|
|
|
sourceSize.width: width * 2
|
2020-09-01 03:49:05 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-10-22 12:06:35 +00:00
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: "../app/img/exclamation_outline.svg"
|
|
|
|
}
|
|
|
|
StyledText {
|
|
|
|
id: txtValidationError
|
|
|
|
//% "Not enough ETH for gas"
|
|
|
|
text: qsTrId("wallet-insufficient-gas")
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
font.pixelSize: 13
|
|
|
|
height: 18
|
|
|
|
color: Style.current.danger
|
2020-09-01 03:49:05 +00:00
|
|
|
}
|
|
|
|
}
|