@ -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: 55 0
height: 50 0
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 = tru e
functionRect . visible = fals e
functionComboBox . visible = tru e
functionComboBox . visible = fals e
}
}
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
}
}
}
}
}
}