NodePortal

This commit is contained in:
Hongwei Zhang 2021-08-09 09:48:56 +08:00
parent 5758a3ae78
commit fe1dcf7e79
3 changed files with 222 additions and 0 deletions

View File

@ -544,6 +544,73 @@
<textarea class="form-control" id="responseArea"></textarea>
</div>
</div>
<div class="row d-flex justify-content-flex-start">
<h6 class="card-title" style="margin-top: 2%">Mask配置</h6>
<div class="input-group mb-3">
<div class="input-group-append">
<span class="input-group-text">参数</span>
</div>
<input type="text" class="form-control" placeholder="输入参数" id="maskArg">
<div class="input-group-append">
<button onclick="getMask()" type="button"
class="btn btn-outline-primary">get
</button>
</div>
<div class="input-group-append">
<button onclick="setMask()"
type="button" class="btn btn-outline-primary">set
</button>
</div>
</div>
</div>
<div class="row d-flex justify-content-flex-start">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="maskStatus">当前配置:</span>
</div>
<textarea class="form-control" id="maskResponseArea"></textarea>
</div>
</div>
<div class="row d-flex justify-content-flex-start">
<h6 class="card-title" style="margin-top: 2%">Mock配置</h6>
<div class="input-group mb-3">
<div class="input-group-append">
<span class="input-group-text">参数</span>
</div>
<input type="text" class="form-control" placeholder="输入参数" id="mockArg">
<div class="input-group-append">
<button onclick="getMock()" type="button"
class="btn btn-outline-primary">get
</button>
</div>
<div class="input-group-append">
<button onclick="setMock()"
type="button" class="btn btn-outline-primary">set
</button>
</div>
</div>
</div>
<div class="row d-flex justify-content-flex-start">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="mockStatus">当前配置:</span>
</div>
<textarea class="form-control" id="mockResponseArea"></textarea>
</div>
</div>
<div class="row d-flex justify-content-flex-start">
<h6 class="card-title" style="margin-top: 2%">权限管理</h6>
</div>

View File

@ -443,6 +443,155 @@ function onExecuteResult(obj) {
}
}
function getMask() {
const argDiv = $('#maskArg')[0];
const request = {};
request.action = "getMask";
request.requestID = new Date().getTime() + "";
request.contractID = global.contractInstance;
const operation = $("#selectContractFunction")[0].value;
if (operation === " " && !operation) {
myToast("执行合约", "请选择合约方法!");
return;
}
//request.operation = operation;
request.arg = argDiv.value;
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(
toSign,
global.sm2Key.privateKey,
{hash: true, der: true});
localStorage.setItem("persisArg", JSON.stringify(request));
global.wssocket.send(JSON.stringify(request));
}
function setMask() {
const argDiv = $('#maskArg')[0];
const request = {};
request.action = "setMask";
request.requestID = new Date().getTime() + "";
request.contractID = global.contractInstance;
const operation = $("#selectContractFunction")[0].value;
if (operation === " " && !operation) {
myToast("执行合约", "请选择合约方法!");
return;
}
//request.operation = operation;
request.arg = argDiv.value;
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(
toSign,
global.sm2Key.privateKey,
{hash: true, der: true});
localStorage.setItem("persisArg", JSON.stringify(request));
global.wssocket.send(JSON.stringify(request));
}
function onGetMask(obj) {
console.log("onGetMask obj.data", obj.data);
try {
const result = obj;
$("#maskResponseArea")[0].value = JSON.stringify(obj.data);
} catch (e) {
$("#maskResponseArea")[0].value = JSON.stringify(obj.data);
}
}
function getMock() {
const argDiv = $('#mockArg')[0];
const request = {};
request.action = "getMock";
request.requestID = new Date().getTime() + "";
request.contractID = global.contractInstance;
const operation = $("#selectContractFunction")[0].value;
if (operation === " " && !operation) {
myToast("执行合约", "请选择合约方法!");
return;
}
//request.operation = operation;
request.arg = argDiv.value;
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(
toSign,
global.sm2Key.privateKey,
{hash: true, der: true});
localStorage.setItem("persisArg", JSON.stringify(request));
global.wssocket.send(JSON.stringify(request));
}
function setMock() {
const argDiv = $('#mockArg')[0];
const request = {};
request.action = "setMock";
request.requestID = new Date().getTime() + "";
request.contractID = global.contractInstance;
const operation = $("#selectContractFunction")[0].value;
if (operation === " " && !operation) {
myToast("执行合约", "请选择合约方法!");
return;
}
//request.operation = operation;
request.arg = argDiv.value;
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(
toSign,
global.sm2Key.privateKey,
{hash: true, der: true});
localStorage.setItem("persisArg", JSON.stringify(request));
global.wssocket.send(JSON.stringify(request));
}
function onGetMock(obj) {
console.log("onGetMask obj.data", obj.data);
try {
const result = obj;
$("#mockResponseArea")[0].value = JSON.stringify(obj.data);
} catch (e) {
$("#mockResponseArea")[0].value = JSON.stringify(obj.data);
}
}
function onHashResult(obj) {
$("#hashResult").html("数链指纹:" + obj.data);
}

View File

@ -200,6 +200,12 @@ function WSHandler(event) {
case 'onListLeakContractProcess':
onListLeakContractProcess(obj);
break;
case 'onGetMask':
onGetMask(obj);
break;
case 'onGetMock':
onGetMock(obj);
break;
default:
displayOutput(obj);
break;