merge: merge changes in BaaS

This commit is contained in:
Frank.R.Wu
2021-06-15 21:43:19 +08:00
parent c8758ecfdc
commit 12a1b701f7
7 changed files with 2166 additions and 1409 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -87,36 +87,34 @@ var genReadme = function () {
var sm2Key = JSON.parse(key.sm2Key);
for (c of mainVue.contracts) {
// 这里假设合约名同文件名
if (yjsName == c.name) {
var exportedFunction = c.exportedFunctions;
ReadmeFunction = [];
for (let f of exportedFunction) {
let description = "暂无描述";
let readmeFunc = {};
readmeFunc.functionName = f.functionName;
readmeFunc.description = description;
for (let anno of f.annotations) {
if (anno.type == 'Param') {
readmeFunc.args = anno.args[0];
}
else if (anno.type == 'Description') {
readmeFunc.description = anno.args[0];
}
else if (anno.type == 'Result') {
readmeFunc.result = anno.args[0];
}
}
ReadmeFunction.push(readmeFunc);
}
request.action = "generateReadme";
// 这里假设合约名同文件名
if (yjsName == c.name) {
var exportedFunction = c.exportedFunctions;
ReadmeFunction = [];
for (let f of exportedFunction) {
let description = "暂无描述";
let readmeFunc = {};
readmeFunc.functionName = f.functionName;
readmeFunc.description = description;
for (let anno of f.annotations) {
if (anno.type == 'Param') {
readmeFunc.args = anno.args[0];
} else if (anno.type == 'Description') {
readmeFunc.description = anno.args[0];
} else if (anno.type == 'Result') {
readmeFunc.result = anno.args[0];
}
}
ReadmeFunction.push(readmeFunc);
}
request.action = "generateReadme";
request.contractID = c.id;
request.contractName = c.name;
request.pubkey = sm2Key.publicKey;
global.wssocket.send(JSON.stringify(request));
return;
}
request.contractID = c.id;
request.contractName = c.name;
request.pubkey = sm2Key.publicKey;
global.wssocket.send(JSON.stringify(request));
return;
}
}
myToast("生成文档失败", "请启动合约并检查合约与文件名是否一致!");
};
@@ -138,7 +136,7 @@ var genData = function () {
if ($('#gasLimit').val() == undefined || $('#gasLimit').val() == "") {
arg.gasLimit = '1000';
} else {
arg.gasLimit =$('#gasLimit').val();
arg.gasLimit = $('#gasLimit').val();
}
// console.log("[arg.gasLimit]"+arg.gasLimit);
request.pubkey = sm2Key.publicKey;
@@ -177,11 +175,12 @@ var importContractInstanceCodeByDOI = function () {
};
var openinClient = function () {
var path = document.location.pathname;
path = path.replace("/SCIDE","");
path = path.replace("/OnlineIDE.html","");
var url = path + "/client/bdwareclient.html?self=true&contract="
+ mainVue.contracts[selectedContract.value].id;
let url
if (global.isBaaS) {
url = `${location.origin}/client/BaaSClient.html${location.search}`;
} else {
url = `${location.origin}/client/bdwareclient.html?self=true&contract=${mainVue.contracts[selectedContract.value].id}`
}
window.open(url);
};
@@ -192,7 +191,7 @@ var stopAllContract = function () {
};
var selectContractToExecute = function () {
var value = selectedContractAtExecute.value;
if (value != undefined && value != "选择实例") {
if (!value && value !== "选择实例") {
var exportedFunction = mainVue.contracts[value].exportedFunctions;
mainVue.contractFunctions = exportedFunction;
@@ -220,7 +219,6 @@ var executeContract = function () {
var request = {};
request.action = "executeContract";
request.requestID = new Date().getTime() + "_"
+ Math.floor(Math.random() * 10000);
@@ -233,12 +231,12 @@ var executeContract = function () {
if ($('#gasLimit').val() == undefined || $('#gasLimit').val() == "") {
arg.gasLimit = '1000';
} else {
arg.gasLimit =$('#gasLimit').val();
arg.gasLimit = $('#gasLimit').val();
}
// console.log("[arg.gasLimit]"+arg.gasLimit);
request.pubkey = sm2Key.publicKey;
request.signature = sm2.doSignature(request.contractID + "|" + arg.action
+ "|" + arg.arg + "|" + sm2Key.publicKey, sm2Key.privateKey,{hash:true,der:true});
+ "|" + arg.arg + "|" + sm2Key.publicKey, sm2Key.privateKey, {hash: true, der: true});
request.arg = JSON.stringify(arg);
localStorage.setItem("persisArg", JSON.stringify(request));
@@ -271,7 +269,7 @@ var executeContractWithDynamicResult = function () {
request.pubkey = global.sm2Key.publicKey;
request.signature = sm2.doSignature(request.contractID + "|" + arg.action
+ "|" + arg.arg + "|" + global.sm2Key.publicKey,
global.sm2Key.privateKey,{hash:true,der:true});
global.sm2Key.privateKey, {hash: true, der: true});
localStorage.setItem("persisArg", JSON.stringify(request));
global.wssocket.send(JSON.stringify(request));
};

View File

@@ -76,9 +76,9 @@ var importContractInstanceCodeByDOI = function () {
};
var openinClient = function () {
var path = document.location.pathname;
path = path.replace("/SCIDE","");
path = path.replace("/OnlineIDE.html","");
var path = document.location.pathname;
path = path.replace("/SCIDE", "");
path = path.replace("/OnlineIDE.html", "");
var url = path + "/client/bdwareclient.html?self=true&contract="
+ mainVue.contracts[selectedContract.value].id;
window.open(url);
@@ -91,7 +91,7 @@ var stopAllContract = function () {
};
var selectContractToExecute = function () {
var value = selectedContractAtExecute.value;
if (value != undefined && value != "Select Instance") {
if (value && value !== "Select Instance") {
var exportedFunction = mainVue.contracts[value].exportedFunctions;
mainVue.contractFunctions = exportedFunction;
@@ -119,7 +119,6 @@ var executeContract = function () {
var request = {};
request.action = "executeContract";
request.requestID = new Date().getTime() + "_"
+ Math.floor(Math.random() * 10000);
@@ -131,14 +130,14 @@ var executeContract = function () {
arg.arg = executeContractArgInput.value;
//console.log("[global.withEvaluatesAnalysis]"+global.withEvaluatesAnalysis);
//if (global.withEvaluatesAnalysis != undefined) {
//console.log("test");
//console.log("test");
if ($('#gasLimit').val() == undefined || $('#gasLimit').val() == "") {
arg.gasLimit = '1000';
} else {
arg.gasLimit =$('#gasLimit').val();
arg.gasLimit = $('#gasLimit').val();
}
console.log("[arg.gasLimit]"+arg.gasLimit);
//request.withEvaluatesAnalysis = global.withEvaluatesAnalysis;
console.log("[arg.gasLimit]" + arg.gasLimit);
//request.withEvaluatesAnalysis = global.withEvaluatesAnalysis;
//}
request.pubkey = sm2Key.publicKey;
request.signature = sm2.doSignature(request.contractID + "|" + arg.action