feat: enable gas calculation

This commit is contained in:
root
2021-07-01 17:42:39 +08:00
parent cb5ebfc072
commit 821ea0eeda
2 changed files with 45 additions and 6 deletions

View File

@@ -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 = {};