Browse Source

transaction dialog ui

cl-refactor
yann300 10 years ago
parent
commit
7c84ffde7c
  1. 39
      mix/CodeModel.cpp
  2. 19
      mix/CodeModel.h
  3. 1
      mix/qml/QAddressView.qml
  4. 21
      mix/qml/QBoolTypeView.qml
  5. 9
      mix/qml/StructView.qml
  6. 609
      mix/qml/TransactionDialog.qml
  7. 6
      mix/qml/js/NetworkDeployment.js
  8. 4
      mix/qml/js/TransactionHelper.js

39
mix/CodeModel.cpp

@ -392,6 +392,7 @@ void CodeModel::gasEstimation(solidity::CompilerStack const& _cs)
} }
eth::AssemblyItems const& runtimeAssembly = *_cs.getRuntimeAssemblyItems(n); eth::AssemblyItems const& runtimeAssembly = *_cs.getRuntimeAssemblyItems(n);
QString contractName = QString::fromStdString(contractDefinition.getName());
// Functional gas costs (per function, but also for accessors) // Functional gas costs (per function, but also for accessors)
for (auto it: contractDefinition.getInterfaceFunctions()) for (auto it: contractDefinition.getInterfaceFunctions())
{ {
@ -399,13 +400,15 @@ void CodeModel::gasEstimation(solidity::CompilerStack const& _cs)
continue; continue;
SourceLocation loc = it.second->getDeclaration().getLocation(); SourceLocation loc = it.second->getDeclaration().getLocation();
GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(runtimeAssembly, it.second->externalSignature()); GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(runtimeAssembly, it.second->externalSignature());
m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Function); m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Function,
contractName, QString::fromStdString(it.second->getDeclaration().getName()));
} }
if (auto const* fallback = contractDefinition.getFallbackFunction()) if (auto const* fallback = contractDefinition.getFallbackFunction())
{ {
SourceLocation loc = fallback->getLocation(); SourceLocation loc = fallback->getLocation();
GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(runtimeAssembly, "INVALID"); GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(runtimeAssembly, "INVALID");
m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Function); m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Function,
contractName, "fallback");
} }
for (auto const& it: contractDefinition.getDefinedFunctions()) for (auto const& it: contractDefinition.getDefinedFunctions())
{ {
@ -416,13 +419,15 @@ void CodeModel::gasEstimation(solidity::CompilerStack const& _cs)
GasEstimator::GasConsumption cost = GasEstimator::GasConsumption::infinite(); GasEstimator::GasConsumption cost = GasEstimator::GasConsumption::infinite();
if (entry > 0) if (entry > 0)
cost = GasEstimator::functionalEstimation(runtimeAssembly, entry, *it); cost = GasEstimator::functionalEstimation(runtimeAssembly, entry, *it);
m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Function); m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Function,
contractName, QString::fromStdString(it->getName()));
} }
if (auto const* constructor = contractDefinition.getConstructor()) if (auto const* constructor = contractDefinition.getConstructor())
{ {
SourceLocation loc = constructor->getLocation(); SourceLocation loc = constructor->getLocation();
GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(*_cs.getAssemblyItems(n)); GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(*_cs.getAssemblyItems(n));
m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Constructor); m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Constructor,
contractName, contractName);
} }
} }
} }
@ -435,6 +440,14 @@ QVariantList CodeModel::gasCostByDocumentId(QString const& _documentId) const
return QVariantList(); return QVariantList();
} }
QVariantList CodeModel::gasCostBy(QString const& _contractName, QString const& _functionName) const
{
if (m_gasCostsMaps)
return m_gasCostsMaps->gasCostsBy(_contractName, _functionName);
else
return QVariantList();
}
void CodeModel::collectContracts(dev::solidity::CompilerStack const& _cs, std::vector<std::string> const& _sourceNames) void CodeModel::collectContracts(dev::solidity::CompilerStack const& _cs, std::vector<std::string> const& _sourceNames)
{ {
Guard pl(x_pendingContracts); Guard pl(x_pendingContracts);
@ -643,9 +656,9 @@ void CodeModel::setOptimizeCode(bool _value)
emit scheduleCompilationJob(++m_backgroundJobId); emit scheduleCompilationJob(++m_backgroundJobId);
} }
void GasMapWrapper::push(QString _source, int _start, int _end, QString _value, bool _isInfinite, GasMap::type _type) void GasMapWrapper::push(QString _source, int _start, int _end, QString _value, bool _isInfinite, GasMap::type _type, QString _contractName, QString _functionName)
{ {
GasMap* gas = new GasMap(_start, _end, _value, _isInfinite, _type, this); GasMap* gas = new GasMap(_start, _end, _value, _isInfinite, _type, _contractName, _functionName, this);
m_gasMaps.find(_source).value().push_back(QVariant::fromValue(gas)); m_gasMaps.find(_source).value().push_back(QVariant::fromValue(gas));
} }
@ -668,3 +681,17 @@ QVariantList GasMapWrapper::gasCostsByDocId(QString _source)
return QVariantList(); return QVariantList();
} }
QVariantList GasMapWrapper::gasCostsBy(QString _contractName, QString _functionName)
{
QVariantList gasMap;
for (auto const& map: m_gasMaps)
{
for (auto const& gas: map)
{
if (gas.value<GasMap*>()->contractName() == _contractName && (_functionName.isEmpty() || gas.value<GasMap*>()->functionName() == _functionName))
gasMap.push_back(gas);
}
}
return gasMap;
}

19
mix/CodeModel.h

@ -31,6 +31,7 @@
#include <QMetaEnum> #include <QMetaEnum>
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
#include <libdevcore/Guards.h> #include <libdevcore/Guards.h>
#include <libevmcore/Params.h>
#include <libevmasm/Assembly.h> #include <libevmasm/Assembly.h>
#include "SolidityType.h" #include "SolidityType.h"
#include "QBigInt.h" #include "QBigInt.h"
@ -140,6 +141,8 @@ class GasMap: public QObject
Q_PROPERTY(QString gas MEMBER m_gas CONSTANT) Q_PROPERTY(QString gas MEMBER m_gas CONSTANT)
Q_PROPERTY(bool isInfinite MEMBER m_isInfinite CONSTANT) Q_PROPERTY(bool isInfinite MEMBER m_isInfinite CONSTANT)
Q_PROPERTY(QString codeBlockType READ codeBlockType CONSTANT) Q_PROPERTY(QString codeBlockType READ codeBlockType CONSTANT)
Q_PROPERTY(QString contractName MEMBER m_contractName CONSTANT)
Q_PROPERTY(QString functionName MEMBER m_functionName CONSTANT)
public: public:
@ -150,13 +153,19 @@ public:
Constructor Constructor
}; };
GasMap(int _start, int _end, QString _gas, bool _isInfinite, type _type, QObject* _parent): QObject(_parent), m_start(_start), m_end(_end), m_gas(_gas), m_isInfinite(_isInfinite), m_type(_type) {} GasMap(int _start, int _end, QString _gas, bool _isInfinite, type _type, QString _contractName, QString _functionName, QObject* _parent): QObject(_parent),
m_start(_start), m_end(_end), m_gas(_gas), m_isInfinite(_isInfinite), m_type(_type), m_contractName(_contractName), m_functionName(_functionName) {}
QString contractName() { return m_contractName; }
QString functionName() { return m_functionName; }
private:
int m_start; int m_start;
int m_end; int m_end;
QString m_gas; QString m_gas;
bool m_isInfinite; bool m_isInfinite;
type m_type; type m_type;
QString m_contractName;
QString m_functionName;
QString codeBlockType() const QString codeBlockType() const
{ {
@ -178,10 +187,11 @@ class GasMapWrapper: public QObject
public: public:
GasMapWrapper(QObject* _parent = nullptr): QObject(_parent){} GasMapWrapper(QObject* _parent = nullptr): QObject(_parent){}
void push(QString _source, int _start, int _end, QString _value, bool _isInfinite, GasMap::type _type); void push(QString _source, int _start, int _end, QString _value, bool _isInfinite, GasMap::type _type, QString _contractName = "", QString _functionName = "");
bool contains(QString _key); bool contains(QString _key);
void insert(QString _source, QVariantList _variantList); void insert(QString _source, QVariantList _variantList);
QVariantList gasCostsByDocId(QString _source); QVariantList gasCostsByDocId(QString _source);
QVariantList gasCostsBy(QString _contractName, QString _functionName = "");
private: private:
GasCostsMaps m_gasMaps; GasCostsMaps m_gasMaps;
@ -200,6 +210,8 @@ public:
Q_PROPERTY(bool compiling READ isCompiling NOTIFY stateChanged) Q_PROPERTY(bool compiling READ isCompiling NOTIFY stateChanged)
Q_PROPERTY(bool hasContract READ hasContract NOTIFY codeChanged) Q_PROPERTY(bool hasContract READ hasContract NOTIFY codeChanged)
Q_PROPERTY(bool optimizeCode MEMBER m_optimizeCode WRITE setOptimizeCode) Q_PROPERTY(bool optimizeCode MEMBER m_optimizeCode WRITE setOptimizeCode)
Q_PROPERTY(int callStipend READ callStipend)
Q_PROPERTY(int txGas READ txGas)
/// @returns latest compilation results for contracts /// @returns latest compilation results for contracts
QVariantMap contracts() const; QVariantMap contracts() const;
@ -234,7 +246,10 @@ public:
void gasEstimation(solidity::CompilerStack const& _cs); void gasEstimation(solidity::CompilerStack const& _cs);
/// Gas cost by doc id /// Gas cost by doc id
Q_INVOKABLE QVariantList gasCostByDocumentId(QString const& _documentId) const; Q_INVOKABLE QVariantList gasCostByDocumentId(QString const& _documentId) const;
Q_INVOKABLE QVariantList gasCostBy(QString const& _contractName, QString const& _functionName) const;
Q_INVOKABLE void setOptimizeCode(bool _value); Q_INVOKABLE void setOptimizeCode(bool _value);
int txGas() { return static_cast<int>(dev::eth::c_txGas); }
int callStipend() { return static_cast<int>(dev::eth::c_callStipend); }
signals: signals:
/// Emited on compilation state change /// Emited on compilation state change

1
mix/qml/QAddressView.qml

@ -102,7 +102,6 @@ Row
} }
Rectangle { Rectangle {
//anchors.fill: parent
radius: 4 radius: 4
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: 20 height: 20

21
mix/qml/QBoolTypeView.qml

@ -21,16 +21,19 @@ Item
value = value === "true" ? "1" : value value = value === "true" ? "1" : value
value = value === "false" ? "0" : value; value = value === "false" ? "0" : value;
var setValue = "1"
if (value === "") if (value === "")
boolCombo.currentIndex = parseInt(defaultValue); setValue = parseInt(defaultValue);
else else
boolCombo.currentIndex = parseInt(value); setValue = parseInt(value);
boolCombo.checked = setValue === "1" ? true: false
boolCombo.enabled = !readOnly; boolCombo.enabled = !readOnly;
} }
Rectangle { Rectangle {
color: "transparent"
anchors.fill: parent anchors.fill: parent
ComboBox CheckBox
{ {
property bool inited; property bool inited;
Component.onCompleted: Component.onCompleted:
@ -41,17 +44,13 @@ Item
id: boolCombo id: boolCombo
anchors.fill: parent anchors.fill: parent
onCurrentIndexChanged: onCheckedChanged:
{ {
if (inited) if (inited)
value = comboModel.get(currentIndex).value; value = checked ? "1" : "0"
}
model: ListModel
{
id: comboModel
ListElement { text: qsTr("False"); value: "0" }
ListElement { text: qsTr("True"); value: "1" }
} }
text: qsTr("True")
} }
} }
} }

9
mix/qml/StructView.qml

@ -13,14 +13,11 @@ Column
property int transactionIndex property int transactionIndex
property string context property string context
Layout.fillWidth: true Layout.fillWidth: true
spacing: 5 spacing: 15
Repeater Repeater
{ {
id: repeater id: repeater
visible: model.length > 0 visible: model.length > 0
//height: parent.height
RowLayout RowLayout
{ {
id: row id: row
@ -42,7 +39,9 @@ Column
Label { Label {
height: 20 height: 20
id: typeLabel id: typeLabel
text: "(" + modelData.type.name + ")" text: " (" + modelData.type.name + ")"
font.italic: true
font.weight: Font.Light
} }
} }
} }

609
mix/qml/TransactionDialog.qml

@ -7,13 +7,14 @@ import QtQuick.Controls.Styles 1.3
import org.ethereum.qml.QEther 1.0 import org.ethereum.qml.QEther 1.0
import "js/TransactionHelper.js" as TransactionHelper import "js/TransactionHelper.js" as TransactionHelper
import "js/InputValidator.js" as InputValidator import "js/InputValidator.js" as InputValidator
import "js/NetworkDeployment.js" as NetworkDeployment
import "." import "."
Dialog { Dialog {
id: modalTransactionDialog id: modalTransactionDialog
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
width: 630 width: 630
height: 550 height: 500
visible: false visible: false
title: qsTr("Edit Transaction") title: qsTr("Edit Transaction")
property int transactionIndex property int transactionIndex
@ -59,6 +60,7 @@ Dialog {
load(item.isContractCreation, item.isFunctionCall, functionId, contractId) load(item.isContractCreation, item.isFunctionCall, functionId, contractId)
estimatedGas.updateView()
visible = true; visible = true;
} }
@ -273,217 +275,223 @@ Dialog {
contentItem: Rectangle { contentItem: Rectangle {
color: transactionDialogStyle.generic.backgroundColor color: transactionDialogStyle.generic.backgroundColor
anchors.fill: parent anchors.fill: parent
ColumnLayout { ScrollView
width: modalTransactionDialog.width - 30 {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 20 anchors.fill: parent
ColumnLayout {
RowLayout width: modalTransactionDialog.width - 30
{ anchors.horizontalCenter: parent.horizontalCenter
Layout.fillWidth: true anchors.top: parent.top
Rectangle anchors.topMargin: 10
spacing: 10
RowLayout
{ {
Layout.preferredWidth: 150 Layout.fillWidth: true
Label { Rectangle
anchors.right: parent.right {
anchors.verticalCenter: parent.verticalCenter Layout.preferredWidth: 150
text: qsTr("Sender Account") Label {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Sender Account")
}
} }
}
ComboBox { ComboBox {
function select(secret) function select(secret)
{ {
for (var i in model) for (var i in model)
if (model[i].secret === secret) if (model[i].secret === secret)
{ {
currentIndex = i; currentIndex = i;
break; break;
} }
}
Layout.preferredWidth: 350
id: senderComboBox
currentIndex: 0
textRole: "name"
editable: false
} }
Layout.preferredWidth: 350
id: senderComboBox
currentIndex: 0
textRole: "name"
editable: false
} }
}
RowLayout RowLayout
{
Layout.fillWidth: true
Rectangle
{ {
Layout.preferredWidth: 150 Layout.fillWidth: true
Layout.preferredHeight: 80 Rectangle
color: "transparent"
Label
{ {
anchors.verticalCenter: parent.verticalCenter Layout.preferredWidth: 150
anchors.top: parent.top Layout.preferredHeight: 80
anchors.right: parent.right color: "transparent"
text: qsTr("Type of Transaction") Label
{
anchors.verticalCenter: parent.verticalCenter
anchors.top: parent.top
anchors.right: parent.right
text: qsTr("Type of Transaction")
}
} }
}
Column Column
{ {
Layout.preferredWidth: 150 Layout.preferredWidth: 150
Layout.preferredHeight: 90 Layout.preferredHeight: 90
ExclusiveGroup { ExclusiveGroup {
id: rbbuttonList id: rbbuttonList
onCurrentChanged: { onCurrentChanged: {
if (current) if (current)
{
if (current.objectName === "trTypeSend")
{
recipientsAccount.visible = true
contractCreationComboBox.visible = false
modalTransactionDialog.load(false, false)
}
else if (current.objectName === "trTypeCreate")
{
contractCreationComboBox.visible = true
recipientsAccount.visible = false
modalTransactionDialog.load(true, true)
}
else if (current.objectName === "trTypeExecute")
{ {
recipientsAccount.visible = true if (current.objectName === "trTypeSend")
contractCreationComboBox.visible = false {
modalTransactionDialog.load(false, true) recipientsAccount.visible = true
contractCreationComboBox.visible = false
modalTransactionDialog.load(false, false)
}
else if (current.objectName === "trTypeCreate")
{
contractCreationComboBox.visible = true
recipientsAccount.visible = false
modalTransactionDialog.load(true, true)
}
else if (current.objectName === "trTypeExecute")
{
recipientsAccount.visible = true
contractCreationComboBox.visible = false
modalTransactionDialog.load(false, true)
}
} }
} }
} }
}
RadioButton { RadioButton {
id: trTypeSend id: trTypeSend
objectName: "trTypeSend" objectName: "trTypeSend"
exclusiveGroup: rbbuttonList exclusiveGroup: rbbuttonList
height: 30 height: 30
text: qsTr("Send ether to account") text: qsTr("Send ether to account")
} }
RadioButton { RadioButton {
id: trTypeCreate id: trTypeCreate
objectName: "trTypeCreate" objectName: "trTypeCreate"
exclusiveGroup: rbbuttonList exclusiveGroup: rbbuttonList
height: 30 height: 30
text: qsTr("Create Contract") text: qsTr("Create Contract")
} }
RadioButton { RadioButton {
id: trTypeExecute id: trTypeExecute
objectName: "trTypeExecute" objectName: "trTypeExecute"
exclusiveGroup: rbbuttonList exclusiveGroup: rbbuttonList
height: 30 height: 30
text: qsTr("Execute Contract") text: qsTr("Execute Contract")
}
} }
} }
}
RowLayout RowLayout
{
Layout.fillWidth: true
Rectangle
{ {
Layout.preferredWidth: 150 Layout.fillWidth: true
Label { Rectangle
id: labelRecipient {
anchors.verticalCenter: parent.verticalCenter Layout.preferredWidth: 150
anchors.right: parent.right Label {
text: qsTr("Recipient Account") id: labelRecipient
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
text: qsTr("Recipient Account")
}
} }
}
QAddressView QAddressView
{
id: recipientsAccount
displayInput: false
onIndexChanged:
{ {
if (rbbuttonList.current.objectName === "trTypeExecute") id: recipientsAccount
loadFunctions(contractFromToken(currentValue())) displayInput: false
onIndexChanged:
{
if (rbbuttonList.current.objectName === "trTypeExecute")
loadFunctions(contractFromToken(currentValue()))
}
} }
}
ComboBox { ComboBox {
id: contractCreationComboBox id: contractCreationComboBox
function currentValue() { function currentValue() {
return (currentIndex >=0 && currentIndex < contractsModel.count) ? contractsModel.get(currentIndex).cid : ""; return (currentIndex >=0 && currentIndex < contractsModel.count) ? contractsModel.get(currentIndex).cid : "";
} }
Layout.preferredWidth: 350 Layout.preferredWidth: 350
currentIndex: -1 currentIndex: -1
textRole: "text" textRole: "text"
editable: false editable: false
model: ListModel { model: ListModel {
id: contractsModel id: contractsModel
} }
onCurrentIndexChanged: { onCurrentIndexChanged: {
loadCtorParameters(currentValue()); loadCtorParameters(currentValue());
}
} }
} }
}
RowLayout RowLayout
{
Layout.fillWidth: true
Rectangle
{ {
Layout.preferredWidth: 150 Layout.fillWidth: true
id: functionRect Rectangle
function hide()
{ {
functionRect.visible = false Layout.preferredWidth: 150
functionComboBox.visible = false id: functionRect
}
function show() function hide()
{ {
functionRect.visible = true functionRect.visible = false
functionComboBox.visible = true functionComboBox.visible = false
} }
Label { function show()
anchors.verticalCenter: parent.verticalCenter {
anchors.right: parent.right functionRect.visible = true
text: qsTr("Function") functionComboBox.visible = true
} }
}
ComboBox { Label {
id: functionComboBox anchors.verticalCenter: parent.verticalCenter
Layout.preferredWidth: 350 anchors.right: parent.right
currentIndex: -1 text: qsTr("Function")
textRole: "text" }
editable: false
model: ListModel {
id: functionsModel
} }
onCurrentIndexChanged: {
loadParameters(); ComboBox {
id: functionComboBox
Layout.preferredWidth: 350
currentIndex: -1
textRole: "text"
editable: false
model: ListModel {
id: functionsModel
}
onCurrentIndexChanged: {
loadParameters();
}
} }
} }
}
RowLayout RowLayout
{
Layout.fillWidth: true
ScrollView
{ {
id: paramScroll id: paramScroll
anchors.topMargin: 10
Layout.fillWidth: true Layout.fillWidth: true
function updateView() function updateView()
{ {
paramScroll.height = paramsModel.length < 4 ? paramsModel.length * 20 : 145 paramScroll.visible = paramsModel.length > 0
paramScroll.parent.Layout.preferredHeight = paramsModel.length < 4 ? paramsModel.length * 20 : 145 typeLoader.visible = paramsModel.length > 0
paramScroll.visible = paramsModel.length !== 0 paramScroll.height = paramsModel.length < 6 ? paramsModel.length * 30 : 190
typeLoader.height = paramsModel.length < 6 ? paramsModel.length * 30 : 190
if (paramsModel.length === 0)
{
paramScroll.height = 0
typeLoader.height = 0
}
} }
StructView StructView
@ -495,135 +503,212 @@ Dialog {
context: "parameter" context: "parameter"
} }
} }
}
RowLayout RowLayout
{
Layout.fillWidth: true
Rectangle
{ {
Layout.preferredWidth: 150 Layout.fillWidth: true
Label { Rectangle
id: amountLabel {
anchors.verticalCenter: parent.verticalCenter Layout.preferredWidth: 150
anchors.right: parent.right Label {
text: qsTr("Amount") id: amountLabel
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
text: qsTr("Amount")
}
} }
}
Ether { Ether {
id: valueField id: valueField
edit: true edit: true
displayFormattedValue: true displayFormattedValue: false
displayUnitSelection: true
}
} }
}
Rectangle
{
color: "#cccccc"
height: 1
Layout.fillWidth: true
}
Rectangle Rectangle
{ {
width: parent.width Layout.preferredHeight: 30
height: 20 Layout.fillWidth: true
color: "transparent" color: "transparent"
Label { Rectangle
text: qsTr("Transaction fees") {
anchors.horizontalCenter: parent.horizontalCenter color: "#cccccc"
height: 1
width: parent.width
anchors.verticalCenter: parent.verticalCenter
}
} }
}
RowLayout
{
Layout.fillWidth: true
Rectangle Rectangle
{ {
Layout.preferredWidth: 150 width: parent.width
height: 20
color: "transparent"
Label { Label {
anchors.verticalCenter: parent.verticalCenter text: qsTr("Transaction fees")
anchors.right: parent.right anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Gas")
} }
} }
Row RowLayout
{ {
DefaultTextField Layout.fillWidth: true
Layout.preferredHeight: 40
Rectangle
{ {
property variant gasValue Layout.preferredWidth: 150
onGasValueChanged: text = gasValue.value(); Label {
onTextChanged: gasValue.setValue(text); anchors.verticalCenter: parent.verticalCenter
implicitWidth: 200 anchors.right: parent.right
enabled: !gasAutoCheck.checked text: qsTr("Gas")
id: gasValueEdit; }
} }
CheckBox Row
{ {
id: gasAutoCheck DefaultTextField
checked: true {
text: qsTr("Auto"); property variant gasValue
onGasValueChanged: text = gasValue.value();
onTextChanged: gasValue.setValue(text);
implicitWidth: 200
enabled: !gasAutoCheck.checked
id: gasValueEdit;
Label
{
id: estimatedGas
anchors.top: parent.bottom
text: ""
Connections
{
target: functionComboBox
onCurrentIndexChanged:
{
estimatedGas.displayGas(contractFromToken(recipientsAccount.currentValue()), functionComboBox.currentText)
}
}
function displayGas(contractName, functionName)
{
var gasCost = codeModel.gasCostBy(contractName, functionName);
if (gasCost && gasCost.length > 0)
estimatedGas.text = qsTr("Estimated cost: ") + gasCost[0].gas + " gas"
}
function updateView()
{
if (rbbuttonList.current.objectName === "trTypeExecute")
estimatedGas.displayGas(contractFromToken(recipientsAccount.currentValue()), functionComboBox.currentText)
else if (rbbuttonList.current.objectName === "trTypeCreate")
{
var contractName = contractCreationComboBox.currentValue()
estimatedGas.displayGas(contractName, contractName)
}
else if (rbbuttonList.current.objectName === "trTypeSend")
{
var gas = codeModel.txGas + codeModel.callStipend
estimatedGas.text = qsTr("Estimated cost: ") + gas + " gas"
}
}
Connections
{
target: rbbuttonList
onCurrentChanged: {
estimatedGas.updateView()
}
}
}
}
CheckBox
{
id: gasAutoCheck
checked: true
text: qsTr("Auto");
}
} }
} }
}
RowLayout RowLayout
{
Layout.fillWidth: true
Rectangle
{ {
Layout.preferredWidth: 150 Layout.fillWidth: true
Label { Layout.preferredHeight: 40
anchors.verticalCenter: parent.verticalCenter Rectangle
anchors.right: parent.right {
text: qsTr("Gas Price") Layout.preferredWidth: 150
Label {
id: gasPriceLabel
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
text: qsTr("Gas Price")
}
Label {
id: gasPriceMarket
anchors.top: gasPriceLabel.bottom
Component.onCompleted:
{
NetworkDeployment.gasPrice(function(result)
{
gasPriceMarket.text = qsTr("Current market: ") + " " + result + " Wei";
}, function (){});
}
}
} }
}
Ether { Ether {
id: gasPriceField id: gasPriceField
edit: true edit: true
displayFormattedValue: true displayFormattedValue: false
displayUnitSelection: true
}
} }
}
RowLayout RowLayout
{ {
anchors.bottom: parent.bottom anchors.right: parent.right
anchors.right: parent.right;
Button {
Button { text: qsTr("Cancel");
text: qsTr("OK"); onClicked: close();
onClicked: { }
var invalid = InputValidator.validate(paramsModel, paramValues);
if (invalid.length === 0) Button {
{ text: qsTr("Update");
close(); onClicked: {
accepted(); var invalid = InputValidator.validate(paramsModel, paramValues);
} if (invalid.length === 0)
else {
{ close();
errorDialog.text = qsTr("Some parameters are invalid:\n"); accepted();
for (var k in invalid) }
errorDialog.text += invalid[k].message + "\n"; else
errorDialog.open(); {
errorDialog.text = qsTr("Some parameters are invalid:\n");
for (var k in invalid)
errorDialog.text += invalid[k].message + "\n";
errorDialog.open();
}
} }
} }
}
Button {
text: qsTr("Cancel"); MessageDialog {
onClicked: close(); id: errorDialog
standardButtons: StandardButton.Ok
icon: StandardIcon.Critical
}
} }
MessageDialog { RowLayout
id: errorDialog {
standardButtons: StandardButton.Ok anchors.bottom: parent.bottom
icon: StandardIcon.Critical Layout.preferredHeight: 20
} }
} }
} }

6
mix/qml/js/NetworkDeployment.js

@ -201,7 +201,7 @@ function executeTrNextStep(trIndex, state, ctrAddresses, callBack)
callBack(); callBack();
} }
function gasPrice(callBack) function gasPrice(callBack, error)
{ {
var requests = [{ var requests = [{
jsonrpc: "2.0", jsonrpc: "2.0",
@ -210,7 +210,9 @@ function gasPrice(callBack)
id: jsonRpcRequestId id: jsonRpcRequestId
}]; }];
rpcCall(requests, function (httpCall, response){ rpcCall(requests, function (httpCall, response){
callBack(JSON.parse(response)[0].result); callBack(JSON.parse(response)[0].result)
}, function(message){
error(message)
}); });
} }

4
mix/qml/js/TransactionHelper.js

@ -17,7 +17,7 @@ function defaultTransaction()
}; };
} }
function rpcCall(requests, callBack) function rpcCall(requests, callBack, error)
{ {
var jsonRpcUrl = "http://localhost:8545"; var jsonRpcUrl = "http://localhost:8545";
var rpcRequest = JSON.stringify(requests); var rpcRequest = JSON.stringify(requests);
@ -33,7 +33,7 @@ function rpcCall(requests, callBack)
{ {
var errorText = qsTr("Unable to initiate request to the live network. Please verify your ethereum node is up.") + qsTr(" Error status: ") + httpRequest.status; var errorText = qsTr("Unable to initiate request to the live network. Please verify your ethereum node is up.") + qsTr(" Error status: ") + httpRequest.status;
console.log(errorText); console.log(errorText);
deploymentError(errorText); error(errorText);
} }
else else
{ {

Loading…
Cancel
Save