diff --git a/js/bdwareclient.js b/js/bdwareclient.js
index e2e294b..5b2030c 100644
--- a/js/bdwareclient.js
+++ b/js/bdwareclient.js
@@ -401,6 +401,7 @@ function changeAppInternal(requireRendering) {
+ " \n"
+ " \n"
+ " \n"
+ + " \n"
+ "
\n"
+ ""
@@ -473,14 +474,21 @@ function triggerExecuteCurrentContract() {
console.log(funNode);
const argInput = $("#argInput");
var contract = global.currentContract;
- executeContract(contract.id, funNode.functionName, argInput[0].value,
+ var gas = $("#gasInput")[0].value/1;
+ executeContractWithGas(contract.id, funNode.functionName, argInput[0].value,gas,
fillResultInternal, executeContractAsDebug.checked);
- const iHtml = "/SCIDE/SCManager?action=executeContract&contractID="
+ var iHtml = "/SCIDE/SCManager?action=executeContract&contractID="
+ global.currentContract.name + "&operation="
- + funNode.functionName + "&arg=" + argInput[0].value
- + "&pubkey=" + global.sm2Key.publicKey + "&signature=";
- const toSign = global.currentContract.name + "|" + funNode.functionName + "|"
- + argInput[0].value + "|" + global.sm2Key.publicKey;
+ + funNode.functionName + "&arg=" + argInput[0].value;
+
+ var toSign = global.currentContract.name + "|" + funNode.functionName + "|"
+ + argInput[0].value ;
+ if (gas>0){
+ toSign+="|"+gas;
+ iHtml+="&gasLimit="+gas;
+ }
+ iHtml+= "&pubkey=" + global.sm2Key.publicKey + "&signature=";
+ toSign+= "|" + global.sm2Key.publicKey;
const signature = sm2.doSignature(toSign, global.sm2Key.privateKey, {hash: true, der: true});
let urlPre = $("#urlInput")[0].value;
if (urlPre.startsWith("ws")) {
@@ -520,6 +528,9 @@ function fillResultInternal(result, data) {
global.responseCollector[data.responseID].push(data);
$("#statusSpan")[0].innerHTML = result.status;
$("#timeSpan")[0].innerHTML = "调用耗时:" + data.executeTime + "(ms)";
+ if (data.executionGas !=undefined && data.executionGas>0)
+ $("#timeSpan")[0].innerHTML+="
"+data.executionGas+"(gas)";
+ $("#timeSpan")[0].innerHTML
if (result.result instanceof Object) {
$("#responseArea")[0].value = JSON.stringify(result.result);
$("#timeSpan")[0].innerHTML += "
JSON格式";
diff --git a/js/createWS.js b/js/createWS.js
index 250d28a..adff751 100644
--- a/js/createWS.js
+++ b/js/createWS.js
@@ -179,6 +179,34 @@ var onExecuteResultInternal = function (data) {
callback(global.executeResult, data);
}
};
+window.executeContractWithGas = function (contractID, method, strarg, gas, cb, asDebug) {
+ var sm2Key = global.sm2Key;
+ var request = {};
+ request.action = "executeContract";
+ request.requestID = new Date().getTime() + "_"
+ + Math.floor(Math.random() * 10000);
+ if (asDebug)
+ request.isDebug = true;
+ global.cbs[request.requestID] = cb;
+ request.contractID = contractID;
+ request.operation = method;
+ request.arg = strarg;
+ if (sm2Key) {
+ request.pubkey = sm2Key.publicKey;
+ var toSign = request.contractID + "|"
+ + method + "|" + strarg ;
+ if (gas>0){
+ request.gasLimit = gas;
+ toSign+= "|" + gas;
+ }
+ toSign+= "|" + sm2Key.publicKey;
+ request.signature = sm2.doSignature(toSign ,
+ sm2Key.privateKey, {hash: true, der: true});
+ }
+
+ global.wssocket.send(JSON.stringify(request));
+};
+
window.executeContract = function (contractID, method, strarg, cb, asDebug) {
var sm2Key = global.sm2Key;
var request = {};