|
@ -3,6 +3,7 @@ import QtQuick.Controls 1.1 |
|
|
import QtQuick.Layouts 1.1 |
|
|
import QtQuick.Layouts 1.1 |
|
|
import QtQuick.Window 2.0 |
|
|
import QtQuick.Window 2.0 |
|
|
import org.ethereum.qml.QEther 1.0 |
|
|
import org.ethereum.qml.QEther 1.0 |
|
|
|
|
|
import "js/TransactionHelper.js" as TransactionHelper |
|
|
|
|
|
|
|
|
Window { |
|
|
Window { |
|
|
id: modalTransactionDialog |
|
|
id: modalTransactionDialog |
|
@ -18,15 +19,29 @@ Window { |
|
|
property alias transactionValue: valueField.value; |
|
|
property alias transactionValue: valueField.value; |
|
|
property alias functionId: functionComboBox.currentText; |
|
|
property alias functionId: functionComboBox.currentText; |
|
|
property var itemParams; |
|
|
property var itemParams; |
|
|
|
|
|
property bool isConstructorTransaction; |
|
|
|
|
|
property bool useTransactionDefaultValue: false |
|
|
|
|
|
|
|
|
signal accepted; |
|
|
signal accepted; |
|
|
|
|
|
|
|
|
function open(index, item) { |
|
|
function open(index, item) { |
|
|
|
|
|
valueLabel.visible = !useTransactionDefaultValue; |
|
|
|
|
|
valueField.visible = !useTransactionDefaultValue; |
|
|
|
|
|
gasLabel.visible = !useTransactionDefaultValue; |
|
|
|
|
|
gasFieldRect.visible = !useTransactionDefaultValue; |
|
|
|
|
|
gasPriceLabel.visible = !useTransactionDefaultValue; |
|
|
|
|
|
gasPriceRect.visible = !useTransactionDefaultValue; |
|
|
|
|
|
|
|
|
transactionIndex = index; |
|
|
transactionIndex = index; |
|
|
gasField.value = item.gas; |
|
|
gasField.value = item.gas; |
|
|
gasPriceField.value = item.gasPrice; |
|
|
gasPriceField.value = item.gasPrice; |
|
|
valueField.value = item.value; |
|
|
valueField.value = item.value; |
|
|
var functionId = item.functionId; |
|
|
var functionId = item.functionId; |
|
|
|
|
|
isConstructorTransaction = item.executeConstructor; |
|
|
|
|
|
functionLabel.visible = !item.executeConstructor; |
|
|
|
|
|
functionComboBox.visible = !item.executeConstructor; |
|
|
|
|
|
console.log(item.executeConstructor); |
|
|
|
|
|
|
|
|
itemParams = item.parameters !== undefined ? item.parameters : {}; |
|
|
itemParams = item.parameters !== undefined ? item.parameters : {}; |
|
|
functionsModel.clear(); |
|
|
functionsModel.clear(); |
|
|
var functionIndex = -1; |
|
|
var functionIndex = -1; |
|
@ -41,7 +56,18 @@ Window { |
|
|
functionIndex = 0; //@todo suggest unused funtion |
|
|
functionIndex = 0; //@todo suggest unused funtion |
|
|
|
|
|
|
|
|
functionComboBox.currentIndex = functionIndex; |
|
|
functionComboBox.currentIndex = functionIndex; |
|
|
|
|
|
paramsModel.clear(); |
|
|
|
|
|
if (!item.executeConstructor) |
|
|
loadParameters(); |
|
|
loadParameters(); |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
console.log("load ctro paramters"); |
|
|
|
|
|
var parameters = codeModel.code.contract.constructor.parameters; |
|
|
|
|
|
for (var p = 0; p < parameters.length; p++) { |
|
|
|
|
|
var pname = parameters[p].name; |
|
|
|
|
|
paramsModel.append({ name: pname, type: parameters[p].type, value: itemParams[pname] !== undefined ? itemParams[pname].value() : "" }); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
visible = true; |
|
|
visible = true; |
|
|
valueField.focus = true; |
|
|
valueField.focus = true; |
|
|
} |
|
|
} |
|
@ -49,7 +75,6 @@ Window { |
|
|
function loadParameters() { |
|
|
function loadParameters() { |
|
|
if (!paramsModel) |
|
|
if (!paramsModel) |
|
|
return; |
|
|
return; |
|
|
paramsModel.clear(); |
|
|
|
|
|
if (functionComboBox.currentIndex >= 0 && functionComboBox.currentIndex < functionsModel.count) { |
|
|
if (functionComboBox.currentIndex >= 0 && functionComboBox.currentIndex < functionsModel.count) { |
|
|
var func = codeModel.code.contract.functions[functionComboBox.currentIndex]; |
|
|
var func = codeModel.code.contract.functions[functionComboBox.currentIndex]; |
|
|
var parameters = func.parameters; |
|
|
var parameters = func.parameters; |
|
@ -67,17 +92,37 @@ Window { |
|
|
|
|
|
|
|
|
function getItem() |
|
|
function getItem() |
|
|
{ |
|
|
{ |
|
|
var item = { |
|
|
var item; |
|
|
|
|
|
if (!useTransactionDefaultValue) |
|
|
|
|
|
{ |
|
|
|
|
|
item = { |
|
|
functionId: transactionDialog.functionId, |
|
|
functionId: transactionDialog.functionId, |
|
|
gas: transactionDialog.gas, |
|
|
gas: transactionDialog.gas, |
|
|
gasPrice: transactionDialog.gasPrice, |
|
|
gasPrice: transactionDialog.gasPrice, |
|
|
value: transactionDialog.transactionValue, |
|
|
value: transactionDialog.transactionValue, |
|
|
parameters: {} |
|
|
parameters: {}, |
|
|
|
|
|
executeConstructor: isConstructorTransaction |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
item = TransactionHelper.defaultTransaction(); |
|
|
|
|
|
item.functionId = transactionDialog.functionId; |
|
|
|
|
|
item.executeConstructor = isConstructorTransaction; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isConstructorTransaction) |
|
|
|
|
|
item.functionId = qsTr("Constructor"); |
|
|
|
|
|
|
|
|
for (var p = 0; p < transactionDialog.transactionParams.count; p++) { |
|
|
for (var p = 0; p < transactionDialog.transactionParams.count; p++) { |
|
|
var parameter = transactionDialog.transactionParams.get(p); |
|
|
var parameter = transactionDialog.transactionParams.get(p); |
|
|
var intComponent = Qt.createComponent("qrc:/qml/BigIntValue.qml"); |
|
|
var intComponent = Qt.createComponent("qrc:/qml/BigIntValue.qml"); |
|
|
var param = intComponent.createObject(modalTransactionDialog); |
|
|
var param = intComponent.createObject(modalTransactionDialog); |
|
|
|
|
|
console.log(param); |
|
|
|
|
|
console.log(JSON.stringify(param)); |
|
|
|
|
|
console.log(item); |
|
|
|
|
|
console.log(JSON.stringify(item)); |
|
|
|
|
|
|
|
|
param.setValue(parameter.value); |
|
|
param.setValue(parameter.value); |
|
|
item.parameters[parameter.name] = param; |
|
|
item.parameters[parameter.name] = param; |
|
|
} |
|
|
} |
|
@ -93,6 +138,7 @@ Window { |
|
|
columnSpacing: 10 |
|
|
columnSpacing: 10 |
|
|
|
|
|
|
|
|
Label { |
|
|
Label { |
|
|
|
|
|
id: functionLabel; |
|
|
text: qsTr("Function") |
|
|
text: qsTr("Function") |
|
|
} |
|
|
} |
|
|
ComboBox { |
|
|
ComboBox { |
|
@ -110,10 +156,12 @@ Window { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Label { |
|
|
Label { |
|
|
|
|
|
id: valueLabel |
|
|
text: qsTr("Value") |
|
|
text: qsTr("Value") |
|
|
} |
|
|
} |
|
|
Rectangle |
|
|
Rectangle |
|
|
{ |
|
|
{ |
|
|
|
|
|
id: valueFieldRect |
|
|
Layout.fillWidth: true |
|
|
Layout.fillWidth: true |
|
|
Ether { |
|
|
Ether { |
|
|
id: valueField |
|
|
id: valueField |
|
@ -123,10 +171,12 @@ Window { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Label { |
|
|
Label { |
|
|
|
|
|
id: gasLabel |
|
|
text: qsTr("Gas") |
|
|
text: qsTr("Gas") |
|
|
} |
|
|
} |
|
|
Rectangle |
|
|
Rectangle |
|
|
{ |
|
|
{ |
|
|
|
|
|
id: gasFieldRect |
|
|
Layout.fillWidth: true |
|
|
Layout.fillWidth: true |
|
|
Ether { |
|
|
Ether { |
|
|
id: gasField |
|
|
id: gasField |
|
@ -136,10 +186,12 @@ Window { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Label { |
|
|
Label { |
|
|
|
|
|
id: gasPriceLabel |
|
|
text: qsTr("Gas price") |
|
|
text: qsTr("Gas price") |
|
|
} |
|
|
} |
|
|
Rectangle |
|
|
Rectangle |
|
|
{ |
|
|
{ |
|
|
|
|
|
id: gasPriceRect |
|
|
Layout.fillWidth: true |
|
|
Layout.fillWidth: true |
|
|
Ether { |
|
|
Ether { |
|
|
id: gasPriceField |
|
|
id: gasPriceField |
|
|