feat: enable gas calculation
This commit is contained in:
@@ -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 = {};
|
||||
|
||||
Reference in New Issue
Block a user