Browse Source

- Do not create a registrar for the dapp itself

- eth:// scheme
 - Handle empty path
 - Don't wait for transactions to be mined, setDefault to zero
cl-refactor
yann300 10 years ago
parent
commit
8f95591290
  1. 15
      mix/qml/DeploymentDialog.qml
  2. 49
      mix/qml/js/ProjectModel.js

15
mix/qml/DeploymentDialog.qml

@ -187,12 +187,25 @@ Window {
text: qsTr("Ethereum Application URL: ")
}
DefaultTextField
Rectangle
{
Layout.fillWidth: true
height: 25
color: "transparent"
DefaultTextField
{
width: 350
id: applicationUrlEth
}
DefaultLabel
{
anchors.verticalCenter: parent.verticalCenter;
anchors.left: applicationUrlEth.right
text: "/" + projectModel.projectTitle
}
}
DefaultLabel
{
text: qsTr("Web Application Ressources URL: ")

49
mix/qml/js/ProjectModel.js

@ -309,9 +309,24 @@ function startDeployProject(erasePrevious)
var ctrNames = Object.keys(codeModel.contracts);
var ctrAddresses = {};
setDefaultBlock(0, function() {
deployContracts(0, ctrAddresses, ctrNames, function (){
finalizeDeployment(deploymentId, ctrAddresses);
});
});
}
function setDefaultBlock(val, callBack)
{
var requests = [{
jsonrpc: "2.0",
method: "eth_setDefaultBlock",
params: [val],
id: 0
}];
rpcCall(requests, function (httpCall, response){
callBack();
});
}
function deployContracts(ctrIndex, ctrAddresses, ctrNames, callBack)
@ -398,18 +413,22 @@ function finalizeDeployment(deploymentId, addresses) {
var applicationUrlEth = deploymentDialog.applicationUrlEth;
applicationUrlEth = formatAppUrl(applicationUrlEth);
deploymentStepChanged(qsTr("Registering application on the Ethereum network ..."));
applicationUrlEth.push(projectModel.projectTitle);
checkEthPath(applicationUrlEth, function () {
deploymentComplete();
deployRessourcesDialog.text = qsTr("Register Web Application to finalize deployment.");
deployRessourcesDialog.open();
setDefaultBlock(-1, function() {});
});
}
function checkEthPath(dappUrl, callBack)
{
if (dappUrl.length === 1)
registerContentHash(deploymentDialog.eth, callBack); // we directly create a dapp under the root registrar.
else
{
// the first owned reigstrar must have been created to follow the path.
var str = createString(dappUrl[0]);
var requests = [];
requests.push({
@ -422,7 +441,7 @@ function checkEthPath(dappUrl, callBack)
rpcCall(requests, function (httpRequest, response) {
var res = JSON.parse(response);
var addr = normalizeAddress(res[0].result);
if (addr === "")
if (addr.replace(/0+/g, "") === "")
{
var errorTxt = qsTr("Path does not exists " + JSON.stringify(dappUrl) + ". Please register using Registration Dapp. Aborting.");
deploymentError(errorTxt);
@ -435,8 +454,13 @@ function checkEthPath(dappUrl, callBack)
}
});
}
}
function checkRegistration(dappUrl, addr, callBack)
{
if (dappUrl.length === 1)
registerContentHash(addr, callBack); // We do not create the register for the last part, just registering the content hash.
else
{
var txt = qsTr("Checking " + JSON.stringify(dappUrl) + " ... in registrar " + addr);
deploymentStepChanged(txt);
@ -479,10 +503,7 @@ function checkRegistration(dappUrl, addr, callBack)
else if (nextAddr.replace(/0+/g, "") !== "")
{
dappUrl.splice(0, 1);
if (dappUrl.length > 0)
checkRegistration(dappUrl, nextAddr, callBack);
else
registerContentHash(addr, callBack);
}
else
{
@ -500,15 +521,11 @@ function checkRegistration(dappUrl, addr, callBack)
});
rpcCall(requests, function(httpRequest, response) {
console.log("crea2" + response);
var newCtrAddress = normalizeAddress(JSON.parse(response)[0].result);
requests = [];
console.log('new created addr ' + newCtrAddress);
var txt = qsTr("Please wait " + dappUrl[0] + " is registering ...");
deploymentStepChanged(txt);
console.log(txt);
deploymentDialog.waitForTrCountToIncrement(function(status) {
if (status === -1)
{
@ -524,18 +541,16 @@ function checkRegistration(dappUrl, addr, callBack)
id: jsonRpcRequestId++
});
rpcCall(requests, function(){
rpcCall(requests, function(request, response){
dappUrl.splice(0, 1);
if (dappUrl.length > 0)
checkRegistration(dappUrl, newCtrAddress, callBack);
else
registerContentHash(addr, callBack);
});
});
});
}
});
}
}
function trCountIncrementTimeOut()
{
@ -592,6 +607,11 @@ function normalizeAddress(addr)
function formatAppUrl(url)
{
if (url.toLowerCase().indexOf("eth://") === 0)
url = url.substring(6);
if (url === "")
return [projectModel.projectTitle];
var ret;
if (url.indexOf("/") === -1)
ret = url.split('.').reverse();
@ -608,5 +628,6 @@ function formatAppUrl(url)
}
if (ret[0].toLowerCase() === "eth")
ret.splice(0, 1);
ret.push(projectModel.projectTitle);
return ret;
}

Loading…
Cancel
Save