From 965ee674094664ddf99013eed26f6aaacac4fe01 Mon Sep 17 00:00:00 2001 From: "Frank.R.Wu" Date: Sun, 12 Dec 2021 12:25:36 +0800 Subject: [PATCH] fix: fix bugs in executeContract of NodeContractInstances.js --- js/NodeContractInstances.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/js/NodeContractInstances.js b/js/NodeContractInstances.js index 91a5bd2..ed612c2 100644 --- a/js/NodeContractInstances.js +++ b/js/NodeContractInstances.js @@ -398,14 +398,14 @@ function executeContract() { request.pubkey = global.sm2Key.publicKey; request.isDebug = executeContractAsDebug.checked; console.log(request.arg); - const gasLimit = $('#gasLimit').val()/1; + const gasLimit = $('#gasLimit').val() / 1; var toSign = request.contractID + "|" - + request.operation + "|" + arg ; - if (gasLimit>0){ - request.gasLimit = gasLimit; - toSign+= "|" + gasLimit; + + request.operation + "|" + request.arg; + if (gasLimit > 0) { + request.gasLimit = gasLimit; + toSign += "|" + gasLimit; } - toSign+= "|" + global.sm2Key.publicKey; + toSign += "|" + global.sm2Key.publicKey; request.signature = sm2.doSignature( toSign, global.sm2Key.privateKey, @@ -431,9 +431,9 @@ function onExecuteResult(obj) { $("#responseArea")[0].value = result.result; } $("#responseID").html(`请求ID:${obj['responseID']}`); - var gasInfo=""; - if (obj.executionGas!=undefined && obj.executionGas>0) - gasInfo="
"+obj.executionGas+"gas"; + var gasInfo = ""; + if (obj.executionGas != undefined && obj.executionGas > 0) + gasInfo = "
" + obj.executionGas + "gas"; $("#responseTime").html(`响应时间:${obj['executeTime']}ms${gasInfo}${styleTail}`); } catch (e) { $("#responseStatus").html("执行状态:Failed"); @@ -461,12 +461,12 @@ function getMask() { console.log(request.arg); //const gasLimit = $('#gasLimit').val()/1; var toSign = request.contractID + "|" - + request.operation + "|" + arg ; + + request.operation + "|" + arg; /*if (gasLimit>0){ request.gasLimit = gasLimit; toSign+= "|" + gasLimit; }*/ - toSign+= "|" + global.sm2Key.publicKey; + toSign += "|" + global.sm2Key.publicKey; request.signature = sm2.doSignature( toSign, global.sm2Key.privateKey, @@ -474,6 +474,7 @@ function getMask() { localStorage.setItem("persisArg", JSON.stringify(request)); global.wssocket.send(JSON.stringify(request)); } + function setMask() { const argDiv = $('#maskArg')[0]; const request = {}; @@ -492,12 +493,12 @@ function setMask() { console.log(request.arg); //const gasLimit = $('#gasLimit').val()/1; var toSign = request.contractID + "|" - + request.operation + "|" + arg ; + + request.operation + "|" + arg; /*if (gasLimit>0){ request.gasLimit = gasLimit; toSign+= "|" + gasLimit; }*/ - toSign+= "|" + global.sm2Key.publicKey; + toSign += "|" + global.sm2Key.publicKey; request.signature = sm2.doSignature( toSign, global.sm2Key.privateKey, @@ -535,12 +536,12 @@ function getMock() { console.log(request.arg); //const gasLimit = $('#gasLimit').val()/1; var toSign = request.contractID + "|" - + request.operation + "|" + arg ; + + request.operation + "|" + arg; /*if (gasLimit>0){ request.gasLimit = gasLimit; toSign+= "|" + gasLimit; }*/ - toSign+= "|" + global.sm2Key.publicKey; + toSign += "|" + global.sm2Key.publicKey; request.signature = sm2.doSignature( toSign, global.sm2Key.privateKey, @@ -567,12 +568,12 @@ function setMock() { console.log(request.arg); //const gasLimit = $('#gasLimit').val()/1; var toSign = request.contractID + "|" - + request.operation + "|" + arg ; + + request.operation + "|" + arg; /*if (gasLimit>0){ request.gasLimit = gasLimit; toSign+= "|" + gasLimit; }*/ - toSign+= "|" + global.sm2Key.publicKey; + toSign += "|" + global.sm2Key.publicKey; request.signature = sm2.doSignature( toSign, global.sm2Key.privateKey,