feat: enable gas calculation

This commit is contained in:
root
2021-07-01 17:42:39 +08:00
parent 59d54cb2b5
commit 02f791f578
4 changed files with 41 additions and 26 deletions

View File

@@ -398,8 +398,16 @@ function executeContract() {
request.pubkey = global.sm2Key.publicKey;
request.isDebug = executeContractAsDebug.checked;
console.log(request.arg);
const gasLimit = $('#gasLimit').val()/1;
var toSign = request.contractID + "|"
+ request.operation + "|" + arg ;
if (gasLimit>0){
request.gasLimit = gasLimit;
toSign+= "|" + gasLimit;
}
toSign+= "|" + global.sm2Key.publicKey;
request.signature = sm2.doSignature(
`${request.contractID}|${operation}|${argDiv.value}|${global.sm2Key.publicKey}`,
toSign,
global.sm2Key.privateKey,
{hash: true, der: true});
localStorage.setItem("persisArg", JSON.stringify(request));
@@ -423,7 +431,10 @@ function onExecuteResult(obj) {
$("#responseArea")[0].value = result.result;
}
$("#responseID").html(`请求ID:${obj['responseID']}`);
$("#responseTime").html(`响应时间:${obj['executeTime']}ms${styleTail}`);
var gasInfo="";
if (obj.executionGas!=undefined && obj.executionGas>0)
gasInfo="<br>"+obj.executionGas+"gas";
$("#responseTime").html(`响应时间:${obj['executeTime']}ms${gasInfo}${styleTail}`);
} catch (e) {
$("#responseStatus").html("执行状态Failed");
$("#responseArea")[0].value = obj.data;