Browse Source

deploy dialog UX changes

cl-refactor
yann300 10 years ago
parent
commit
631f12e6c4
  1. 76
      mix/qml/DeployContractStep.qml
  2. 2
      mix/qml/DeploymentDialog.qml
  3. 1
      mix/qml/DeploymentWorker.qml
  4. 31
      mix/qml/PackagingStep.qml
  5. 80
      mix/qml/RegisteringStep.qml
  6. 14
      mix/qml/TransactionDialog.qml
  7. 32
      mix/qml/js/NetworkDeployment.js
  8. 15
      mix/qml/js/ProjectModel.js

76
mix/qml/DeployContractStep.qml

@ -2,6 +2,7 @@ import QtQuick 2.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.3 import QtQuick.Controls.Styles 1.3
import Qt.labs.settings 1.0
import "js/TransactionHelper.js" as TransactionHelper import "js/TransactionHelper.js" as TransactionHelper
import "js/NetworkDeployment.js" as NetworkDeploymentCode import "js/NetworkDeployment.js" as NetworkDeploymentCode
import "js/QEtherHelper.js" as QEtherHelper import "js/QEtherHelper.js" as QEtherHelper
@ -10,10 +11,13 @@ import org.ethereum.qml.QEther 1.0
Rectangle { Rectangle {
property variant paramsModel: [] property variant paramsModel: []
property variant worker property variant worker
property variant gas: []
color: "#E3E3E3E3" color: "#E3E3E3E3"
anchors.fill: parent anchors.fill: parent
id: root id: root
property int labelWidth: 150
function show() function show()
{ {
visible = true visible = true
@ -26,6 +30,7 @@ Rectangle {
} }
if (worker.accounts.length > 0) if (worker.accounts.length > 0)
worker.currentAccount = worker.accounts[0].id worker.currentAccount = worker.accounts[0].id
deployedAddresses.refresh()
} }
RowLayout RowLayout
@ -201,7 +206,7 @@ Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
Rectangle Rectangle
{ {
width: 100 width: labelWidth
Label Label
{ {
text: qsTr("Account") text: qsTr("Account")
@ -228,7 +233,7 @@ Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
Rectangle Rectangle
{ {
width: 100 width: labelWidth
Label Label
{ {
text: qsTr("Gas Price") text: qsTr("Gas Price")
@ -289,6 +294,7 @@ Rectangle {
worker.estimateGas(sce, function(gas) { worker.estimateGas(sce, function(gas) {
if (gasPriceLoad.loaded) if (gasPriceLoad.loaded)
{ {
root.gas = gas
cost = 0 cost = 0
for (var k in gas) for (var k in gas)
{ {
@ -308,7 +314,7 @@ Rectangle {
Rectangle Rectangle
{ {
width: 100 width: labelWidth
Label Label
{ {
text: qsTr("Cost Estimate") text: qsTr("Cost Estimate")
@ -327,7 +333,66 @@ Rectangle {
} }
} }
RowLayout
{
id: deployedRow
Layout.fillWidth: true
Rectangle
{
width: labelWidth
Label
{
id: labelAddresses
text: qsTr("Deployed Addresses")
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}
ColumnLayout
{
ListModel
{
id: deployedAddrModel
}
Repeater
{
id: deployedAddresses
model: deployedAddrModel
function refresh()
{
deployedAddrModel.clear()
deployedRow.visible = Object.keys(projectModel.deploymentAddresses).length > 0
for (var k in projectModel.deploymentAddresses)
{
deployedAddrModel.append({ id: k, value: projectModel.deploymentAddresses[k]})
}
}
Rectangle
{
Layout.preferredHeight: 20
Layout.preferredWidth: 235
color: "transparent"
Label
{
id: labelContract
width: 110
elide: Text.ElideRight
text: index > -1 ? deployedAddrModel.get(index).id : ""
}
TextField
{
anchors.left: labelContract.right
text: index > - 1 ? deployedAddrModel.get(index).value : ""
}
}
}
}
}
} }
Rectangle Rectangle
@ -341,7 +406,10 @@ Rectangle {
onClicked: onClicked:
{ {
projectModel.deployedScenarioIndex = contractList.currentIndex projectModel.deployedScenarioIndex = contractList.currentIndex
NetworkDeploymentCode.deployContracts(); NetworkDeploymentCode.deployContracts(root.gas, function(addresses)
{
deployedAddresses.refresh()
});
} }
} }
} }

2
mix/qml/DeploymentDialog.qml

@ -14,7 +14,7 @@ import "."
Dialog { Dialog {
id: modalDeploymentDialog id: modalDeploymentDialog
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
width: 800 width: 850
height: 450 height: 450
visible: false visible: false

1
mix/qml/DeploymentWorker.qml

@ -61,7 +61,6 @@ Item
NetworkDeploymentCode.gasPrice(function(price) { NetworkDeploymentCode.gasPrice(function(price) {
gasPrice = price; gasPrice = price;
gasPriceInt.setValue(price); gasPriceInt.setValue(price);
console.log("fjdsfkjds hfkdsf " + price)
gasPriceLoaded() gasPriceLoaded()
}, function(){}); }, function(){});
} }

31
mix/qml/PackagingStep.qml

@ -13,18 +13,14 @@ Rectangle {
property variant worker property variant worker
color: "#E3E3E3E3" color: "#E3E3E3E3"
anchors.fill: parent anchors.fill: parent
id: root
property string packageHash property string packageHash
property string packageBase64 property string packageBase64
property alias localPackageUrl: localPackageUrl.text property alias localPackageUrl: localPackageUrl.text
property alias lastDeployDate: lastDeployLabel.text
property string deploymentId property string deploymentId
property string packageDir property string packageDir
Settings {
property alias localUrl: localPackageUrl.text
}
function show() function show()
{ {
visible = true visible = true
@ -100,16 +96,35 @@ Rectangle {
Rectangle Rectangle
{ {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 20 Layout.preferredHeight: 40
color: "transparent" color: "transparent"
Button Button
{ {
id: generatePackageBtn
Layout.preferredWidth: 200 Layout.preferredWidth: 200
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Generate Package") text: qsTr("Generate Package")
onClicked: onClicked:
{ {
NetworkDeploymentCode.packageDapp(projectModel.deploymentAddresses) NetworkDeploymentCode.packageDapp(projectModel.deploymentAddresses);
}
}
RowLayout
{
anchors.top: generatePackageBtn.bottom
anchors.topMargin: 10
visible: root.lastDeployDate !== ""
anchors.horizontalCenter: parent.horizontalCenter
Label
{
id: lastPackage
text: qsTr("Last Package")
}
Label
{
id: lastDeployLabel
} }
} }
} }

80
mix/qml/RegisteringStep.qml

@ -11,8 +11,8 @@ import "."
Rectangle { Rectangle {
property variant worker property variant worker
property alias applicationUrlEth: applicationUrlEth.text property string applicationUrlEth
property alias applicationUrlHttp: applicationUrlHttp.text property string applicationUrlHttp
property string eth: registrarAddr.text property string eth: registrarAddr.text
property int ownedRegistrarDeployGas: 1179075 // TODO: Use sol library to calculate gas requirement for each tr. property int ownedRegistrarDeployGas: 1179075 // TODO: Use sol library to calculate gas requirement for each tr.
property int ownedRegistrarSetSubRegistrarGas: 50000 property int ownedRegistrarSetSubRegistrarGas: 50000
@ -25,16 +25,11 @@ Rectangle {
function show() function show()
{ {
ctrRegisterLabel.calculateRegisterGas() ctrRegisterLabel.calculateRegisterGas()
applicationUrlEthCtrl.text = applicationUrlEth
applicationUrlHttp.text = applicationUrlHttp
visible = true visible = true
} }
Settings
{
id: settings
property alias ethUrl: applicationUrlEth.text
property string httpUrl: applicationUrlHttp.text
}
ColumnLayout ColumnLayout
{ {
anchors.top: parent.top anchors.top: parent.top
@ -69,7 +64,7 @@ Rectangle {
DefaultTextField DefaultTextField
{ {
id: registrarAddr id: registrarAddr
text: "bb9af5b8f19fb2bc1765ca36e697fa30e3386b71" //"c6d9d2cd449a754c494264e1809c50e34d64562b" text: "31e316dace244c1efb93c565eb1974ff8efbdefe" //"c6d9d2cd449a754c494264e1809c50e34d64562b"
visible: true visible: true
Layout.preferredWidth: 235 Layout.preferredWidth: 235
} }
@ -92,8 +87,7 @@ Rectangle {
DefaultTextField DefaultTextField
{ {
id: applicationUrlHttp id: applicationUrlHttpCtrl
enabled: rowRegister.isOkToRegister()
Layout.preferredWidth: 235 Layout.preferredWidth: 235
} }
} }
@ -160,7 +154,7 @@ Rectangle {
DefaultTextField DefaultTextField
{ {
width: 235 width: 235
id: applicationUrlEth id: applicationUrlEthCtrl
onTextChanged: { onTextChanged: {
ctrRegisterLabel.calculateRegisterGas(); ctrRegisterLabel.calculateRegisterGas();
} }
@ -194,34 +188,44 @@ Rectangle {
width: 30 width: 30
onClicked: onClicked:
{ {
var inError = []; if (applicationUrlEthCtrl.text !== applicationUrlEth)
var ethUrl = NetworkDeploymentCode.formatAppUrl(applicationUrlEth.text);
for (var k in ethUrl)
{ {
if (ethUrl[k].length > 32) var inError = [];
inError.push(qsTr("Member too long: " + ethUrl[k]) + "\n"); var ethUrl = NetworkDeploymentCode.formatAppUrl(applicationUrlEth.text);
for (var k in ethUrl)
{
if (ethUrl[k].length > 32)
inError.push(qsTr("Member too long: " + ethUrl[k]) + "\n");
}
if (!worker.stopForInputError(inError))
{
NetworkDeploymentCode.registerDapp(function(){
})
}
} }
if (!worker.stopForInputError(inError))
if (applicationUrlHttpCtrl.text !== applicationUrlHttp)
{ {
NetworkDeploymentCode.registerDapp(function(){ if (!(ethUrl.length === 1 && ethUrl[0] === projectModel.projectTitle))
applicationUrlEth.text = ethUrl {
if (applicationUrlHttp.text === "" || deploymentDialog.packageHash === "") applicationUrlEth.text = ethUrl.join('/')
{ }
deployDialog.title = text; if (applicationUrlHttp.text === "" || deploymentDialog.packageHash === "")
deployDialog.text = qsTr("Please provide the link where the resources are stored and ensure the package is aleary built using the deployment step.") {
deployDialog.open(); deployDialog.title = text;
return; deployDialog.text = qsTr("Please provide the link where the resources are stored and ensure the package is aleary built using the deployment step.")
} deployDialog.open();
var inError = []; return;
if (applicationUrlHttp.text.length > 32) }
inError.push(qsTr(applicationUrlHttp.text)); var inError = [];
if (!worker.stopForInputError(inError)) if (applicationUrlHttp.text.length > 32)
{ inError.push(qsTr(applicationUrlHttp.text));
/*registerToUrlHint(function(){ if (!worker.stopForInputError(inError))
settings.httpUrl = applicationUrlHttp.text {
})*/ registerToUrlHint(function(){
} })
}) }
} }
} }
} }

14
mix/qml/TransactionDialog.qml

@ -127,7 +127,7 @@ Dialog {
if (functionComboBox.currentIndex >= 0 && functionComboBox.currentIndex < functionsModel.count) { if (functionComboBox.currentIndex >= 0 && functionComboBox.currentIndex < functionsModel.count) {
var contract = codeModel.contracts[TransactionHelper.contractFromToken(contractCreationComboBox.currentValue())]; var contract = codeModel.contracts[TransactionHelper.contractFromToken(contractCreationComboBox.currentValue())];
if (contract) { if (contract) {
var func = contract.contract.functions[functionComboBox.currentIndex /*+ 1*/]; var func = getFunction(functionComboBox.currentText, contract);
if (func) { if (func) {
var parameters = func.parameters; var parameters = func.parameters;
for (var p = 0; p < parameters.length; p++) for (var p = 0; p < parameters.length; p++)
@ -138,6 +138,18 @@ Dialog {
initTypeLoader(); initTypeLoader();
} }
function getFunction(name, contract)
{
for (var k in contract.contract.functions)
{
if (contract.contract.functions[k].name === name)
{
return contract.contract.functions[k]
}
}
return null
}
function initTypeLoader() function initTypeLoader()
{ {
paramScroll.value = {} paramScroll.value = {}

32
mix/qml/js/NetworkDeployment.js

@ -32,8 +32,9 @@ function deployProject(force) {
deploymentDialog.open(); deploymentDialog.open();
} }
function deployContracts() function deployContracts(gas, callback)
{ {
deploymentGas = gas;
var jsonRpcUrl = "http://127.0.0.1:8080"; var jsonRpcUrl = "http://127.0.0.1:8080";
console.log("Deploying to " + jsonRpcUrl); console.log("Deploying to " + jsonRpcUrl);
deploymentStarted(); deploymentStarted();
@ -50,6 +51,8 @@ function deployContracts()
executeTr(0, 0, state, ctrAddresses, function(){ executeTr(0, 0, state, ctrAddresses, function(){
projectModel.deploymentAddresses = ctrAddresses; projectModel.deploymentAddresses = ctrAddresses;
deploymentStepChanged(qsTr("Scenario deployed. Please wait for verifications")) deploymentStepChanged(qsTr("Scenario deployed. Please wait for verifications"))
if (callback)
callback(ctrAddresses)
}); });
} }
@ -135,16 +138,18 @@ function getFunction(ctrName, functionId)
} }
} }
var deploymentGas
var trRealIndex = -1
function executeTr(blockIndex, trIndex, state, ctrAddresses, callBack) function executeTr(blockIndex, trIndex, state, ctrAddresses, callBack)
{ {
trRealIndex++;
var tr = state.blocks.get(blockIndex).transactions.get(trIndex); var tr = state.blocks.get(blockIndex).transactions.get(trIndex);
var func = getFunction(tr.contractId, tr.functionId); var func = getFunction(tr.contractId, tr.functionId);
console.log(func + " " + tr.contractId + " " + tr.functionId + " ")
if (!func) if (!func)
executeTrNextStep(blockIndex, trIndex, state, ctrAddresses, callBack); executeTrNextStep(blockIndex, trIndex, state, ctrAddresses, callBack);
else else
{ {
var gasCost = clientModel.toHex(clientModel.gasCosts[trIndex]); var gasCost = clientModel.toHex(deploymentGas[trRealIndex]);
var rpcParams = { "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost }; var rpcParams = { "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost };
var params = replaceParamToken(func.parameters, tr.parameters, ctrAddresses); var params = replaceParamToken(func.parameters, tr.parameters, ctrAddresses);
var encodedParams = clientModel.encodeParams(params, contractFromToken(tr.contractId), tr.functionId); var encodedParams = clientModel.encodeParams(params, contractFromToken(tr.contractId), tr.functionId);
@ -223,6 +228,15 @@ function packageDapp(addresses)
deploymentStepChanged(qsTr("Packaging application ...")); deploymentStepChanged(qsTr("Packaging application ..."));
var deploymentDir = projectPath + deploymentId + "/"; var deploymentDir = projectPath + deploymentId + "/";
if (deploymentDialog.packageStep.packageDir !== "")
deploymentDir = deploymentDialog.packageStep.packageDir
else
{
deploymentDir = projectPath + "package/"
fileIo.makeDir(deploymentDir);
}
projectModel.deploymentDir = deploymentDir; projectModel.deploymentDir = deploymentDir;
fileIo.makeDir(deploymentDir); fileIo.makeDir(deploymentDir);
for (var i = 0; i < projectListModel.count; i++) { for (var i = 0; i < projectListModel.count; i++) {
@ -263,24 +277,18 @@ function packageDapp(addresses)
deploymentAddresses = addresses; deploymentAddresses = addresses;
saveProject(); saveProject();
if (deploymentDialog.packageStep.packageDir !== "")
deploymentDir = deploymentDialog.packageStep.packageDir
else
{
deploymentDir = projectPath + "package/"
fileIo.makeDir(deploymentDir);
}
var packageRet = fileIo.makePackage(deploymentDir); var packageRet = fileIo.makePackage(deploymentDir);
deploymentDialog.packageStep.packageHash = packageRet[0]; deploymentDialog.packageStep.packageHash = packageRet[0];
deploymentDialog.packageStep.packageBase64 = packageRet[1]; deploymentDialog.packageStep.packageBase64 = packageRet[1];
deploymentDialog.packageStep.localPackageUrl = packageRet[2] + "?hash=" + packageRet[0]; deploymentDialog.packageStep.localPackageUrl = packageRet[2] + "?hash=" + packageRet[0];
deploymentDialog.packageStep.lastDeployDate = date
deploymentComplete() deploymentComplete()
} }
function registerDapp(callback) function registerDapp(callback)
{ {
var applicationUrlEth = deploymentDialog.registerStep.applicationUrlEth; var applicationUrlEth = deploymentDialog.registerStep.applicationUrlEth;
projectModel.deploymentEthUrl = applicationUrlEth
applicationUrlEth = formatAppUrl(applicationUrlEth); applicationUrlEth = formatAppUrl(applicationUrlEth);
deploymentStepChanged(qsTr("Registering application on the Ethereum network ...")); deploymentStepChanged(qsTr("Registering application on the Ethereum network ..."));
checkEthPath(applicationUrlEth, false, function (success) { checkEthPath(applicationUrlEth, false, function (success) {
@ -512,7 +520,7 @@ function registerContentHash(registrar, callBack)
function registerToUrlHint(callback) function registerToUrlHint(callback)
{ {
deploymentStepChanged(qsTr("Registering application Resources (" + deploymentDialog.registerStep.applicationUrlHttp) + ") ..."); deploymentStepChanged(qsTr("Registering application Resources (" + deploymentDialog.registerStep.applicationUrlHttp) + ") ...");
projectModel.deploymentHttpUrl = deploymentDialog.registerStep.applicationUrlHttp
urlHintAddress(function(urlHint){ urlHintAddress(function(urlHint){
var requests = []; var requests = [];
var paramUrlHttp = clientModel.encodeStringParam(deploymentDialog.registerStep.applicationUrlHttp); var paramUrlHttp = clientModel.encodeStringParam(deploymentDialog.registerStep.applicationUrlHttp);

15
mix/qml/js/ProjectModel.js

@ -74,11 +74,12 @@ function saveProjectFile()
files: [], files: [],
title: projectTitle, title: projectTitle,
deploymentAddresses: deploymentAddresses, deploymentAddresses: deploymentAddresses,
applicationUrlEth: deploymentDialog.applicationUrlEth, applicationUrlEth: deploymentDialog.registerStep.applicationUrlEth,
applicationUrlHttp: deploymentDialog.applicationUrlHttp, applicationUrlHttp: deploymentDialog.registerStep.applicationUrlHttp,
packageHash: deploymentDialog.packageHash, packageHash: deploymentDialog.packageStep.packageHash,
packageBase64: deploymentDialog.packageBase64, packageBase64: deploymentDialog.packageStep.packageBase64,
deploymentDir: projectModel.deploymentDir deploymentDir: deploymentDialog.packageStep.packageDir,
lastPackageDate: deploymentDialog.packageStep.lastDeployDate
}; };
for (var i = 0; i < projectListModel.count; i++) for (var i = 0; i < projectListModel.count; i++)
projectData.files.push({ projectData.files.push({
@ -114,11 +115,13 @@ function loadProject(path) {
deploymentDialog.registerStep.applicationUrlEth = projectData.applicationUrlEth deploymentDialog.registerStep.applicationUrlEth = projectData.applicationUrlEth
if (projectData.applicationUrlHttp) if (projectData.applicationUrlHttp)
deploymentDialog.registerStep.applicationUrlHttp = projectData.applicationUrlHttp deploymentDialog.registerStep.applicationUrlHttp = projectData.applicationUrlHttp
if (projectData.lastPackageDate)
deploymentDialog.packageStep.lastDeployDate = projectData.lastPackageDate
if (!projectData.title) { if (!projectData.title) {
var parts = path.split("/"); var parts = path.split("/");
projectData.title = parts[parts.length - 2]; projectData.title = parts[parts.length - 2];
} }
deploymentAddresses = projectData.deploymentAddresses ? projectData.deploymentAddresses : []; deploymentAddresses = projectData.deploymentAddresses ? projectData.deploymentAddresses : {};
projectTitle = projectData.title; projectTitle = projectData.title;
projectPath = path; projectPath = path;
if (!projectData.files) if (!projectData.files)

Loading…
Cancel
Save