|
@ -48,11 +48,12 @@ function deployContracts(gas, callback) |
|
|
console.log(txt); |
|
|
console.log(txt); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
executeTr(0, 0, state, ctrAddresses, function(){ |
|
|
var trHashes = {} |
|
|
|
|
|
executeTr(0, 0, state, ctrAddresses, trHashes, 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) |
|
|
if (callback) |
|
|
callback(ctrAddresses) |
|
|
callback(ctrAddresses, trHashes) |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -140,7 +141,7 @@ function getFunction(ctrName, functionId) |
|
|
|
|
|
|
|
|
var deploymentGas |
|
|
var deploymentGas |
|
|
var trRealIndex = -1 |
|
|
var trRealIndex = -1 |
|
|
function executeTr(blockIndex, trIndex, state, ctrAddresses, callBack) |
|
|
function executeTr(blockIndex, trIndex, state, ctrAddresses, trHashes, callBack) |
|
|
{ |
|
|
{ |
|
|
trRealIndex++; |
|
|
trRealIndex++; |
|
|
var tr = state.blocks.get(blockIndex).transactions.get(trIndex); |
|
|
var tr = state.blocks.get(blockIndex).transactions.get(trIndex); |
|
@ -148,7 +149,7 @@ function executeTr(blockIndex, trIndex, state, ctrAddresses, callBack) |
|
|
callBack() |
|
|
callBack() |
|
|
var func = getFunction(tr.contractId, tr.functionId); |
|
|
var func = getFunction(tr.contractId, tr.functionId); |
|
|
if (!func) |
|
|
if (!func) |
|
|
executeTrNextStep(blockIndex, trIndex, state, ctrAddresses, callBack); |
|
|
executeTrNextStep(blockIndex, trIndex, state, ctrAddresses, trHashes, callBack); |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
var gasCost = clientModel.toHex(deploymentGas[trRealIndex]); |
|
|
var gasCost = clientModel.toHex(deploymentGas[trRealIndex]); |
|
@ -172,8 +173,9 @@ function executeTr(blockIndex, trIndex, state, ctrAddresses, callBack) |
|
|
var txt = qsTr(tr.contractId + "." + tr.functionId + "() ...") |
|
|
var txt = qsTr(tr.contractId + "." + tr.functionId + "() ...") |
|
|
deploymentStepChanged(txt); |
|
|
deploymentStepChanged(txt); |
|
|
console.log(txt); |
|
|
console.log(txt); |
|
|
|
|
|
var hash = JSON.parse(response)[0].result |
|
|
deploymentDialog.worker.waitForTrReceipt(JSON.parse(response)[0].result, function(status, receipt){ |
|
|
trHashes[tr.contractId + "." + tr.functionId + "()"] = hash |
|
|
|
|
|
deploymentDialog.worker.waitForTrReceipt(hash, function(status, receipt){ |
|
|
if (status === -1) |
|
|
if (status === -1) |
|
|
trCountIncrementTimeOut(); |
|
|
trCountIncrementTimeOut(); |
|
|
else |
|
|
else |
|
@ -183,7 +185,7 @@ function executeTr(blockIndex, trIndex, state, ctrAddresses, callBack) |
|
|
ctrAddresses[tr.contractId] = receipt.contractAddress |
|
|
ctrAddresses[tr.contractId] = receipt.contractAddress |
|
|
ctrAddresses[tr.contractId + " - " + trIndex] = receipt.contractAddress //get right ctr address if deploy more than one contract of same type.
|
|
|
ctrAddresses[tr.contractId + " - " + trIndex] = receipt.contractAddress //get right ctr address if deploy more than one contract of same type.
|
|
|
} |
|
|
} |
|
|
executeTrNextStep(blockIndex, trIndex, state, ctrAddresses, callBack) |
|
|
executeTrNextStep(blockIndex, trIndex, state, ctrAddresses, trHashes, callBack) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}); |
|
|
}); |
|
@ -203,17 +205,17 @@ function retrieveContractAddress(trHash, callback) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function executeTrNextStep(blockIndex, trIndex, state, ctrAddresses, callBack) |
|
|
function executeTrNextStep(blockIndex, trIndex, state, ctrAddresses, trHashes, callBack) |
|
|
{ |
|
|
{ |
|
|
trIndex++; |
|
|
trIndex++; |
|
|
if (trIndex < state.blocks.get(blockIndex).transactions.count) |
|
|
if (trIndex < state.blocks.get(blockIndex).transactions.count) |
|
|
executeTr(blockIndex, trIndex, state, ctrAddresses, callBack); |
|
|
executeTr(blockIndex, trIndex, state, ctrAddresses, trHashes, callBack); |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
blockIndex++ |
|
|
blockIndex++ |
|
|
if (blockIndex < state.blocks.count) |
|
|
if (blockIndex < state.blocks.count) |
|
|
{ |
|
|
{ |
|
|
executeTr(blockIndex, 0, state, ctrAddresses, callBack); |
|
|
executeTr(blockIndex, 0, state, ctrAddresses, trHashes, callBack); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -514,6 +516,7 @@ function registerContentHash(registrar, callBack) |
|
|
deploymentStepChanged(txt); |
|
|
deploymentStepChanged(txt); |
|
|
console.log(txt); |
|
|
console.log(txt); |
|
|
console.log("register url " + deploymentDialog.packageStep.packageHash + " " + projectModel.projectTitle) |
|
|
console.log("register url " + deploymentDialog.packageStep.packageHash + " " + projectModel.projectTitle) |
|
|
|
|
|
projectModel.registerContentHashTrHash = "" |
|
|
var requests = []; |
|
|
var requests = []; |
|
|
var paramTitle = clientModel.encodeStringParam(projectModel.projectTitle); |
|
|
var paramTitle = clientModel.encodeStringParam(projectModel.projectTitle); |
|
|
var gasCost = clientModel.toHex(deploymentDialog.registerStep.ownedRegistrarSetContentHashGas); |
|
|
var gasCost = clientModel.toHex(deploymentDialog.registerStep.ownedRegistrarSetContentHashGas); |
|
@ -525,6 +528,7 @@ function registerContentHash(registrar, callBack) |
|
|
id: jsonRpcRequestId++ |
|
|
id: jsonRpcRequestId++ |
|
|
}); |
|
|
}); |
|
|
rpcCall(requests, function (httpRequest, response) { |
|
|
rpcCall(requests, function (httpRequest, response) { |
|
|
|
|
|
projectModel.registerContentHashTrHash = JSON.parse(response)[0].result |
|
|
callBack(true); |
|
|
callBack(true); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -546,6 +550,7 @@ function registerToUrlHint(url, callback) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
rpcCall(requests, function (httpRequest, response) { |
|
|
rpcCall(requests, function (httpRequest, response) { |
|
|
|
|
|
projectModel.registerUrlTrHash = JSON.parse(response)[0].result |
|
|
deploymentComplete(); |
|
|
deploymentComplete(); |
|
|
if (callback) |
|
|
if (callback) |
|
|
callback() |
|
|
callback() |
|
|