From fe1dcf7e796b6c4fd7b70c0ef97ac607711c352b Mon Sep 17 00:00:00 2001 From: hongwei <1223101214@qq.com> Date: Mon, 9 Aug 2021 09:48:56 +0800 Subject: [PATCH] NodePortal --- NodePortal.html | 67 ++++++++++++++++ js/NodeContractInstances.js | 149 ++++++++++++++++++++++++++++++++++++ js/NodePortal.js | 6 ++ 3 files changed, 222 insertions(+) diff --git a/NodePortal.html b/NodePortal.html index 51b03ea..699a8f1 100644 --- a/NodePortal.html +++ b/NodePortal.html @@ -544,6 +544,73 @@ + +
+
Mask配置
+
+ +
+ 参数 +
+ + + +
+ +
+
+ +
+ +
+
+
+
+
+ 当前配置: +
+ + +
+
+ +
+
Mock配置
+
+ +
+ 参数 +
+ + + +
+ +
+
+ +
+ +
+
+
+
+
+ 当前配置: +
+ + +
+
+
权限管理
diff --git a/js/NodeContractInstances.js b/js/NodeContractInstances.js index 616ea0d..b6436c1 100644 --- a/js/NodeContractInstances.js +++ b/js/NodeContractInstances.js @@ -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); } diff --git a/js/NodePortal.js b/js/NodePortal.js index 531af64..9dc6256 100644 --- a/js/NodePortal.js +++ b/js/NodePortal.js @@ -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;