|
|
@ -47,6 +47,7 @@ function startDeployProject(erasePrevious) |
|
|
|
|
|
|
|
var ctrAddresses = {}; |
|
|
|
var state = retrieveState(projectModel.deployedState); |
|
|
|
console.log(JSON.stringify(state)); |
|
|
|
if (!state) |
|
|
|
{ |
|
|
|
var txt = qsTr("Unable to find state " + projectModel.deployedState); |
|
|
@ -59,6 +60,23 @@ function startDeployProject(erasePrevious) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function checkPathCreationCost(callBack) |
|
|
|
{ |
|
|
|
var dappUrl = formatAppUrl(deploymentDialog.applicationUrlEth); |
|
|
|
checkEthPath(dappUrl, true, function(success) { |
|
|
|
callBack((dappUrl.length - 1) * 100000 + 5000 /* 500: register content hash */); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function gasUsed() |
|
|
|
{ |
|
|
|
var gas = 0; |
|
|
|
var gasCosts = clientModel.gasCosts; |
|
|
|
for (var g in gasCosts) |
|
|
|
gas += gasCosts[g]; |
|
|
|
return gas; |
|
|
|
} |
|
|
|
|
|
|
|
function retrieveState(state) |
|
|
|
{ |
|
|
|
for (var k = 0; k < projectModel.stateListModel.count; k++) |
|
|
@ -113,7 +131,9 @@ function executeTr(trIndex, state, ctrAddresses, callBack) |
|
|
|
executeTrNextStep(trIndex, state, ctrAddresses, callBack); |
|
|
|
else |
|
|
|
{ |
|
|
|
var rpcParams = { "from": deploymentDialog.currentAccount, "gas": deploymentDialog.gasToUse }; |
|
|
|
var gasCost = clientModel.encodeAbiString(clientModel.gasCosts[trIndex]); |
|
|
|
console.log("gas " + gasCost); |
|
|
|
var rpcParams = { "from": deploymentDialog.currentAccount, "gas": "0x" + gasCost }; |
|
|
|
var params = replaceParamToken(func.parameters, tr.parameters, ctrAddresses); |
|
|
|
var encodedParams = clientModel.encodeParams(params, tr.contractId, tr.functionId); |
|
|
|
|
|
|
@ -157,6 +177,19 @@ function executeTrNextStep(trIndex, state, ctrAddresses, callBack) |
|
|
|
callBack(); |
|
|
|
} |
|
|
|
|
|
|
|
function gasPrice(callBack) |
|
|
|
{ |
|
|
|
var requests = [{ |
|
|
|
jsonrpc: "2.0", |
|
|
|
method: "eth_gasPrice", |
|
|
|
params: [], |
|
|
|
id: jsonRpcRequestId |
|
|
|
}]; |
|
|
|
rpcCall(requests, function (httpCall, response){ |
|
|
|
callBack(JSON.parse(response)[0].result); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function finalizeDeployment(deploymentId, addresses) { |
|
|
|
deploymentStepChanged(qsTr("Packaging application ...")); |
|
|
|
var deploymentDir = projectPath + deploymentId + "/"; |
|
|
@ -185,8 +218,8 @@ function finalizeDeployment(deploymentId, addresses) { |
|
|
|
} |
|
|
|
//write deployment js
|
|
|
|
var deploymentJs = |
|
|
|
"// Autogenerated by Mix\n" + |
|
|
|
"contracts = {};\n"; |
|
|
|
"// Autogenerated by Mix\n" + |
|
|
|
"contracts = {};\n"; |
|
|
|
for (var c in codeModel.contracts) { |
|
|
|
var contractAccessor = "contracts[\"" + codeModel.contracts[c].contract.name + "\"]"; |
|
|
|
deploymentJs += contractAccessor + " = {\n" + |
|
|
@ -209,16 +242,18 @@ function finalizeDeployment(deploymentId, addresses) { |
|
|
|
|
|
|
|
applicationUrlEth = formatAppUrl(applicationUrlEth); |
|
|
|
deploymentStepChanged(qsTr("Registering application on the Ethereum network ...")); |
|
|
|
checkEthPath(applicationUrlEth, function () { |
|
|
|
checkEthPath(applicationUrlEth, false, function (success) { |
|
|
|
if (!success) |
|
|
|
return; |
|
|
|
deploymentComplete(); |
|
|
|
deployResourcesDialog.text = qsTr("Register Web Application to finalize deployment."); |
|
|
|
deployResourcesDialog.open(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function checkEthPath(dappUrl, callBack) |
|
|
|
function checkEthPath(dappUrl, checkOnly, callBack) |
|
|
|
{ |
|
|
|
if (dappUrl.length === 1) |
|
|
|
if (dappUrl.length === 1 && !checkOnly) |
|
|
|
registerContentHash(deploymentDialog.eth, callBack); // we directly create a dapp under the root registrar.
|
|
|
|
else |
|
|
|
{ |
|
|
@ -240,19 +275,20 @@ function checkEthPath(dappUrl, callBack) |
|
|
|
var errorTxt = qsTr("Path does not exists " + JSON.stringify(dappUrl) + ". Please register using Registration Dapp. Aborting."); |
|
|
|
deploymentError(errorTxt); |
|
|
|
console.log(errorTxt); |
|
|
|
callBack(false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
dappUrl.splice(0, 1); |
|
|
|
checkRegistration(dappUrl, addr, callBack); |
|
|
|
checkRegistration(dappUrl, addr, callBack, checkOnly); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function checkRegistration(dappUrl, addr, callBack) |
|
|
|
function checkRegistration(dappUrl, addr, callBack, checkOnly) |
|
|
|
{ |
|
|
|
if (dappUrl.length === 1) |
|
|
|
if (dappUrl.length === 1 && !checkOnly) |
|
|
|
registerContentHash(addr, callBack); // We do not create the register for the last part, just registering the content hash.
|
|
|
|
else |
|
|
|
{ |
|
|
@ -287,20 +323,28 @@ function checkRegistration(dappUrl, addr, callBack) |
|
|
|
errorTxt = qsTr("Error when creating new owned regsitrar. Please use the regsitration Dapp. Aborting"); |
|
|
|
deploymentError(errorTxt); |
|
|
|
console.log(errorTxt); |
|
|
|
callBack(false); |
|
|
|
} |
|
|
|
else if (normalizeAddress(deploymentDialog.currentAccount) !== normalizeAddress(res[0].result)) |
|
|
|
{ |
|
|
|
errorTxt = qsTr("You are not the owner of " + dappUrl[0] + ". Aborting"); |
|
|
|
deploymentError(errorTxt); |
|
|
|
console.log(errorTxt); |
|
|
|
callBack(false); |
|
|
|
} |
|
|
|
else if (nextAddr.replace(/0+/g, "") !== "") |
|
|
|
{ |
|
|
|
dappUrl.splice(0, 1); |
|
|
|
checkRegistration(dappUrl, nextAddr, callBack); |
|
|
|
checkRegistration(dappUrl, nextAddr, callBack, checkOnly); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (checkOnly) |
|
|
|
{ |
|
|
|
callBack(true); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var txt = qsTr("Registering sub domain " + dappUrl[0] + " ..."); |
|
|
|
console.log(txt); |
|
|
|
deploymentStepChanged(txt); |
|
|
@ -424,6 +468,9 @@ function normalizeAddress(addr) |
|
|
|
|
|
|
|
function formatAppUrl(url) |
|
|
|
{ |
|
|
|
console.log(" 55 " + url); |
|
|
|
if (url.toLowerCase().lastIndexOf("/") === url.length - 1) |
|
|
|
url = url.substring(0, url.length - 1); |
|
|
|
if (url.toLowerCase().indexOf("eth://") === 0) |
|
|
|
url = url.substring(6); |
|
|
|
if (url.toLowerCase().indexOf(projectModel.projectTitle + ".") === 0) |
|
|
|