Browse Source

ui changes

cl-refactor
yann300 10 years ago
parent
commit
bb15b2af75
  1. 36
      mix/qml/DeployContractStep.qml
  2. 9
      mix/qml/DeploymentWorker.qml
  3. 2
      mix/qml/ProjectModel.qml
  4. 18
      mix/qml/RegisteringStep.qml
  5. 24
      mix/qml/js/NetworkDeployment.js

36
mix/qml/DeployContractStep.qml

@ -12,6 +12,7 @@ Rectangle {
property variant paramsModel: []
property variant worker
property variant gas: []
property alias gasPrice: gasPriceInput
color: "#E3E3E3E3"
signal deployed
anchors.fill: parent
@ -31,7 +32,11 @@ Rectangle {
}
if (worker.accounts.length > 0)
{
worker.currentAccount = worker.accounts[0].id
accountsList.currentIndex = 0
}
if (projectModel.deployBlockNumber !== -1)
{
@ -47,6 +52,8 @@ Rectangle {
function updateVerification(blockNumber, trLost)
{
var nb = parseInt(blockNumber - projectModel.deployBlockNumber)
verificationTextArea.visible = false
verificationLabel.visible = true
if (nb >= 10)
{
verificationLabel.text = qsTr("contracts deployment verified")
@ -57,12 +64,14 @@ Rectangle {
verificationLabel.text = nb
if (trLost.length > 0)
{
verificationTextArea.visible = true
verificationLabel.visible = false
deploymentStepChanged("following transactions are invalidated:")
verificationLabel.text += "\n" + qsTr("Transactions lost") + "\n"
verificationTextArea.text += "\n" + qsTr("Transactions lost") + "\n"
for (var k in trLost)
{
deploymentStepChanged(trLost[k])
verificationLabel.text += trLost[k] + "\n"
verificationTextArea.text += trLost[k] + "\n"
}
}
}
@ -262,7 +271,6 @@ Rectangle {
{
worker.currentAccount = currentText
accountBalance.text = worker.balance(currentText).format()
console.log(worker.balance(currentText).format())
}
}
@ -289,9 +297,14 @@ Rectangle {
Ether
{
id: gasPriceInput
displayUnitSelection: true
displayUnitSelection: false
displayFormattedValue: true
edit: true
edit: false
function toHexWei()
{
return "0x" + gasPriceInput.value.toWei().hexValue()
}
}
Connections
@ -341,9 +354,7 @@ Rectangle {
root.gas = gas
cost = 0
for (var k in gas)
{
cost += gas[k]
}
setCost()
}
});
@ -361,7 +372,7 @@ Rectangle {
width: labelWidth
Label
{
text: qsTr("Cost Estimate")
text: qsTr("Deployment Cost")
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
@ -442,8 +453,15 @@ Rectangle {
}
TextArea
{
id: verificationTextArea
visible: false
}
Label
{
id: verificationLabel
visible: true
}
}
}
@ -482,7 +500,7 @@ Rectangle {
onClicked:
{
projectModel.deployedScenarioIndex = contractList.currentIndex
NetworkDeploymentCode.deployContracts(root.gas, function(addresses, trHashes)
NetworkDeploymentCode.deployContracts(root.gas, gasPriceInput.toHexWei(), function(addresses, trHashes)
{
projectModel.deploymentTrHashes = trHashes
worker.verifyHashes(trHashes, function (nb, trLost)

9
mix/qml/DeploymentWorker.qml

@ -21,15 +21,6 @@ Item
property variant accounts: []
signal gasPriceLoaded()
function highGasPrice()
{
var hex = deploymentDialog.worker.gasPriceInt.multiply(QEtherHelper.createBigInt(10)).hexValue();
if (hex.indexOf("0x") !== -1)
return hex
else
return "0x" + hex
}
function renewCtx()
{
accounts = []

2
mix/qml/ProjectModel.qml

@ -80,7 +80,7 @@ Item {
function getDocumentIndex(documentId) { return ProjectModelCode.getDocumentIndex(documentId); }
function addExistingFiles(paths) { ProjectModelCode.doAddExistingFiles(paths); }
function deployProject() { NetworkDeploymentCode.deployProject(false); }
function registerToUrlHint(url, callback) { NetworkDeploymentCode.registerToUrlHint(url, callback); }
function registerToUrlHint(url, gasPrice, callback) { NetworkDeploymentCode.registerToUrlHint(url, gasPrice, callback); }
function formatAppUrl() { NetworkDeploymentCode.formatAppUrl(url); }
function cleanDeploymentStatus()

18
mix/qml/RegisteringStep.qml

@ -144,7 +144,7 @@ Rectangle {
Layout.preferredWidth: col.width / 2
Label
{
text: qsTr("Gas to use for dapp registration")
text: qsTr("Registration Cost")
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
id: ctrRegisterLabel
@ -169,7 +169,7 @@ Rectangle {
id: gasToUseDeployInput
displayUnitSelection: true
displayFormattedValue: true
edit: true
edit: false
Layout.preferredWidth: 235
}
}
@ -242,7 +242,7 @@ Rectangle {
anchors.bottomMargin: 10
width: parent.width
function registerHash(callback)
function registerHash(gasPrice, callback)
{
var inError = [];
var ethUrl = NetworkDeploymentCode.formatAppUrl(applicationUrlEthCtrl.text);
@ -253,7 +253,7 @@ Rectangle {
}
if (!worker.stopForInputError(inError))
{
NetworkDeploymentCode.registerDapp(ethUrl, function(){
NetworkDeploymentCode.registerDapp(ethUrl, gasPrice, function(){
projectModel.applicationUrlEth = applicationUrlEthCtrl.text
projectModel.saveProject()
worker.waitForTrReceipt(projectModel.registerContentHashTrHash, function(status, receipt)
@ -270,7 +270,7 @@ Rectangle {
}
}
function registerUrl()
function registerUrl(gasPrice, callback)
{
if (applicationUrlHttp.text === "" || deploymentDialog.packageHash === "")
{
@ -284,7 +284,7 @@ Rectangle {
inError.push(qsTr(applicationUrlHttpCtrl.text));
if (!worker.stopForInputError(inError))
{
registerToUrlHint(applicationUrlHttpCtrl.text, function(){
registerToUrlHint(applicationUrlHttpCtrl.text, gasPrice, function(){
projectModel.applicationUrlHttp = applicationUrlHttpCtrl.text
projectModel.saveProject()
worker.waitForTrReceipt(projectModel.registerUrlTrHash, function(status, receipt)
@ -295,6 +295,7 @@ Rectangle {
projectModel.saveProject()
root.updateVerification(bn, bn, trLost, verificationUrl)
root.registered()
callback()
});
})
})
@ -309,8 +310,9 @@ Rectangle {
width: 30
onClicked:
{
parent.registerHash(function(){
parent.registerUrl()
var gasPrice = deploymentDialog.deployStep.gasPrice.toHexWei()
parent.registerHash(gasPrice, function(){
parent.registerUrl(gasPrice, function(){})
})
}
}

24
mix/qml/js/NetworkDeployment.js

@ -32,9 +32,10 @@ function deployProject(force) {
deploymentDialog.open();
}
function deployContracts(gas, callback)
function deployContracts(gas, gasPrice, callback)
{
deploymentGas = gas;
deploymentGasPrice = gasPrice
deploymentStarted();
var ctrAddresses = {};
@ -135,6 +136,7 @@ function getFunction(ctrName, functionId)
}
var deploymentGas
var deploymentGasPrice
var trRealIndex = -1
function executeTr(blockIndex, trIndex, state, ctrAddresses, trHashes, callBack)
{
@ -148,7 +150,7 @@ function executeTr(blockIndex, trIndex, state, ctrAddresses, trHashes, callBack)
else
{
var gasCost = clientModel.toHex(deploymentGas[trRealIndex]);
var rpcParams = { "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "gasPrice": "0x" + deploymentDialog.worker.highGasPrice() };
var rpcParams = { "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "gasPrice": deploymentGasPrice };
var params = replaceParamToken(func.parameters, tr.parameters, ctrAddresses);
var encodedParams = clientModel.encodeParams(params, contractFromToken(tr.contractId), tr.functionId);
@ -209,14 +211,10 @@ function executeTrNextStep(blockIndex, trIndex, state, ctrAddresses, trHashes, c
{
blockIndex++
if (blockIndex < state.blocks.count)
{
executeTr(blockIndex, 0, state, ctrAddresses, trHashes, callBack);
}
else
{
callBack();
}
}
}
function gasPrice(callBack, error)
@ -296,8 +294,9 @@ function packageDapp(addresses)
deploymentStepChanged(qsTr("Dapp is Packaged"))
}
function registerDapp(url, callback)
function registerDapp(url, gasPrice, callback)
{
deploymentGasPrice = gasPrice
deploymentStepChanged(qsTr("Registering application on the Ethereum network ..."));
checkEthPath(url, false, function (success) {
if (!success)
@ -441,7 +440,7 @@ function continueRegistration(dappUrl, addr, callBack, checkOnly)
requests.push({
jsonrpc: "2.0",
method: "eth_sendTransaction",
params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentDialog.worker.highGasPrice(), "gas": "0x" + gasCost, "code": "0x600080547fffffffffffffffffffffffff000000000000000000000000000000000000000016331781556105cd90819061003990396000f3007c010000000000000000000000000000000000000000000000000000000060003504630198489281146100b257806321f8a721146100e45780632dff6941146100ee5780633b3b57de1461010e5780635a3a05bd1461013e5780635fd4b08a146101715780637dd564111461017d57806389a69c0e14610187578063b387ef92146101bb578063b5c645bd146101f4578063be99a98014610270578063c3d014d6146102a8578063d93e7573146102dc57005b73ffffffffffffffffffffffffffffffffffffffff600435166000908152600160205260409020548060005260206000f35b6000808052602081f35b600435600090815260026020819052604090912001548060005260206000f35b600435600090815260026020908152604082205473ffffffffffffffffffffffffffffffffffffffff1680835291f35b600435600090815260026020908152604082206001015473ffffffffffffffffffffffffffffffffffffffff1680835291f35b60008060005260206000f35b6000808052602081f35b60005461030c9060043590602435903373ffffffffffffffffffffffffffffffffffffffff908116911614610569576105c9565b60005473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b600435600090815260026020819052604090912080546001820154919092015473ffffffffffffffffffffffffffffffffffffffff9283169291909116908273ffffffffffffffffffffffffffffffffffffffff166000528173ffffffffffffffffffffffffffffffffffffffff166020528060405260606000f35b600054610312906004359060243590604435903373ffffffffffffffffffffffffffffffffffffffff90811691161461045457610523565b6000546103189060043590602435903373ffffffffffffffffffffffffffffffffffffffff90811691161461052857610565565b60005461031e90600435903373ffffffffffffffffffffffffffffffffffffffff90811691161461032457610451565b60006000f35b60006000f35b60006000f35b60006000f35b60008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260019091529020548114610361576103e1565b6000818152600260205260408082205473ffffffffffffffffffffffffffffffffffffffff169183917ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a85459190a360008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260019091528120555b600081815260026020819052604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168255600182018054909116905590910182905582917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b50565b600083815260026020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001683179055806104bb57827fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc60006040a2610522565b73ffffffffffffffffffffffffffffffffffffffff8216837ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a854560006040a373ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090208390555b5b505050565b600082815260026020819052604080832090910183905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b5050565b60008281526002602052604080822060010180547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b505056" } ],
params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentGasPrice, "gas": "0x" + gasCost, "code": "0x600080547fffffffffffffffffffffffff000000000000000000000000000000000000000016331781556105cd90819061003990396000f3007c010000000000000000000000000000000000000000000000000000000060003504630198489281146100b257806321f8a721146100e45780632dff6941146100ee5780633b3b57de1461010e5780635a3a05bd1461013e5780635fd4b08a146101715780637dd564111461017d57806389a69c0e14610187578063b387ef92146101bb578063b5c645bd146101f4578063be99a98014610270578063c3d014d6146102a8578063d93e7573146102dc57005b73ffffffffffffffffffffffffffffffffffffffff600435166000908152600160205260409020548060005260206000f35b6000808052602081f35b600435600090815260026020819052604090912001548060005260206000f35b600435600090815260026020908152604082205473ffffffffffffffffffffffffffffffffffffffff1680835291f35b600435600090815260026020908152604082206001015473ffffffffffffffffffffffffffffffffffffffff1680835291f35b60008060005260206000f35b6000808052602081f35b60005461030c9060043590602435903373ffffffffffffffffffffffffffffffffffffffff908116911614610569576105c9565b60005473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b600435600090815260026020819052604090912080546001820154919092015473ffffffffffffffffffffffffffffffffffffffff9283169291909116908273ffffffffffffffffffffffffffffffffffffffff166000528173ffffffffffffffffffffffffffffffffffffffff166020528060405260606000f35b600054610312906004359060243590604435903373ffffffffffffffffffffffffffffffffffffffff90811691161461045457610523565b6000546103189060043590602435903373ffffffffffffffffffffffffffffffffffffffff90811691161461052857610565565b60005461031e90600435903373ffffffffffffffffffffffffffffffffffffffff90811691161461032457610451565b60006000f35b60006000f35b60006000f35b60006000f35b60008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260019091529020548114610361576103e1565b6000818152600260205260408082205473ffffffffffffffffffffffffffffffffffffffff169183917ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a85459190a360008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260019091528120555b600081815260026020819052604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168255600182018054909116905590910182905582917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b50565b600083815260026020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001683179055806104bb57827fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc60006040a2610522565b73ffffffffffffffffffffffffffffffffffffffff8216837ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a854560006040a373ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090208390555b5b505050565b600082815260026020819052604080832090910183905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b5050565b60008281526002602052604080822060010180547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b505056" } ],
id: jsonRpcRequestId++
});
@ -463,7 +462,7 @@ function continueRegistration(dappUrl, addr, callBack, checkOnly)
//setRegister()
jsonrpc: "2.0",
method: "eth_sendTransaction",
params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentDialog.worker.highGasPrice(), "gas": "0x" + gasCost, "to": '0x' + addr, "data": "0x89a69c0e" + crLevel + newCtrAddress } ],
params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentGasPrice, "gas": "0x" + gasCost, "to": '0x' + addr, "data": "0x89a69c0e" + crLevel + newCtrAddress } ],
id: jsonRpcRequestId++
});
@ -496,7 +495,7 @@ function reserve(registrar, callBack)
//reserve()
jsonrpc: "2.0",
method: "eth_sendTransaction",
params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentDialog.worker.highGasPrice(), "gas": "0xfffff", "to": '0x' + registrar, "data": "0x432ced04" + paramTitle } ],
params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentGasPrice, "gas": "0xfffff", "to": '0x' + registrar, "data": "0x432ced04" + paramTitle } ],
id: jsonRpcRequestId++
});
rpcCall(requests, function (httpRequest, response) {
@ -519,7 +518,7 @@ function registerContentHash(registrar, callBack)
//setContent()
jsonrpc: "2.0",
method: "eth_sendTransaction",
params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentDialog.worker.highGasPrice(), "gas": "0x" + gasCost, "to": '0x' + registrar, "data": "0xc3d014d6" + paramTitle + deploymentDialog.packageStep.packageHash } ],
params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentGasPrice, "gas": "0x" + gasCost, "to": '0x' + registrar, "data": "0xc3d014d6" + paramTitle + deploymentDialog.packageStep.packageHash } ],
id: jsonRpcRequestId++
});
rpcCall(requests, function (httpRequest, response) {
@ -531,6 +530,7 @@ function registerContentHash(registrar, callBack)
function registerToUrlHint(url, callback)
{
console.log("register url " + deploymentDialog.packageStep.packageHash + " " + url)
deploymentGasPrice = gasPrice
deploymentStepChanged(qsTr("Registering application Resources..."))
urlHintAddress(function(urlHint){
var requests = [];
@ -540,7 +540,7 @@ function registerToUrlHint(url, callback)
//urlHint => suggestUrl
jsonrpc: "2.0",
method: "eth_sendTransaction",
params: [ { "to": '0x' + urlHint, "gasPrice": deploymentDialog.worker.highGasPrice(), "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "data": "0x584e86ad" + deploymentDialog.packageStep.packageHash + paramUrlHttp } ],
params: [ { "to": '0x' + urlHint, "gasPrice": deploymentGasPrice, "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "data": "0x584e86ad" + deploymentDialog.packageStep.packageHash + paramUrlHttp } ],
id: jsonRpcRequestId++
});

Loading…
Cancel
Save