BDContract SDK ============== 除使用可视化的智能合约在线IDE外,用户还可使用WebSocket接口、Http接口、Bash接口来启动和运行合约. -------------- WebSocketSDK下载与安装 ---------------------- 合约SDK提供javascript版本与java版本的客户端。 java客户端的下载链接为:\ `java source <./_static/BDWareJavaClient.zip>`__\ 和\ `jar <./_static/BDWareConfigTool.zip>`__ 可参考java_source下的README.md及测试用例。 javascript的下载链接为:\ `js SDK <./_static/js/createWS.js>`__ 内置的SM2加密库链接:\ `sm2 SDK <./_static/js/sm2.js>`__ 建立连接 ~~~~~~~~ 建立与节点服务器之间的WebSocket连接. 参数 ^^^^ +---------+------------------------------------------------------------+ | 字段 | 值 | +=========+============================================================+ | url | 建立WebSocket的服务器URL. 使用\ ``http``\ 协议时, | | | 前缀为\ ``ws://``, | | | 如\ ``"ws://localhost:1717/SCIDE/SCExecutor"``; | | | 使用\ ``https``\ 协议时, 前缀为\ ``wss://`` | +---------+------------------------------------------------------------+ | msgHand | 收到服务器WebSocket回复后的回调函数, 用户可自行编写, | | ler | 也可参考下面提供的示例 | +---------+------------------------------------------------------------+ 请求示例 ^^^^^^^^ .. code:: javascript var url = "ws://127.0.0.1:1717/SCIDE/SCExecutor";//与Slave节点建立连接 //var url = "ws://127.0.0.1:1718/NodeCenterWS";//与Manager节点建立连接 var msgHandler = function(m){ console.log("recmsg:"); console.log(m); }; var onOpenHandler=undefined; wssocket = createWssocket(url,onOpenHandler,msgHandler); 返回结果示例 ^^^^^^^^^^^^ :: { receiveSeg: [Function (anonymous)], isSending: false, sendList: [], monitor: [Function (anonymous)], send: [Function (anonymous)], sendNextSegment: [Function (anonymous)], isOpen: [Function (anonymous)] } ping ~~~~ ``ping``\ 服务器测试 .. _参数-1: 参数 ^^^^ ====== ==== 字段 值 ====== ==== action ping ====== ==== .. _请求示例-1: 请求示例 ^^^^^^^^ :: var request = {}; request.action = "ping"; wssocket.send(JSON.stringify(request)); .. _返回结果示例-1: 返回结果示例 ^^^^^^^^^^^^ :: { "action":"pong" } 登录 ~~~~ 使用Websocket接口调用需要权限的接口时,不论是连接CenterPortal还是NodePortal必须先\ **登录**\ 。 登录的流程有3步: - 客户端向服务端建立连接,连接建立完成后发送{“action”:“getSessionID”}(可在onOpenHandler中实现) - 服务端收到请求后,会向客户端返回类似{“action”:“onGetSessionID”,“session”:“-4959947809200104526_session”}的结果 - 客户端收到onGetSessionID后,会使用本地的公私钥对sessionID进行签名,并调用login接口 - 服务端会返回onLogin的结果,data字段返回的是该公钥对应的角色。 -------------- 用户角色划分 ------------ 合约节点的角色划分 ~~~~~~~~~~~~~~~~~~ 在合约节点(NodePortal.html)中分为NodeManager/ContractProvider/ContractInstanceManager/ContractUser四类角色。 ======================= ========================================================================== 角色 说明 ======================= ========================================================================== NodeManager 该节点的管理者,拥有用户管理、节点配置等权限 ContractProvider 拥有编辑合约、开发合约代码、运行调试等权限 ContractInstanceManager 拥有启、停合约实例、配置合约实例IO等权限 ContractUser 拥有查看合约实例列表、调用合约等权限 Anonymous 匿名用户,可以调用合约,可以申请成为ContractProvider/InstanceManager等角色 ======================= ========================================================================== =============================== ==================== ========================================= 接口 说明 角色 =============================== ==================== ========================================= changeDumpPeriod 设置备份周期 ContractInstanceManager; createLedger 创建账本 ContractInstanceManager; dumpContract 手动备份 ContractInstanceManager; deleteMemoryFile 删除镜像 ContractInstanceManager; forkContract 迁移合约 ContractInstanceManager; getDumpPeriod 获取备份周期 ContractInstanceManager; killAllContract 停止全部实例 ContractInstanceManager; killContractProcess 停止某一实例 ContractInstanceManager; listMemoryFiles 列取某一实例的镜像 ContractInstanceManager; loadMemory 加载镜像 ContractInstanceManager; queryContractInstanceDOI 查询合约实例信息 ContractInstanceManager; rebuildHashIndex ContractInstanceManager; setPermission ContractProvider;ContractInstanceManager; startContract 启动合约 ContractInstanceManager; startContractBatched 废弃 ContractInstanceManager; startContractByYPK 启动合约 ContractInstanceManager; startContractInTempZips 废弃 ContractInstanceManager; startContractP2PTrustfully 启动合约(集群模式) ContractInstanceManager; updateContract ContractInstanceManager; connectTo 连接合约实例输出流 ContractInstanceManager;ContractUser; countContractLogGroupByAction ContractInstanceManager;ContractUser; countContractLogGroupByCategory ContractInstanceManager;ContractUser; getLastLog 查询日志 ContractInstanceManager;ContractUser; getLog 查询日志 ContractInstanceManager;ContractUser; getLogSize 查询日志 ContractInstanceManager;ContractUser; listAllContractProcess ContractInstanceManager;ContractUser; listContractProcess 查询合约实例列表 ContractInstanceManager;ContractUser; listLeakContractProcess ContractInstanceManager;ContractUser; queryContractLogByDate ContractInstanceManager;ContractUser; queryContractLogByKey ContractInstanceManager;ContractUser; queryContractLogByOffset ContractInstanceManager;ContractUser; queryContractLogDetail ContractInstanceManager;ContractUser; queryContractLogSize ContractInstanceManager;ContractUser; queryNodeLogByDate ContractInstanceManager;ContractUser; queryNodeLogByOffset ContractInstanceManager;ContractUser; queryNodeLogSize ContractInstanceManager;ContractUser; rebuildContractLogIndex ContractInstanceManager;ContractUser; rebuildNodeLogIndex ContractInstanceManager;ContractUser; changePublic ContractProvider; createFile 新建文件 ContractProvider; deleteFile 删除文件 ContractProvider; distributeContract ContractProvider; downloadContract ContractProvider; downloadContractFromOtherHost ContractProvider; generateAnnotationSample ContractProvider; generateAppDataAnalysis ContractProvider; generateAppDataSource ContractProvider; generateBDCoinEventProject ContractProvider; generateBDCoinProject ContractProvider; generateBiddingExample ContractProvider; generateCSVProject ContractProvider; generateContractExecutor ContractProvider; generateDAC4BDOA ContractProvider; generateDAC4BDOA_persist ContractProvider; generateDACSample ContractProvider; generateEmptyProject ContractProvider; generateEventPublisher ContractProvider; generateEventSubscriber ContractProvider; generateGasExample ContractProvider; generateHello ContractProvider; generateHttpExample ContractProvider; generateIncentives ContractProvider; generateJSONExample ContractProvider; generateLedgerExample ContractProvider; generateLedgerProject ContractProvider; generateLicenceManager ContractProvider; generateLoggerExample ContractProvider; generateMySQLExample ContractProvider; generateMySQLProject ContractProvider; generatePostgreSQLSample ContractProvider; generateReadme ContractProvider; generateRenderSample ContractProvider; generateRocksDBSample ContractProvider; generateSM2Example ContractProvider; generateStaticResource ContractProvider; generateTFLinux ContractProvider; generategenerateTFMac ContractProvider; getProject ContractProvider; getTemplateList ContractProvider; importContractInstanceCodeByDOI ContractProvider; listFile ContractProvider; listProject ContractProvider; listProjectPermission ContractProvider; listProjects ContractProvider; renameFile ContractProvider; saveFile ContractProvider; startContractAsDebug ContractProvider; uploadFile ContractProvider; compile ContractProvider;ContractInstanceManager; evaluates ContractProvider;ContractInstanceManager; executeContractP2PTrustfully ContractProvider;ContractInstanceManager; getCodeByID 查询代码 ContractProvider;ContractInstanceManager; getControlFlowByFileName ContractProvider;ContractInstanceManager; getGasValue ContractProvider;ContractInstanceManager; listCompiledFiles ContractProvider;ContractInstanceManager; queryContractResourceInfo ContractProvider;ContractInstanceManager; queryFreeResourceInfo ContractProvider;ContractInstanceManager; staticVerifyContract ContractProvider;ContractInstanceManager; writeDyjs ContractProvider;ContractInstanceManager; authNodeRole 授权角色 NodeManager; changeBDledger 修改账本配置 NodeManager; changeIpPort NodeManager; changeNodeCenter 修改集群地址 NodeManager; changeNodeName NodeManager; changeIpPort NodeManager; changeDOIPConfig NodeManager; changeYJSPath NodeManager; countNodeLogGroupByCategory NodeManager; countRole NodeManager; deleteRole NodeManager; downloadUUID 废弃 NodeManager; getEncodedUUID 废弃 NodeManager; getPeerID NodeManager; listAllAuthRole NodeManager; listNodeInfos NodeManager; listUnAuthRole NodeManager; loadConfig NodeManager; loadNodeConfig NodeManager; lockEdit NodeManager; unlockEdit NodeManager; updateConfig NodeManager; uploadLicence NodeManager; applyNodeRole 申请角色 任意角色 executeContract 调用合约 任意角色 getConnCount 任意角色 getHashAbstractLocally 任意角色 getHashLocally 任意角色 getNodeRoleDeprecated 查询当前角色 任意角色 getSessionID 任意角色 listAdapters 任意角色 listTheContractProcess 任意角色 login 登录 任意角色 longStr 任意角色 ping 任意角色 queryDataByHash 任意角色 queryDataByHashLocally 任意角色 queryHashByOffset 任意角色 queryHashByRequestID 任意角色 queryHashSize 任意角色 queryLedgers 任意角色 queryRole 任意角色 queryTransactionByHash 任意角色 sendTransaction 任意角色 setLogStage 任意角色 =============================== ==================== ========================================= 合约准入中心角色划分 ~~~~~~~~~~~~~~~~~~~~ 共分为两类角色:CenterManager和NodeManager。其中,CenterManager拥有对集群设置的权限。 NodeManager可以增加、删除节点等操作。 ============================= ============ ========================== 接口 说明 角色 ============================= ============ ========================== authNodeManager CenterManager; countActionLogByCategory CenterManager; countCMLogByCategory CenterManager; delete CenterManager; listAllUsers CenterManager; listApplyList CenterManager; listLicence CenterManager; queryActionLog CenterManager; queryCMLog CenterManager; updateLicence CenterManager; addNode CenterManager;NodeManager; changeNCFile CenterManager;NodeManager; changeOtherNC CenterManager;NodeManager; createTrustUnit 创建可信集群 CenterManager;NodeManager; deleteTrustUnit CenterManager;NodeManager; getNCFile CenterManager;NodeManager; getNodeTrustUnits CenterManager;NodeManager; getOtherNC CenterManager;NodeManager; listContractProcess CenterManager;NodeManager; listMultiPointContractProcess CenterManager;NodeManager; listNodes CenterManager;NodeManager; listTrustUnits CenterManager;NodeManager; queryUserStat CenterManager;NodeManager; stopMultiPointContractProcess CenterManager;NodeManager; applyRole NodeManager; executeContract 调用合约 任意角色 executeContractTrustfully 任意角色 getManagerPubkey 任意角色 getNodeRole 任意角色 getNodeSessionID 任意角色 getRole 任意角色 getSessionID 任意角色 login 登录 任意角色 ============================= ============ ========================== -------------- 合约节点Http接口 ---------------- ``http://xxx.xxx.xxx.xxx:1717/SCIDE/SCManager``\ 为提供Http接口服务的服务器 URL(\ ``xxx.xxx.xxx.xxx:1717``\ 为BDWare SCIDE运行的IP和端口号) , 用户可通过在URL后附加字段参数, 完成以下功能. ``http://xxx.xxx.xxx.xxx:18000/SCIDE/SCManager`` 为提供Http接口服务的服务器 URL(\ ``xxx.xxx.xxx.xxx:1717`` 为BDWare SCIDE运行的IP和端口号),用户可通过在URL后附加字段参数,完成以下功能: 用户管理类 ~~~~~~~~~~ .. _ping-1: ping ^^^^ ``ping``\ 服务器测试 方法 '''' GET .. _参数-2: 参数 '''' ====== ==== 字段 值 ====== ==== action ping ====== ==== .. _请求示例-2: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=ping .. _返回结果示例-2: 返回结果示例 '''''''''''' .. code:: json {"data":"pong"} 合约代码管理类 ~~~~~~~~~~~~~~ 下载合约项目 ^^^^^^^^^^^^ .. _方法-1: 方法 '''' GET .. _参数-3: 参数 '''' =========== ================ 字段 值 =========== ================ action downloadContract projectName 合约项目名 isPrivate 是否在私有目录下 pubKey 用户公钥 timestamp 时间戳 sign 签名 =========== ================ .. _请求示例-3: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=downloadContract&projectName=BDCoin&isPrivate=false&pubKey=0480204f4ef341359a5f64fcb11baf9ca2e6706ac20cba3 8b7ff78aa631e97346086e2d48fac2ba7f5b75ccbd19ebf495c0e6f9934d69e3b083da4d42e46c991e0c2ea8bb45d59f31f46d0ec700fb01f2fdd275 上传文件 ^^^^^^^^ .. _方法-2: 方法 '''' POST .. _参数-4: 参数 '''' ========= ================ 字段 值 ========= ================ path 文件上传路径 fileName 待上传文件名 isPrivate 是否在私有目录下 order 第几个数据包 count 数据包总数 timestamp 时间戳 sign 签名 ========= ================ .. _请求示例-4: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/Upload?path=/TEST/TEST.yjs&fileName=WechatIMG15.jpeg&isPrivate=true&order=0&count=3&pubKey=0480204f4ef341359a5f64fcb11baf9ca2e6706ac20cba36ca83066870cf2c1d5de6df67e24e68dde7934af9b31d94a6084281db3d32d5ce42ab8f75bf799aca05&sign=dd867469f5adf9986e4ea6215febeae50c7d4c3836d002cf8c17050dfca031fd2595ffa8646e9eeae53150d2cbaea690e27d818eaf5cea3632ee1b69c3307a4b631e97346086e2d48fac2ba7f5b75ccbd19ebf495c0e6f9934d69e3b083da4d42e46c991e0c2ea8bb45d59f31f46d0ec700fb01f2fdd275 .. _返回结果示例-3: 返回结果示例 '''''''''''' .. code:: json {"status":"true","data":"success"} 保存合约脚本 ^^^^^^^^^^^^ 向服务器发送请求, 向服务器本地保存合约脚本内容. .. _方法-3: 方法 '''' GET .. _参数-5: 参数 '''' ======= ============== 字段 值 ======= ============== action writeDyjs target 合约脚本文件名 content 合约脚本内容 ======= ============== .. _请求示例-5: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=writeDyjs&target=testyjs.yjs&content=contract%20shortc%7B%0A%09export%20function%20main(arg)%7B%0A%09%09return%20arg.length%3B%09%0A%09%7D%0A%7D .. _返回结果示例-4: 返回结果示例 '''''''''''' .. code:: json { "status": false, "action": "onWriteDyjs", "data": "success" } 后续用户可启动并调用该合约. 合约实例管理类 ~~~~~~~~~~~~~~ 查询合约进程 ^^^^^^^^^^^^ 向服务器发送请求, 查询服务器上已经启动的所有合约进程. .. _方法-4: 方法 '''' GET .. _参数-6: 参数 '''' ====== =================== 字段 值 ====== =================== action listContractProcess ====== =================== .. _请求示例-6: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=listContractProcess .. _返回结果示例-5: 返回结果示例 '''''''''''' .. code:: json { "status": false, "action": "onListContractProcess", "data": "[\n {\n \"id\": \"-562752842\",\n \"name\": \"shortc\",\n \"port\": \"1626\",\n \"times\": \"0 \",\n \"traffic\": \"32.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n }\n]" } 启动合约 ^^^^^^^^ 向服务器发送请求, 启动某个合约. .. _方法-5: 方法 '''' GET .. _参数-7: 参数 '''' ====== ================================= 字段 值 ====== ================================= action startContract script 合约脚本内容, 需进行进行URIEncode ====== ================================= .. _请求示例-7: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=startContract&script=contract%20shortc%7B%0A%09export%20function%20main(arg)%7B%0A%09%09return%20arg.length%3B%09%0A%09%7D%0A%7D .. _返回结果示例-6: 返回结果示例 '''''''''''' .. code:: json { "data": "{\"status\":\"Success\",\"result\":\"\"}", "action": "onStartContract", "cid": "-562752842", "executeTime": 1187 } 调用合约 ^^^^^^^^ 向服务器发送请求, 调用某个合约. .. _方法-6: 方法 '''' GET .. _参数-8: 参数 '''' =================== =========================== 字段 值 =================== =========================== action executeContract contractID 合约ID withDynamicAnalysis true/false 是否进行动态分析 operation 调用合约的方法名 arg 调用合约的参数 pubkey 可选,调用者公钥 signature 可选,签名 =================== =========================== 其中pubkey为sm2的公钥,计算方式如下: .. code:: javascript //sm2 可从sm2.js中加载获得。 signature = sm2.doSignature(contractID+"|"+operation+"|"+arg+"|"+pubkey,privateKey); .. _请求示例-8: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=executeContract&contractID=-620602333&operation=main&arg=hhh .. _返回结果示例-7: 返回结果示例 '''''''''''' .. code:: json { "data": "{\"status\":\"Success\",\"result\":\"3\"}", "action": "onExecuteResult", "executeTime": "13" } 批量启动合约 ^^^^^^^^^^^^ 向服务器发送请求, 启动服务器中保存有合约脚本的一系列合约. .. _方法-7: 方法 '''' GET .. _参数-9: 参数 '''' ======== ==================================== 字段 值 ======== ==================================== action startContractBatched fileList 合约脚本文件列表(Json数组,URLEncode) ======== ==================================== .. _请求示例-9: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=startContractBatched&fileList=%5B%20%22EventPuber.yjs%22%2C%20%22EventSuber.yjs%22%2C%20%22LicenceManager.yjs%22%20%5D .. _返回结果示例-8: 返回结果示例 '''''''''''' .. code:: json {"EventPuber.yjs":"{\"status\":\"Success\",\"result\":\"\"}","LicenceManager.yjs":"{\"status\":\"Success\",\"result\":\"\"}","EventSuber.yjs":"{\"status\":\"Success\",\"result\":\"\"}","action":"onStartContract"} 启动Zip包合约 ^^^^^^^^^^^^^ 向服务器发送请求, 启动服务器中包装为\ ``zip``\ 格式的合约. .. _方法-8: 方法 '''' GET .. _参数-10: 参数 '''' ========= ======================= 字段 值 ========= ======================= action startContractInTempZips owner 调用者公钥 path zip合约(路径及)文件名 signature 调用者签名 ========= ======================= .. _请求示例-10: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=startContractInTempZips&owner=0475c7b061f32477c1e228dd04143daf58a5574dc3f6b02bd2857cc794eb92bfe98606dc314049e77fd8714f57a5a481cb470cc759e688fe60d40fc87092165e55&path=traceTest.zip&signature=650d3cad50509682937c253d84da99230e8ea1bcfb9b10f6d18f8888c7c4b6b4%2C72231a6daa078a3ce657c0a2ed38251b7db56cf725beaf86780d4c240b19ccc2 .. _返回结果示例-9: 返回结果示例 '''''''''''' .. code:: json {"data":"verify failed","action":"onStartContract"} 获取合约代码 ^^^^^^^^^^^^ 向服务器发送请求, 获取某个ID合约的脚本代码. .. _方法-9: 方法 '''' GET .. _参数-11: 参数 '''' ========== =========== 字段 值 ========== =========== action getCodeByID contractID 合约ID ========== =========== .. _请求示例-11: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=getCodeByID&contractID=814046805 .. _返回结果示例-10: 返回结果示例 '''''''''''' .. code:: json {"status":true,"action":"onCodeResult","data":"@LogType(\"Arg\")\ncontract EventSuberAtCHQ{\n\t\n \texport function init(arg){\n\t\tvar result \u003d YancloudUtil.subscribe(\"EventPuberAt3966\",\"abc\",handler);\n // print(\"Handler:\"+handler);\n \t \n \t\treturn result;\n\t}\n \texport function handler(e){\n var ret \u003d \"ReceiveEvent:\";\n\t\tret+\u003d\"\\n\";\n \tprint(ret);\n \tret+\u003dYancloudUtil.executeContract(\"EventPuberAt3966\",\"notify\",\"success\");\n \tprint(ret);\n return ret;\n\t}\n}\n"} 保存合约状态 ^^^^^^^^^^^^ 向服务器发送请求, 获取节点服务器的状态转移日志. .. _方法-10: 方法 '''' GET .. _参数-12: 参数 '''' ========== =================== 字段 值 ========== =================== action dumpContract contractID 合约ID 或 合约Name= ========== =================== .. _请求示例-12: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/SCManager?action=dumpContract&contractID=counter&pubKey=040461417efe01423ba603f71c689387e8aac4aa2a6f7cddfaf22c1d22c40222f7669a054e7ec2e8533b04ccbc7a0e6655ac4ae4acef81a2b1822ec6cabcaf6c1f&sign=3045022004ffd1346b936196f5b13953d2f3e11823a0d0a2d2f6fecea258cef8e20d99c0022100bbc219ed1f56799ba28a763b9e9e47063164e7ceecfbfa752de42f44551ffb83 .. _返回结果示例-11: 返回结果示例 '''''''''''' .. code:: json {"data":"success","size":"3.76 KB","time":"0.03s"} 获取合约内存文件列表 ^^^^^^^^^^^^^^^^^^^^ 向服务器发送请求, 获取某子文件夹中的所有内存文件列表. .. _方法-11: 方法 '''' GET .. _参数-13: 参数 '''' ========== ================== 字段 值 ========== ================== action listMemoryFiles contractID 合约Id 或 合约Name ========== ================== .. _请求示例-13: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/SCManager?action=listMemoryFiles&contractID=-247468535&pubKey=040461417efe01423ba603f71c689387e8aac4aa2a6f7cddfaf22c1d22c40222f7669a054e7ec2e8533b04ccbc7a0e6655ac4ae4acef81a2b1822ec6cabcaf6c1f&sign=3045022075c7268e888b0efdef167a3f4dfc6589d771c6be41b3c0a1dc12d057e811f395022100d44f460d0cc3643e169ef08231e75a1e895646c53295c0ef1d15c3b462a53d6b .. _返回结果示例-12: 返回结果示例 '''''''''''' .. code:: json {"data":["2020-09-23.18:40:38","2020-09-24.16:03:41","2020-09-24.16:58:39","2020-09-24.18:25:47","2020-09-24.18:32:37","2020-09-24.20:54:41","2020-09-24.20:57:39","2020-09-24.21:31:07","2020-09-24.21:32:09","2020-09-24.21:36:11","2020-09-28.15:29:15","2020-09-28.20:28:29","2020-09-28.20:39:46","2020-09-28.21:45:31","2020-09-28.21:49:18","2020-09-28.22:27:34","2020-09-28.22:31:09","2020-09-28.22:32:49","2020-10-07.16:51:06","2020-10-07.16:51:23","2020-10-25.21:09:10","2020-12-14.19:06:53","2021-02-02.10:28:56","2021-02-02.10:31:13"],"action":"onListMemoryFiles"} 停止合约 ^^^^^^^^ 向服务器发送请求, 停止某个合约. .. _方法-12: 方法 '''' GET .. _参数-14: 参数 '''' =========== =================== 字段 值 =========== =================== action killContractProcess id 合约ID \*requestID 请求ID, String类型 =========== =================== ``*``\ 表示可选参数 .. _请求示例-14: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=killContractProcess&id=-1759263594 .. _返回结果示例-13: 返回结果示例 '''''''''''' .. code:: json {"status":false,"action":"onListContractProcess","data":"[\n {\n \"id\": \"-65051856\",\n \"name\": \"EventSuber\",\n \"port\": \"1631\",\n \"times\": \"0 \",\n \"traffic\": \"32.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n },\n {\n \"id\": \"814046805\",\n \"name\": \"EventSuberAtCHQ\",\n \"port\": \"1630\",\n \"times\": \"0 \",\n \"traffic\": \"32.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n },\n {\n \"id\": \"2023975189\",\n \"name\": \"LicenceService\",\n \"port\": \"1632\",\n \"times\": \"0 \",\n \"traffic\": \"32.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n },\n {\n \"id\": \"-620602333\",\n \"name\": \"shortc\",\n \"port\": \"1627\",\n \"times\": \"0 \",\n \"traffic\": \"0.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n }\n]"} 停止所有合约 ^^^^^^^^^^^^ 向服务器发送请求, 停止服务器上启动的所有合约. .. _方法-13: 方法 '''' GET .. _参数-15: 参数 '''' ====== =============== 字段 值 ====== =============== action killAllContract ====== =============== .. _请求示例-15: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=killAllContract .. _返回结果示例-14: 返回结果示例 '''''''''''' .. code:: json {"status":false,"action":"onKillAllContract","data":"Kill:7357,7541,7548,7555,7584,7585,7591,7598,7609,7612,8440,8442,8444,8521,"} 静态分析合约 ^^^^^^^^^^^^ 向服务器发送请求, 静态分析合约脚本. .. _方法-14: 方法 '''' GET .. _参数-16: 参数 '''' ========== ==================== 字段 值 ========== ==================== action staticVerifyContract contractid 合约ID script 请求ID, String类型 ========== ==================== .. _请求示例-16: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=staticVerifyContract&contractid=943728900&script=contract%20shortc%7B%0A%09export%20function%20main(arg)%7B%0A%09%09return%20arg.length%3B%09%0A%09%7D%0A%7D&path=static.yjs .. _返回结果示例-15: 返回结果示例 '''''''''''' .. code:: json {"data":"{\"status\":\"Success\",\"result\":\"{\\\"main\\\":\\\"Ret:arg \\\"}\"}","action":"onExecuteResult","cid":"943728900","executeTime":54} 获取合约静态分析流 ^^^^^^^^^^^^^^^^^^ 向服务器发送请求, 获取某个合约的静态分析Control Flow. .. _方法-15: 方法 '''' GET .. _参数-17: 参数 '''' ====== ======================== 字段 值 ====== ======================== action getControlFlowByFileName path 合约ID ====== ======================== .. _请求示例-17: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=getControlFlowByFileName&path=EventSuber.yjs .. _返回结果示例-16: 返回结果示例 '''''''''''' .. code:: json {"init":{"blocks":[{"type":"Continuous","name":"B0","stmts":["\u003dL0\u003d","aload 0","invokevirtual wrp/jdk/nashorn/internal/runtime/ScriptFunction getScope ()Lwrp/jdk/nashorn/internal/runtime/ScriptObject;"],"original":""},{"type":"Continuous","name":"B1","stmts":["\u003dL1\u003d","astore 4"],"original":""},{"type":"Continuous","name":"B2","stmts":["\u003dL2\u003d","aload 4","invokedynamic dyn:getProp|getElem|getMethod:YancloudUtil (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 5 "],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B3","stmts":["dup","invokedynamic dyn:getMethod|getProp|getElem:subscribe (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 0 "],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B4","stmts":["swap","ldc XiaomiSmartHomeAtPKU","ldc onAirPurifierModeChange","aload 4","invokedynamic dyn:getProp|getElem|getMethod:handler (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 5 "],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B5","stmts":["invokedynamic dyn:call:\\\u003dYancloudUtil\\,subscribe (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 0 "],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B6","stmts":["\u003dL3\u003d","astore 5"],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B7","stmts":["\u003dL4\u003d","aload 5","areturn"],"original":" \t\treturn result;"},{"type":"Continuous","name":"B8","stmts":["\u003dL5\u003d"],"original":" \t\treturn result;"},{"type":"Continuous","name":"B9","stmts":["\u003dL6\u003d"],"original":" \t\treturn result;"}],"edges":[{"from":"B0","to":"B1","label":{"label":"e"}},{"from":"B1","to":"B2","label":{"label":"e"}},{"from":"B2","to":"B3","label":{"label":"e"}},{"from":"B3","to":"B4","label":{"label":"e"}},{"from":"B4","to":"B5","label":{"label":"e"}},{"from":"B5","to":"B6","label":{"label":"e"}},{"from":"B6","to":"B7","label":{"label":"e"}},{"from":"B7","to":"B9","label":{"label":"e"}}]},"handler":{"blocks":[{"type":"Continuous","name":"B0","stmts":["\u003dL0\u003d","aload 0","invokevirtual wrp/jdk/nashorn/internal/runtime/ScriptFunction getScope ()Lwrp/jdk/nashorn/internal/runtime/ScriptObject;"],"original":""},{"type":"Continuous","name":"B1","stmts":["\u003dL1\u003d","astore 4"],"original":""},{"type":"Continuous","name":"B2","stmts":["\u003dL2\u003d","ldc ReceiveEvent:","aload 2","invokedynamic dyn:getProp|getElem|getMethod:content (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 0 "],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B3","stmts":["invokestatic wrp/jdk/nashorn/internal/runtime/ScriptRuntime ADD (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B4","stmts":["ldc ","invokestatic wrp/jdk/nashorn/internal/runtime/ScriptRuntime ADD (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B5","stmts":["aload 2","invokedynamic dyn:getProp|getElem|getMethod:type (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 0 "],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B6","stmts":["invokestatic wrp/jdk/nashorn/internal/runtime/ScriptRuntime ADD (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B7","stmts":["\u003dL3\u003d","astore 5"],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B8","stmts":["\u003dL4\u003d","aload 4","invokedynamic dyn:getMethod|getProp|getElem:print (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 5 "],"original":" \tprint(ret);"},{"type":"Continuous","name":"B9","stmts":["getstatic wrp/jdk/nashorn/internal/runtime/ScriptRuntime UNDEFINED Lwrp/jdk/nashorn/internal/runtime/Undefined;","aload 5","invokedynamic dyn:call:print (Ljava/lang/Object;Lwrp/jdk/nashorn/internal/runtime/Undefined;Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 5 "],"original":" \tprint(ret);"},{"type":"Continuous","name":"B10","stmts":["pop"],"original":" \tprint(ret);"},{"type":"Continuous","name":"B11","stmts":["\u003dL5\u003d","aload 5","areturn"],"original":" return ret;"},{"type":"Continuous","name":"B12","stmts":["\u003dL6\u003d"],"original":" return ret;"},{"type":"Continuous","name":"B13","stmts":["\u003dL7\u003d"],"original":" return ret;"}],"edges":[{"from":"B0","to":"B1","label":{"label":"e"}},{"from":"B1","to":"B2","label":{"label":"e"}},{"from":"B2","to":"B3","label":{"label":"e"}},{"from":"B3","to":"B4","label":{"label":"e"}},{"from":"B4","to":"B5","label":{"label":"e"}},{"from":"B5","to":"B6","label":{"label":"e"}},{"from":"B6","to":"B7","label":{"label":"e"}},{"from":"B7","to":"B8","label":{"label":"e"}},{"from":"B8","to":"B9","label":{"label":"e"}},{"from":"B9","to":"B10","label":{"label":"e"}},{"from":"B10","to":"B11","label":{"label":"e"}},{"from":"B11","to":"B13","label":{"label":"e"}}]}} 日志查看类 ~~~~~~~~~~ 合约日志-查询数量 ^^^^^^^^^^^^^^^^^ .. _方法-16: 方法 '''' GET contractName为空或是不传入时,则为查询全部合约的条数 .. _参数-18: 参数 '''' ============ ======================== 字段 值 ============ ======================== action queryContractLogSize contractName 字符串,非必须,合约名称 ============ ======================== .. _请求示例-18: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryContractLogSize&contractName=NanningDataSource .. _返回结果示例-17: 返回结果示例 '''''''''''' .. code:: json { "size": 12, "action": "onQueryContractLogSize", "status": "success" } 合约日志-根据日期查询 ^^^^^^^^^^^^^^^^^^^^^ .. _方法-17: 方法 '''' GET .. _参数-19: 参数 '''' ============ ===================================== 字段 值 ============ ===================================== action queryContractLogByDate start long,必须,起始时间 end long,非必须,若无end,默认为当前时间 contractName 字符串,非必须,合约名称 ============ ===================================== .. _请求示例-19: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryContractLogByDate&start=1597296300272&end=1597296305747 返回结果 '''''''' .. code:: json { "data": [ { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "getMainFrame", "costTime": "2493", "totalGas": "0", "executionGas": "0", "extraGas": "0", "date": 1597296300272, "key": "-8590335427581967208" }, { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "loadResource", "costTime": "732", "totalGas": "0", "executionGas": "0", "extraGas": "0", "date": 1597296301030, "key": "849660532962309239" }, { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "loadResource", "costTime": "4580", "totalGas": "0", "executionGas": "0", "extraGas": "0", "date": 1597296305745, "key": "-8003529429500512736" }, { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "loadResource", "costTime": "4551", "totalGas": "0", "executionGas": "0", "extraGas": "0", "date": 1597296305746, "key": "7604666709899222357" }, { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "loadResource", "costTime": "6", "totalGas": "0", "executionGas": "0", "extraGas": "0", "date": 1597296305751, "key": "-7561786202695627022" } ], "action": "onQueryRecentContractLog" } 合约日志-根据偏移量查询 ^^^^^^^^^^^^^^^^^^^^^^^ .. _方法-18: 方法 '''' GET .. _参数-20: 参数 '''' ============ ============================================= 字段 值 ============ ============================================= action queryContractLogByOffset count long,必须,获取日志条数 offset long,非必须,若无offset,默认返回最新count条 contractName 字符串,非必须,合约名称 ============ ============================================= .. _请求示例-20: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryContractLogByOffset&count=5&contractName=NanningDataSource .. _返回结果-1: 返回结果 '''''''' .. code:: json { "data": [ { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "loadResource", "costTime": "4", "totalGas": "0", "executionGas": "0", "extraGas": "0", "date": 1597296305842, "key": "-2390672423847654148" }, { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "isOwner", "costTime": "4", "totalGas": "0", "executionGas": "0", "extraGas": "0", "date": 1597296305868, "key": "6056586201629372511" }, { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "getApplyList", "costTime": "6", "totalGas": "0", "executionGas": "0", "extraGas": "0", "date": 1597296305893, "key": "3882409580676458151" }, { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "getAcceptList", "costTime": "4", "totalGas": "0", "executionGas": "0", "extraGas": "0", "date": 1597296305908, "key": "-3437513873417136535" }, { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "analysisByIndustry", "costTime": "6", "totalGas": "0", "executionGas": "0", "extraGas": "0", "signature": "4c2cef1756b2b591ab7eead19d67331e2294c7ba765c72298733c306ada0b6e84afbb6c7b9dba48b9843236ebe67aecb4af09fe58a51eef0e2e89b9f3e5cad02", "arg": " {\"year\":2018,\"category\":\"工业\",\"indexType\":\"营业额\"}", "date": 1597296314654, "key": "203156239086062402" } ], "action": "onQueryRecentContractLog" } 合约日志-根据key查询 ^^^^^^^^^^^^^^^^^^^^ .. _方法-19: 方法 '''' GET .. _参数-21: 参数 '''' ====== =========================== 字段 值 ====== =========================== action queryContractLogByKey key long,必须,该日志对应的key ====== =========================== .. _请求示例-21: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryContractLogByKey&key=203156239086062402 .. _返回结果-2: 返回结果 '''''''' .. code:: json { "data": { "action": "executeContract", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "contractID": "-1382208250", "contractName": "NanningDataSource", "function": "analysisByIndustry", "costTime": "6", "totalGas": "0", "executionGas": "0", "extraGas": "0", "signature": "4c2cef1756b2b591ab7eead19d67331e2294c7ba765c72298733c306ada0b6e84afbb6c7b9dba48b9843236ebe67aecb4af09fe58a51eef0e2e89b9f3e5cad02", "arg": " {\"year\":2018,\"category\":\"工业\",\"indexType\":\"营业额\"}", "date": 1597296314654 }, "action": "onQueryContractLogByKey" } 合约日志-按时间段统计调用次数 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. _方法-20: 方法 '''' GET .. _参数-22: 参数 '''' ======== ======================================================== 字段 值 ======== ======================================================== action countContractLogGroupByCategory start long,必须,起始时间 end 非必须,终止时间,默认为当前 interval long,非必须,统计间隔 category 非必须,合约名称以逗号连接,不传入时统计全部合约调用情况 ======== ======================================================== .. _请求示例-22: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=countContractLogGroupByCategory&start=1596758400000&interval=86400000 .. _返回结果-3: 返回结果 '''''''' .. code:: json { "start": 1596758400000, "interval": 86400000, "action": "onCountContractLogGroupByCategory", "data": [ 0, 0, 0, 0, 0, 0, 43, 14 ] } 账本日志-查询数量 ^^^^^^^^^^^^^^^^^ 查询通过本节点去账本上记录的日志数量 .. _方法-21: 方法 '''' GET .. _参数-23: 参数 '''' ============ ================ 字段 值 ============ ================ action queryHashSize contractName 非必须,合约名称 ============ ================ .. _请求示例-23: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryHashSize&contractName=NanningDataSource .. _返回结果-4: 返回结果 '''''''' .. code:: json { "count": "2", "action": "onQueryHashSize" } 账本日志-根据偏移量查询 ^^^^^^^^^^^^^^^^^^^^^^^ 查询x条通过本节点去账本上记录的日志的哈希列表 .. _方法-22: 方法 '''' GET .. _参数-24: 参数 '''' ============ =========================================================== 字段 值 ============ =========================================================== action queryHashByOffset count 整数,必须,表示条数 offset 整数,非必须,表示偏移量,不传入offset则默认返回最新count条 contractName 字符串,非必须,表示合约名称 ============ =========================================================== .. _请求示例-24: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryHashByOffset&count=1&contractName=NanningDataSource .. _返回结果-5: 返回结果 '''''''' .. code:: json { "data": [ { "hash": "3a6c60621907146b77146c1f2d48700e47520173", "date": 1597296314658 } ], "action": "onQueryHash", "status": "success" } 账本日志-根据hash查询详情 ^^^^^^^^^^^^^^^^^^^^^^^^^ 根据hash来查询日志内容 .. _方法-23: 方法 '''' GET .. _参数-25: 参数 '''' ====== =============================== 字段 值 ====== =============================== action queryDataByHash hash 字符串,可通过queryHashByOffset ====== =============================== .. _请求示例-25: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryDataByHash&count=1&contractName=NanningDataSource&hash=3a6c60621907146b77146c1f2d48700e47520173 .. _返回结果-6: 返回结果 '''''''' .. code:: json { "from": "0x3034643139323433323966373263656431343866", "to": "0x65786563757465436f6e74726163740000000000", "data": "1597296314655 --> {\"extraGas\":\"0\",\"totalGas\":\"0\",\"executionGas\":\"0\",\"signature\":\"4c2cef1756b2b591ab7eead19d67331e2294c7ba765c72298733c306ada0b6e84afbb6c7b9dba48b9843236ebe67aecb4af09fe58a51eef0e2e89b9f3e5cad02\",\"costTime\":\"6\",\"arg\":\" {\\\\\\\"year\\\\\\\":2018,\\\\\\\"category\\\\\\\":\\\\\\\"工业\\\\\\\",\\\\\\\"indexType\\\\\\\":\\\\\\\"营业额\\\\\\\"}\",\"contractID\":\"-1382208250\",\"action\":\"analysisByIndustry\",\"pubKey\":\"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}", "requestID": "1597296314629_6067", "action": "onQueryDataByHash" } 账本日志-根据requestID查询Hash ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 根据requestID来查询日志内容,需由开发者保证requestID的唯一性 .. _方法-24: 方法 '''' GET .. _参数-26: 参数 '''' ========= ======================== 字段 值 ========= ======================== action queryHashByRequestID requestID 字符串,在发起调用时生成 ========= ======================== .. _请求示例-26: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=queryHashByRequestID&requestID=0987654321ab 节点日志-查询数量 ^^^^^^^^^^^^^^^^^ .. _方法-25: 方法 '''' GET .. _参数-27: 参数 '''' ======== ============================ 字段 值 ======== ============================ action queryNodeLogSize category 非必须,不传入时查询全部情况 ======== ============================ 其中包括:ping、startContract、saveFile等。 .. _请求示例-27: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogSize http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogSize&category=login .. _返回结果-7: 返回结果 '''''''' .. code:: json { "size": 177, "action": "onQueryNodeLogSize", "status": "success" } 节点日志-按日期查询 ^^^^^^^^^^^^^^^^^^^ .. _方法-26: 方法 '''' GET .. _参数-28: 参数 '''' ======== ============================ 字段 值 ======== ============================ action queryNodeLogByDate start long,必须,起始日期 end long,非必须 category 非必须,不传入时查询全部情况 ======== ============================ .. _请求示例-28: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogByDate&start=1597376006441 http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogByDate&start=1596758400000&category=login .. _返回结果-8: 返回结果 '''''''' .. code:: json { "data": [ { "action": "listAllAuthRole", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006438, "key": "387355870552374748" }, { "action": "listUnAuthRole", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006441, "key": "4772693258708933626" }, { "action": "countRole", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006444, "key": "-6425375229108830572" }, { "action": "loadNodeConfig", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006448, "key": "-6602401010405792959" }, { "action": "getPeerID", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006449, "key": "-7006776427870311552" } ], "action": "onQueryNodeLogByDate" } 节点日志-按偏移量查询 ^^^^^^^^^^^^^^^^^^^^^ .. _方法-27: 方法 '''' GET .. _参数-29: 参数 '''' ============ ============================================= 字段 值 ============ ============================================= action queryNodeLogByOffset count long,必须,获取日志条数 offset long,非必须,若无offset,默认返回最新count条 contractName 字符串,非必须,合约名称 ============ ============================================= .. _请求示例-29: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogByOffset&count=5 .. _返回结果-9: 返回结果 '''''''' .. code:: json { "data": [ { "action": "listAllAuthRole", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006438, "key": "387355870552374748" }, { "action": "listUnAuthRole", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006441, "key": "4772693258708933626" }, { "action": "countRole", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006444, "key": "-6425375229108830572" }, { "action": "loadNodeConfig", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006448, "key": "-6602401010405792959" }, { "action": "getPeerID", "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "status": "accept", "date": 1597376006449, "key": "-7006776427870311552" } ], "action": "onQueryNodeLogByOffset" } 节点日志-按时间段统计调用次数 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. _方法-28: 方法 '''' GET .. _参数-30: 参数 '''' ======== ================================================== 字段 值 ======== ================================================== action countLogGroupByCategory start long,必须,起始时间 end 非必须,终止时间,默认为当前 interval long,非必须,统计间隔 category 非必须,action以逗号连接,不传入时统计全部调用情况 ======== ================================================== 其中,category中的action为NodePortal的接口的action集合。 包括:ping、startContract、saveFile等。 .. _请求示例-30: 请求示例 '''''''' :: http://127.0.0.1:18000/SCIDE/CMManager?action=countNodeLogGroupByCategory&start=1596758400000&interval=86400000 http://127.0.0.1:18000/SCIDE/CMManager?action=countNodeLogGroupByCategory&start=1596758400000&interval=86400000&category=ping,startContract .. _返回结果-10: 返回结果 '''''''' .. code:: json { "start": 1596758400000, "interval": 86400000, "action": "onCountNodeLogGroupByCategory", "data": [ 0, 0, 0, 0, 0, 0, 912, 761 ] } 输出历史记录日志 ^^^^^^^^^^^^^^^^ 向服务器发送请求, 获取节点服务器上合约的TimeTravel日志. .. _方法-29: 方法 '''' GET .. _参数-31: 参数 '''' ====== ================== 字段 值 ====== ================== action printTimeTravelLog ====== ================== .. _请求示例-31: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=printTimeTravelLog .. _返回结果示例-18: 返回结果示例 '''''''''''' .. code:: json {"status":false,"data":"[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/aa\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/aa_1572335939893.dyjs\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/memoryDumps\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/.\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/.\n"} 输出节点转移日志 ^^^^^^^^^^^^^^^^ 向服务器发送请求, 获取节点服务器的状态转移日志. .. _方法-30: 方法 '''' GET .. _参数-32: 参数 '''' ====== ================ 字段 值 ====== ================ action printTransferLog ====== ================ .. _请求示例-32: 请求示例 '''''''' :: http://127.0.0.1:1717/SCIDE/SCManager?action=printTransferLog .. _返回结果示例-19: 返回结果示例 '''''''''''' .. code:: json {"status":false,"data":""} 模板生成类 ~~~~~~~~~~ -------------- 合约节点WebSocket接口 --------------------- .. _用户管理类-1: 用户管理类 ~~~~~~~~~~ 获取Session ^^^^^^^^^^^ 登录前获取session以便进行签名。 .. _参数-33: 参数 '''' ====== ============ 字段 值 ====== ============ action getSessionID ====== ============ .. _请求示例-33: 请求示例 '''''''' :: var req = {}; req.action = "getSessionID"; wssocket.send(JSON.stringify(req)); .. _返回结果-11: 返回结果 '''''''' .. code:: json { "action": "onSessionID", "session": "9782323_session" } 用户登录 ^^^^^^^^ 用户进行公私钥身份验证 .. _参数-34: 参数 '''' ====== ===== 字段 值 ====== ===== action login ====== ===== .. _请求示例-34: 请求示例 '''''''' :: var loginParam = {}; loginParam.pubKey = global.sm2Key.publicKey; loginParam.signature = sm2.doSignature(global.session, global.sm2Key.privateKey); loginParam.action = "login"; wssocket.send(JSON.stringify(loginParam)); .. _返回结果-12: 返回结果 '''''''' .. code:: json { "action": "onLogin", "data": "NodeManager,ContractProvider" } 申请角色 ^^^^^^^^ 在节点管理员界面申请可以申请称为合约管理员(ContractInstanceManager)、合约使用者(ContractUser)、合约提供者(ContractProvider) .. _参数-35: 参数 '''' ====== ============= 字段 值 ====== ============= action applyNodeRole role 申请角色名称 ====== ============= .. _请求示例-35: 请求示例 '''''''' :: var param = {}; param.action = "applyNodeRole"; param.role = "ContractUser"; wssocket.send(JSON.stringify(param)); .. _返回结果-13: 返回结果 '''''''' .. code:: json { "action": "onApplyRole", "data": "success" } { "action":"onApplyRole", "data":"already has!" } 授权角色 ^^^^^^^^ .. _参数-36: 参数 '''' ======== ==================== 字段 值 ======== ==================== action authNodeRole isAccept bool类型,表示否授权 pubKey 授权用户公钥 ======== ==================== .. _请求示例-36: 请求示例 '''''''' :: var param = {}; param.action = "authNodeRole"; param.isAccept = true; param.pubKey = "xxxxx"; wssocket.send(JSON.stringify(param)); .. _返回结果-14: 返回结果 '''''''' .. code:: json { "action": "onAuthNodeRole", "data": "success" } 删除用户角色 ^^^^^^^^^^^^ .. _参数-37: 参数 '''' ====== ============ 字段 值 ====== ============ action deleteRole role 删除角色名称 ====== ============ .. _请求示例-37: 请求示例 '''''''' :: var deleteInfo = {}; deleteInfo.pubKey = global.authorizedUsers.[publicKey]; deleteInfo.action = "deleteRole"; deleteInfo.role="ContractUser"; wssocket.send(JSON.stringify(deleteInfo)); .. _返回结果-15: 返回结果 '''''''' .. code:: json { "action": "onDeleteRole", "data": "success" } 查看授权用户列表 ^^^^^^^^^^^^^^^^ 查看准入管理员当前组网中已经授权的节点管理员 .. _参数-38: 参数 '''' ====== =============== 字段 值 ====== =============== action listAllAuthRole ====== =============== .. _请求示例-38: 请求示例 '''''''' :: var param = {}; param.action = "listAllAuthRole"; wssocket.send(JSON.stringify(param)); .. _返回结果-16: 返回结果 '''''''' .. code:: json { "status":false, "action":"onListAllAuthRole", "data": { "kv":[{"key":"04eafad549d0757cf67f360815e15e157c7428c9ea9fb933f31a5d45bfb6edd9809c5bf6a5f37d7b817207f19fb2d76b7dbdefe38084cd3282e37b9ac39959dfab", "value":"NodeManager,ContractProvider,ContractUser,ContractInstanceManager"}], "time":[{"key":"04eafad549d0757cf67f360815e15e157c7428c9ea9fb933f31a5d45bfb6edd9809c5bf6a5f37d7b817207f19fb2d76b7dbdefe38084cd3282e37b9ac39959dfab", "value":"1617178709933"}] } } 查看申请用户列表 ^^^^^^^^^^^^^^^^ .. _参数-39: 参数 '''' ====== ============== 字段 值 ====== ============== action listUnAuthRole ====== ============== .. _请求示例-39: 请求示例 '''''''' :: var param = {}; param.action = "listUnAuthRole"; wssocket.send(JSON.stringify(param)); .. _返回结果-17: 返回结果 '''''''' .. code:: json { "action": "onListUnAuthRole", "kv": [{ "key": "049999ebd14ff3b96ebf7f7325e1da94a1c4c376573a1dc1cec2b4f7a3b09ed7b07252134e93b6ac2e1853268b82f4b541d34fb42b0182cd61043e99d3489e2cf7", "value": "ContractProvider,ContractUser" }], "time": [{ "key": "049999ebd14ff3b96ebf7f7325e1da94a1c4c376573a1dc1cec2b4f7a3b09ed7b07252134e93b6ac2e1853268b82f4b541d34fb42b0182cd61043e99d3489e2cf7", "value": "1587398989914" }] } 参数(删除) '''''''''' ====== ============= 字段 值 ====== ============= action queryUserStat ====== ============= .. _请求示例-40: 请求示例 '''''''' :: var param = {}; param.action = "queryUserStat"; wssocket.send(JSON.stringify(param)); .. _返回结果-18: 返回结果 '''''''' .. code:: json { "action": "onQueryUserStat", "userListCount": 3, "applyListCount":0 } .. _合约代码管理类-1: 合约代码管理类 ~~~~~~~~~~~~~~ 获取公共合约文件列表 ^^^^^^^^^^^^^^^^^^^^ .. _参数-40: 参数 '''' ====== ============ 字段 值 ====== ============ action listProjects ====== ============ .. _请求示例-41: 请求示例 '''''''' :: var request = {}; request.action = "listProjects"; wssocket.send(JSON.stringify(request)); .. _返回结果-19: 返回结果 '''''''' .. code:: json { "action":"onListProjects", "data":"[\"AnnotationSample\",\"AppDataAnalysis\",\"AppDataSource\",\"BiddingExample\",\"ContractExecutor\"]", "executeTime":0, "isPrivate":false } 获取私有合约文件列表 ^^^^^^^^^^^^^^^^^^^^ .. _参数-41: 参数 '''' ========= ============ 字段 值 ========= ============ action listProjects pubKey 该用户的公钥 isPrivate true ========= ============ .. _请求示例-42: 请求示例 '''''''' .. code:: javascript var request = {}; request.action = "listProjects"; request.pubKey = "global.sm2.publicKey"; request.isPrivate=true; wssocket.send(JSON.stringify(request)); .. _返回结果-20: 返回结果 '''''''' .. code:: json { "action":"onListProjects", "data":"[\"CSVFromTemplate\",\"Empty22\",\"MySQLFromTemplate\",\"test\"]", "executeTime":0, "isPrivate":true } 获取合约实例 ^^^^^^^^^^^^ .. _参数-42: 参数 '''' ====== =================== 字段 值 ====== =================== action listContractProcess ====== =================== .. _请求示例-43: 请求示例 '''''''' :: var request = {}; request.action = "listContractProcess"; wssocket.send(JSON.stringify(request)); .. _返回结果-21: 返回结果 '''''''' .. code:: json { "status":false, "action":"onListContractProcess", "data":"[{\"id\": \"1658407837\",\"name\": \"BDCoin\",\"port\": \"1617\"}]" } .. _启动合约-1: 启动合约 ^^^^^^^^ .. _参数-43: 参数 '''' ========= ============= 字段 值 ========= ============= action startContract owner pubkey requestID 当前时间 script 脚本内容 signature 签名 ========= ============= .. _请求示例-44: 请求示例 '''''''' :: request.action = "startContract"; request.owner = global.sm2Key.publicKey; request.requestID = new Date().getTime() + ""; request.script = global.projectScript; request.signature = sm2.doSignature("Algorithm|" + request.script + "|" + global.sm2Key.publicKey, global.sm2Key.privateKey); wssocket.send(JSON.stringify(request)); .. _返回结果-22: 返回结果 '''''''' .. code:: json { "data":"{\"needSeq\":false,\"seq\":0,\"status\":\"Success\",\"result\":\"\",\"isInsnLimit\":false,\"totalGas\":0,\"executionGas\":0,\"extraGas\":0,\"size\":0,\"eventRelated\":false}", "action":"onStartContract", "cid":"-506393888", "executeTime":2496, "responseID":"1617206735696" } 启动可信集群合约 ^^^^^^^^^^^^^^^^ .. _参数-44: 参数 '''' ========= ==================================== 字段 值 ========= ==================================== action startContractP2PTrustfully owner pubkey isPrivate 当前时间 path 脚本所在路径 signature 签名 peersID 可信执行集群中的节点peerID组成的数组 \ ========= ==================================== .. _请求示例-45: 请求示例 '''''''' .. code:: javascript var request = {}; request.action = "startContractP2PTrustfully"; request.peersID = ["3r729hf2ehf982","sjdfiwoehfwoi34","wnfnwoeifnwenef"]; var project = "JsonTest"; request.path = "/" + project + "/mainfest.json"; request.isPrivate = false; request.signature = sm2.doSignature("Trusted|" + request.path + "|" + global.sm2Key.publicKey, global.sm2Key.privateKey); //合约的签名 request.resultcheck = $("#resultcheck")[0].value; wssocket.send(JSON.stringify(request)); .. _返回结果-23: 返回结果 '''''''' .. code:: json { "data":"{\"status\":\"Success\",\"result\":\"\"}", "action":"onStartContractP2PTrustfully", "cid":"-1543583350", "executeTime":1544 } 分发合约项目 ^^^^^^^^^^^^ .. _参数-45: 参数 '''' ============= ================== 字段 值 ============= ================== action distributeContract peersID 集群中节点peer projectName 合约名 isPrivate 是否在私有目录 sponsorPeerID 发起者ID signature 签名 ============= ================== .. _请求示例-46: 请求示例 '''''''' .. code:: javascript request.action = "distributeContract"; request.peersID = peersID; request.projectName = global.projects[global.lastClickedProjectId]; request.isPrivate = $("#privateDir-tab").hasClass("active"); request.sponsorPeerID = global.peerID; request.signature = sm2.doSignature("DistributeContract|" + request.projectName + "|" + global.sm2Key.publicKey, global.sm2Key.privateKey); wssocket.send(JSON.stringify(request)); .. _返回结果-24: 返回结果 '''''''' .. code:: json { "action":"onDistributeContract", "progress":"100.00%" } 终止合约 ^^^^^^^^ .. _参数-46: 参数 '''' ========= =================== 字段 值 ========= =================== action killContractProcess id 合约id requestID 请求ID ========= =================== .. _请求示例-47: 请求示例 '''''''' :: request.action = "killContractProcess"; request.id = contractid; request.requestID = new Date().getTime() + ""; wssocket.send(JSON.stringify(request)); .. _返回结果-25: 返回结果 '''''''' .. code:: json { "data": "ContractHandler: exit in 3 seconds!", "action": "onOutputStream" } 终止所有合约 ^^^^^^^^^^^^ .. _参数-47: 参数 '''' ====== =============== 字段 值 ====== =============== action killAllContract ====== =============== .. _请求示例-48: 请求示例 '''''''' :: request.action = "killAllContract"; wssocket.send(JSON.stringify(request)); .. _返回结果-26: 返回结果 '''''''' .. code:: json { "status":false, "action":"onKillAllContract", "data":"Kill:7241,7245," } .. _静态分析合约-1: 静态分析合约 ^^^^^^^^^^^^ .. _参数-48: 参数 '''' ========== ==================== 字段 值 ========== ==================== action staticVerifyContract owner 用户私钥 isPartial 是否是部分 contractid contractid script 脚本内容 path 合约文件名 ========== ==================== .. _请求示例-49: 请求示例 '''''''' .. code:: javascript request.action = "staticVerifyContract"; request.owner = global.sm2Key.privateKey request.isPartial = false; request.contractid = contractid; request.script = global.projectScript; request.path = global.projectName; wssocket.send(JSON.stringify(request)); .. _返回结果-27: 返回结果 '''''''' .. code:: json { "data":"{\"needSeq\":false,\"seq\":0,\"status\":\"Success\",\"result\":{\"hello\":\"Ret:\"},\"isInsnLimit\":false,\"totalGas\":0,\"executionGas\":0,\"extraGas\":0,\"size\":0,\"eventRelated\":false}", "action":"onStaticVerifyResult", "cid":"verify", "executeTime":83 } 删除合约 ^^^^^^^^ .. _参数-49: 参数 '''' ====== ========== 字段 值 ====== ========== action deleteFile file fileName ====== ========== .. _请求示例-50: 请求示例 '''''''' .. code:: javascript request.action = "deleteFile"; request.file = fileName; wssocket.send(JSON.stringify(request)); .. _返回结果-28: 返回结果 '''''''' .. code:: json { "action":"onDeleteFile", "data":"success", "executeTime":0 } 私有合约传至公共目录 ^^^^^^^^^^^^^^^^^^^^ .. _参数-50: 参数 '''' ======== ============ 字段 值 ======== ============ action changePublic pubkey 用户公钥 fileName fileName ======== ============ .. _请求示例-51: 请求示例 '''''''' .. code:: javascript request.action = "changePublic"; request.pubkey = pubkey; request.fileName = fileName; wssocket.send(JSON.stringify(request)); .. _返回结果-29: 返回结果 '''''''' .. code:: json { "action":"onChangePublic", "data":"success", "executeTime":0 } 上传合约 ^^^^^^^^ .. _参数-51: 参数 '''' ========= ======================== 字段 值 ========= ======================== action UploadFile isAppend false fileName fileName path path isPrivate true/false content fileContent(base64编码) ========= ======================== .. _请求示例-52: 请求示例 '''''''' :: request.action = "uploadFile"; request.isAppend = false; request.fileName = "test1.yjs"; request.path = "test1"; text="Y29udHJhY3QgdGVzdDF7CglleHBvcnQgZnVuY3Rpb24gaGVsbG8oYXJnKXsgCiAgICAgICAgcmV0dXJuICJ3b3JsZCI7ICAKICAgIH0gICAKfQ==" request.content = text; wssocket.send(JSON.stringify(request)); .. _返回结果-30: 返回结果 '''''''' .. code:: json { "action":"onUploadFile", "data":"success", "executeTime":0 } 编译合约 ^^^^^^^^ .. _参数-52: 参数 '''' ========== ========================== 字段 值 ========== ========================== action compile path string, 待编译的项目名称 privateTab bool, 是否为私有目录的项目 ========== ========================== .. _请求示例-53: 请求示例 '''''''' .. code:: javascript var req = {"action":"compile","path":"Hello","privateTab":true} .. _返回结果-31: 返回结果 '''''''' .. code:: json {"result":"Hello_2020-08-17-09:09:40.ypk","action":"onCompile"} 锁定私有目录 ^^^^^^^^^^^^ 锁定某个用户的的私有目录编辑功能 .. _参数-53: 参数 '''' ====== ====================== 字段 值 ====== ====================== action lockEdit pubKey string, 要被锁定的公钥 ====== ====================== .. _请求示例-54: 请求示例 '''''''' .. code:: javascript var req = {}; req.action = "lockEdit"; req.pubKey = "xxxxxx"; wssocket.send(JSON.stringify(req)); .. code:: json { "action":"onLockEdit", "status":"success", "data":"04c4c855862b53f323e077ccfcc744ecc2c0a04645ed16d99ede8fd5866b38c0670a97ad22c6260d1a4672aba2a5fe229a2d4eba34627c054aab102620afa288c1" } 解锁私有目录 ^^^^^^^^^^^^ 解锁某个用户的的私有目录编辑功能 .. _参数-54: 参数 '''' ====== ====================== 字段 值 ====== ====================== action unLockEdit pubKey string, 要被锁定的公钥 ====== ====================== .. _请求示例-55: 请求示例 '''''''' .. code:: javascript var req = {}; req.action = unlockEdit; req.pubKey = "xxxxxx"; wssocket.send(JSON.stringify(req)); .. code:: json { "action":"onUnlockEdit", "status":"success", "data":"04c4c855862b53f323e077ccfcc744ecc2c0a04645ed16d99ede8fd5866b38c0670a97ad22c6260d1a4672aba2a5fe229a2d4eba34627c054aab102620afa288c1" } .. _合约实例管理类-1: 合约实例管理类 ~~~~~~~~~~~~~~ .. _查询合约进程-1: 查询合约进程 ^^^^^^^^^^^^ 向服务器发送请求, 查询服务器上已经启动的所有合约进程. .. _参数-55: 参数 '''' ====== =================== 字段 值 ====== =================== action listContractProcess ====== =================== .. _请求示例-56: 请求示例 '''''''' .. code:: javascript var request = {}; request.action = "listContractProcess"; wssocket.send(JSON.stringify(request)); .. _返回结果示例-20: 返回结果示例 '''''''''''' .. code:: json { "status": false, "action": "onListContractProcess", "data": "[...]" } .. _调用合约-1: 调用合约 ^^^^^^^^ 向服务器发送请求, 调用某个合约. .. _参数-56: 参数 '''' =================== ================================ 字段 值 =================== ================================ action executeContract contractID 合约ID withDynamicAnalysis true/false 是否进行动态分析,可选 operation 调用合约的方法名 arg 调用合约的参数 pubkey 调用者公钥,可选 signature 调用者签名 ,可选 =================== ================================ ``*``\ 表示可选参数 .. code:: javascript //sm2 可从sm2.js中加载获得。 signature = sm2.doSignature(contractID+"|"+operation+"|"+arg+"|"+pubkey,privateKey); .. _请求示例-57: 请求示例 '''''''' .. code:: javascript var request = {}; request.action = "executeContract"; request.contractID = "2073401446"; request.operation = "main"; request.arg = "hhhhh"; wssocket.send(JSON.stringify(request)); .. _返回结果示例-21: 返回结果示例 '''''''''''' .. code:: json { "needSeq":false, "seq":0, "status":"Success", "result":"world", "isInsnLimit":false, "totalGas":0, "executionGas":0, "extraGas":0, "size":0, "eventRelated":false, "responseID":"1617211077264_223", "action":"onExecuteResult", "executeTime":"5" } 输出历史记录日志(删除) ^^^^^^^^^^^^^^^^^^^^^^ 向服务器发送请求, 获取节点服务器上合约的TimeTravel日志. .. _参数-57: 参数 '''' ====== ================== 字段 值 ====== ================== action printTimeTravelLog ====== ================== .. _请求示例-58: 请求示例 '''''''' .. code:: javascript var request = {}; request.action = "printTimeTravelLog"; wssocket.send(JSON.stringify(request)); .. _返回结果示例-22: 返回结果示例 '''''''''''' .. code:: json { "status": false, "data": "[CMActions] dumpContract :…t/contractExamples/memoryDumps/LicenceManager\n" } 输出节点转移日志(删除) ^^^^^^^^^^^^^^^^^^^^^^^^ 向服务器发送请求, 获取节点服务器的状态转移日志. .. _参数-58: 参数 '''' ====== ================ 字段 值 ====== ================ action printTransferLog ====== ================ .. _请求示例-59: 请求示例 '''''''' .. code:: javascript var request = {}; request.action = "printTransferLog"; wssocket.send(JSON.stringify(request)); .. _返回结果示例-23: 返回结果示例 '''''''''''' .. code:: json { "status": false, "data": "" } 合约状态迁移 ^^^^^^^^^^^^ 向服务器发送请求, 获取节点服务器的状态转移日志. .. _参数-59: 参数 '''' ============ ============ 字段 值 ============ ============ action loadMemory contractName 合约名称 memoryFile 合约文件名称 ============ ============ .. _请求示例-60: 请求示例 '''''''' .. code:: javascript var request = {}; request.action = "loadMemory"; request.contractName = "JsonContract"; request.memoryFile = "2020-03-17.20/42/55"; wssocket.send(JSON.stringify(request)); .. _返回结果示例-24: 返回结果示例 '''''''''''' .. code:: json { "data":"success", "size":"0.00 B", "action":"onTransferTo", "time":"0.01s" } .. _日志查看类-1: 日志查看类 ~~~~~~~~~~ 查看本地近n日节点日志(删除) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. _参数-60: 参数 '''' ====== ================ 字段 值 ====== ================ action listLocalNodeLog date 当前时间 ====== ================ .. _请求示例-61: 请求示例 '''''''' :: request.action = "listLocalNodeLog"; request.date = new Date().getTime() - 24 * 3600 * 1000 * n; wssocket.send(JSON.stringify(request)); .. _返回结果-32: 返回结果 '''''''' .. code:: json { "data":"[{\"action\":\"login\",\"pubKey\":\"null\",\"status\":\"accept\",\"date\":1583139323822}\",]" } 查看本地近n日合约日志(删除) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. _参数-61: 参数 '''' ====== ==================== 字段 值 ====== ==================== action listLocalContractLog date 当前时间 ====== ==================== .. _请求示例-62: 请求示例 '''''''' :: request.action = "listLocalContractLog"; request.date = new Date().getTime() - 24 * 3600 * 1000 * n; wssocket.send(JSON.stringify(request)); .. _返回结果-33: 返回结果 '''''''' .. code:: json { "data":"[\"{\"action\":\"startContract\",\"pubKey\":\"04405d7ba358d9234939623ab51ea94ca685e6a1f36ed81fd9630ccba6473e632f163bb30faffd4c91f21e5bace20101d6d6e36c04ac67eea14cc24b4962b84f57\",\"contractID\":\"845581788\",\"contractName\":\"null\",\"date\":1583141525539}\"]" } 节点配置类 ~~~~~~~~~~ 获取节点配置信息 ^^^^^^^^^^^^^^^^ .. _参数-62: 参数 '''' ====== ============== 字段 值 ====== ============== action loadNodeConfig ====== ============== .. _请求示例-63: 请求示例 '''''''' :: var param = {}; param.action = "loadNodeConfig"; wssocket.send(JSON.stringify(param)); .. _返回结果-34: 返回结果 '''''''' :: { "status": true, "action": "onLoadNodeConfig", "data": { "nodeName": "04BF52213343C147E631B877BCEB17B794230EE551E85F58FA429C4BA03D690778CC384C6916C63DF36CB9E35C7E274FDB4E18491DFE3D611D347856D441CACC5AF9090B515F02AFC2DFBF56461EC83B5A4CD342466360D6CF82E6E40B637430AC4A329CCBC798DAF7D526AF9E3B3600E0BEA1BFAB8C160EF90128FAF67B19E45F37664F1E4B", "licence": "04AADCC7103CD02626D228AFFBEF53F8242ECA4DDD6F179D30B622440666715CFBB6FD1D3678A2B25812DEA9917073E79A65F7ADE517F784DC76288EFCEB37ECAA1025E6903540702F729DA1C2ECCD93F4E6FAFCE40DF443E7FD74387169D0C6D927C7BB12882D0471C8D3E6F31B0316A42FC38F6DD9978D4351B23B2AD63E2244909E98F51185D32CB99B4AE4E22D3AB4C04027BB", "expireTime": "Wed Aug 26 09:43:08 CST 2020", "nodes": "[\"node1\",\"node2\",\"node3\"]", "yjsPath": "/Users/xxx/docs/BDWareHttp/generatedlib/yjs.jar", "nodeCenter": "ws://127.0.0.1:1719/SCIDE/NodeCenter" } } { "status":true, "action":"onLoadNodeConfig", "data":{ "nodeName":"Node_180", "peerID":"", "masterAddress":"39.104.201.40:21031", "licence":"04AADCC7103C", "doipConfig":"{\\"LHSProxyAddress\\":\\"http://39.104.201.40:21042/\\",\\"ownerHandle\\":\\"86.5000.470/dou.TEST\\",\\"certPath\\":\\"keys/dou.TEST.keystore\\",\\"certPassword\\":\\"123456\\",\\"repoID\\":\\"86.5000.470/doip.vcg9Mu1gSq_bdw\\",\\"listeners\\":\\"[{\\\\\\"url\\\\\\":\\\\\\"tcp://39.104.201.40:21032\\\\\\",\\\\\\"protocolVersion\\\\\\":\\\\\\"2.1\\\\\\",\\\\\\"messageFormat\\\\\\":\\\\\\"packet\\\\\\"}]\\",\\"serviceDescription\\":\\"test local Contract Repository\\",\\"serviceName\\":\\"ContractEngine021\\"}", "clusterConnected":"false", "nodePubKey":"0492d974b8a5b473d0ed2c81800917f76e2a1ec3666067888c85fe6922a672223f2083f95402ae13a744df58deabbe7206c4a317dd14296b0d3941a26ca4e34dc5", "ipPort":"", "bdledger":"39.108.56.240:18091,39.108.56.12:1809139.104.70.160:18091 47.98.247.70:18091 47.98.248.208:18091 39.104.77.165:18091 47.98.249.131:18091", "yjsPath":"/data/bdwaas/bdcontract/yjs.jar", "nodeCenter":"ws://39.104.201.21040/SCIDE/NodeCenter" } } 修改节点配置 ^^^^^^^^^^^^ .. _参数-63: 参数 '''' ====== ============== 字段 值 ====== ============== action updateConfig key 要改的配置项 val 要更改的目标值 ====== ============== 其中,key的可选项包括: ============= =================================== =============================== key的示 val示例 说明 ============= =================================== =============================== yjsPath /User/xxx/cp/yjs.jar 合约进程启动所需的jar dataChain 192.168.1.8:18090,182.173.2.3:18091 账本节点的ip与端口 nodeCenter ws://127.0.0.1:18002 CenterPortal所在的ip/端口 nodeName Node_180 字符串类型 masterAddress 192.168.3.2:18001 该NodePortal节点的ip和的TCP端口 ============= =================================== =============================== 其中NodePortal的TCP端口为Node的http/ws端口号+1。 修改节点名称 ^^^^^^^^^^^^ .. _参数-64: 参数 '''' ====== ============== 字段 值 ====== ============== action changeNodeName data 新的节点名称 ====== ============== .. _请求示例-64: 请求示例 '''''''' :: var param = {}; param.action = "changeNodeName"; param.data = "NewNodeName"; wssocket.send(JSON.stringify(param)); .. _返回结果-35: 返回结果 '''''''' .. code:: json { "status": true, "action": "onChangeNodeName", "data": true } 修改节点YJS路径 ^^^^^^^^^^^^^^^ .. _参数-65: 参数 '''' ====== ===================== 字段 值 ====== ===================== action changeYJSPath data 节点服务器yjs.jar路径 ====== ===================== .. _请求示例-65: 请求示例 '''''''' :: var param = {}; param.action = "changeYJSPath"; param.data = "/Users/xxx/docs/BDWareHttp/generatedlib/yjs.jar"; wssocket.send(JSON.stringify(param)); .. _返回结果-36: 返回结果 '''''''' .. code:: json { "status": true, "action": "onChangeYJSPath", "data": true } 修改NodeCenter ^^^^^^^^^^^^^^ .. _参数-66: 参数 '''' ====== ========================================= 字段 值 ====== ========================================= action changeNodeCenter data 节点服务器要连接的NodeCenterWebSocket路径 ====== ========================================= .. _请求示例-66: 请求示例 '''''''' :: var param = {}; param.action = "changeNodeCenter"; param.data = "ws://127.0.0.1:1719/SCIDE/NodeCenter"; wssocket.send(JSON.stringify(param)); .. _返回结果-37: 返回结果 '''''''' .. code:: json { "status": true, "action": "onChangeNodeCenter", "data": true } 修改账本节点 ^^^^^^^^^^^^ .. _参数-67: 参数 '''' ====== =========================== 字段 值 ====== =========================== action changeBDledger data 数链节点的IP:port,用“,”隔开 ====== =========================== .. _请求示例-67: 请求示例 '''''''' :: var param = {}; param.action = "changeBDledger"; param.data = "39.108.56.240:18091,39.108.56.12:18091"; wssocket.send(JSON.stringify(param)); .. _返回结果-38: 返回结果 '''''''' .. code:: json { "status": true, "action": "onChangeBDledger", "data": true } 上传节点Licence ^^^^^^^^^^^^^^^ .. _参数-68: 参数 '''' ====== ======================= 字段 值 ====== ======================= action uploadLicence data 节点服务器的Licence内容 ====== ======================= .. _请求示例-68: 请求示例 '''''''' :: var param = {}; param.action = "uploadLicence"; param.data = "04AADCC7103C"; wssocket.send(JSON.stringify(param)); .. _返回结果-39: 返回结果 '''''''' .. code:: json { "status": true, "action": "onUploadLicence", "data": true } 获取节点ID ^^^^^^^^^^ .. _参数-69: 参数 '''' ====== ========= 字段 值 ====== ========= action getNodeID ====== ========= .. _请求示例-69: 请求示例 '''''''' :: var param = {}; param.action = "getNodeID"; wssocket.send(JSON.stringify(param)); .. _返回结果-40: 返回结果 '''''''' .. code:: json { "status": true, "action": "onGetNodeID", "data": "0431…d3a92e1184bbc5817ebda5c2ad498e4ff1d240009b4f06d" } 获取节点所在的可信执行集群 ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. _参数-70: 参数 '''' ========== ================================================ 字段 值 ========== ================================================ action getNodeTrustUnits data 节点ID msgHandler 收到回复的回调函数, 可使用“建立连接”的msgHandler ws 节点所属的NodeCenter的WebSocket地址 ========== ================================================ .. _请求示例-70: 请求示例 '''''''' :: centerportalws = createWssocket("ws://127.0.0.1:1718/NodeCenterWS",function() { var param = {}; param.action = "getNodeTrustUnits"; param.data = "0431e311bd70840fe69965e2cabea97fafe99f2133953c01abb9bd7cb62af42f8283f474d203051e920d3a92e1184bbc5817ebda5c2ad498e4ff1d240009b4f06d"; centerportalws.send(JSON.stringify(param)); }, msgHandler); .. _返回结果-41: 返回结果 '''''''' .. code:: json { "data": [{ "key": "0475c7b061...65e55_4063665700873624164", "value": "[\"04541429c11b094…40009b4f06d\"]" }], "action": "onGetNodeTrustUnits" } .. _模板生成类-1: 模板生成类 ~~~~~~~~~~ 获取合约模板列表 ^^^^^^^^^^^^^^^^ .. _参数-71: 参数 '''' ====== =============== 字段 值 ====== =============== action getTemplateList ====== =============== .. _请求示例-71: 请求示例 '''''''' .. code:: javascript req={}; req.action = "getTemplateList"; wssocket.send(JSON.stringify(req)); .. _返回结果-42: 返回结果 '''''''' .. code:: json { "data": [ { "formDesc": { "dbPWD": { "label": "密码", "type": "input" }, "contractName": { "label": "合约名称", "type": "input" }, "accessPolicy": { "label": "访问控制策略", "type": "input", "option": [ { "text": "无访问控制", "value": "NAC" }, { "text": "直接访问控制", "value": "DAC" }, { "text": "基于角色的访问控制", "value": "RBAC" } ] }, "dbUserName": { "label": "用户名", "type": "input" }, "fieldList": { "label": "字段名", "type": "tag" }, "dbUrl": { "label": "数据库链接", "type": "input" }, "tableName": { "label": "表名", "type": "input" } }, "apiName": "generateMySQLProject" }, { "formDesc": { "contractName": { "label": "合约名称", "type": "input" }, "accessPolicy": { "label": "访问控制策略", "type": "input", "option": [ { "text": "无访问控制", "value": "NAC" }, { "text": "直接访问控制", "value": "DAC" }, { "text": "基于角色的访问控制", "value": "RBAC" } ] } }, "apiName": "generateEmptyProject" } ], "action": "onTemplateList" } 空白合约模板 ^^^^^^^^^^^^ .. _参数-72: 参数 '''' ============ ============================= 字段 值 ============ ============================= action generateEmptyProject contractName 字符串类型,合约名称 isPrivate 布尔类型,是否为私有项目 accessPolicy 若为“DAC”,则实现直接访问控制 ============ ============================= .. _请求示例-72: 请求示例 '''''''' .. code:: javascript var req = {}; req.contractName = "Empty22"; req.action = "generateEmptyProject"; req.accessPolicy = "DAC"; //wssocket为建立好的连接 wssocket.send(JSON.stringify(req)); .. _返回结果-43: 返回结果 '''''''' .. code:: json { "action":"onListProjects", "data":"[\"AnnotationSample\",\"AppDataAnalysis\",\"AppDataSource\"]", "executeTime":0, "isPrivate":false } MySQL接入合约 ^^^^^^^^^^^^^ .. _参数-73: 参数 '''' ============= ====================================================== 字段 值 ============= ====================================================== action generateMySQLProject contractName 字符串类型,合约名称 isPrivate 布尔类型,是否为私有项目 dbUrl 字符串类型,数据库的URI dbUserName 字符串类型,数据库的用户名 dbPWD 字符串类型,数据库密码 accessPolicy 若为“DAC”,则实现直接访问控制,若为“NAC”则没有访问控制 tableName 字符串类型,数据库的表名 fieldList 字符串列表,数据库的字段列表 defaultAccept 布尔值,表示申请时是否默认有权 ============= ====================================================== .. _请求示例-73: 请求示例 '''''''' .. code:: javascript var req = {}; req.contractName = "MySQLFromTemplate"; req.action = "generateMySQLProject"; req.pubKey = global.sm2Key.publicKey; req.isPrivate = true; req.tableName = "data"; req.dbUrl = "jdbc:mysql://xxx:xxx/xxx"; req.dbUserName = "loushuai"; req.dbPWD = "loushuai"; req.fieldList = [{"name":"名字","code":"*"}]; req.basicInfo={"type":"所属分类","name":"资源名称"}; req.accessPolicy = "DAC"; req.defaultAccept = true; //global.wssocket为建立好的连接 global.wssocket.send(JSON.stringify(req)); .. _返回结果-44: 返回结果 '''''''' .. code:: json { "action":"onListProjects", "data":"[\"CSVFromTemplate\",\"Empty22\",\"Hello\",\"MySQLFromTemplate\",\"test\"]", "executeTime":0, "isPrivate":true } CSV接入合约 ^^^^^^^^^^^ .. _参数-74: 参数 '''' ================= ====================================================== 字段 值 ================= ====================================================== action generateCSVProject contractName 字符串类型,合约名称 base64EncodedData 字符串类型,通过base64编码后的CSV文件内容 isPrivate 可选字段,布尔类型,是否为私有项目 accessPolicy 若为“DAC”,则实现直接访问控制,若为“NAC”则没有访问控制 defaultAccept 可选字段,布尔值,表示申请时是否默认有权 ================= ====================================================== .. _请求示例-74: 请求示例 '''''''' .. code:: javascript var req = {}; req.contractName = "CSVFromTemplate"; req.action = "generateCSVProject"; req.pubKey = global.sm2Key.publicKey; req.isPrivate = true; req.tableName = "data"; req.accessPolicy = "DAC"; req.defaultAccept = true; req.base64EncodedData = "bmFtZSwgc2NvcmUsCmphY2ssIDkwLApsdWN5LCA5MQo="; //global.wssocket为建立好的连接 global.wssocket.send(JSON.stringify(req)); .. _返回结果-45: 返回结果 '''''''' .. code:: json { "action":"onListProjects", "data":"[\"CSVFromTemplate\",\"Empty22\",\"Hello\",\"MySQLFromTemplate\",\"test\"]", "executeTime":0, "isPrivate":true } -------------- 路由节点WebSocket接口 --------------------- .. _用户管理类-2: 用户管理类 ~~~~~~~~~~ .. _获取session-1: 获取Session ^^^^^^^^^^^ 登录前获取session以便进行签名。 .. _参数-75: 参数 '''' ====== ============ 字段 值 ====== ============ action getSessionID ====== ============ .. _请求示例-75: 请求示例 '''''''' :: var req = {}; req.action = "getSessionID"; wssocket.send(JSON.stringify(req)); .. _返回结果-46: 返回结果 '''''''' .. code:: json { "action": "onSessionID", "session": "9782323_session" } .. _用户登录-1: 用户登录 ^^^^^^^^ 用户进行公私钥身份验证,需先调用“getSessionID”获取sessionID以便于签名。 .. _参数-76: 参数 '''' ====== ===== 字段 值 ====== ===== action login ====== ===== .. _请求示例-76: 请求示例 '''''''' :: var loginParam = {}; loginParam.pubKey = global.sm2Key.publicKey; loginParam.signature = sm2.doSignature(global.session, global.sm2Key.privateKey); loginParam.action = "login"; wssocket.send(JSON.stringify(loginParam)); .. _返回结果示例-25: 返回结果示例 '''''''''''' .. code:: json { "action": "onLogin", "data": "CenterManager" } 用户获取当前角色(删除) ^^^^^^^^^^^^^^^^^^^^^^ 用户根据登录时的公钥获取对应的角色,如果是第一次登录则此时的公钥默认称为准入管理员 .. _参数-77: 参数 '''' ====== ======= 字段 值 ====== ======= action getRole ====== ======= .. _请求示例-77: 请求示例 '''''''' :: var param = {}; param.action = "getRole"; wssocket.send(JSON.stringify(param)); .. _返回结果示例-26: 返回结果示例 '''''''''''' .. code:: json { "action": "onGetRole", "data": "CenterManager" } .. _申请角色-1: 申请角色 ^^^^^^^^ 在准入管理员界面可以申请称为组网中某个节点的节点管理员 .. _参数-78: 参数 '''' ====== ============== 字段 值 ====== ============== action applyRole role 申请的角色名称 ====== ============== .. _请求示例-78: 请求示例 '''''''' :: var param = {}; param.action = "applyRole"; param.role=" wssocket.send(JSON.stringify(param)); .. _返回结果示例-27: 返回结果示例 '''''''''''' .. code:: json { "action": "onApplyRole", "data": "failed" } 添加节点 ^^^^^^^^ .. _参数-79: 参数 '''' ========== ================ 字段 值 ========== ================ action addNode nodePubKey 要添加的节点公钥 ========== ================ .. _请求示例-79: 请求示例 ^^^^^^^^ :: var req = {}; //某节点的publicKey可通过连接该节点,并通过"获取节点配置信息"接口获取 req.nodePubKey = publicKey; req.action = "addNode"; wssocket.send(JSON.stringify(req)); .. _删除用户角色-1: 删除用户角色 ^^^^^^^^^^^^ .. _参数-80: 参数 '''' ====== ============== 字段 值 ====== ============== action delete pubKey 对应用户的公钥 ====== ============== .. _请求示例-80: 请求示例 '''''''' :: var deleteInfo = {}; deleteInfo.pubKey = user.publicKey; deleteInfo.action = "delete"; wssocket.send(JSON.stringify(deleteInfo)); .. _返回结果示例-28: 返回结果示例 '''''''''''' .. code:: json { "action": "onDelete", "data": "success" } .. _查看授权用户列表-1: 查看授权用户列表 ^^^^^^^^^^^^^^^^ 查看准入管理员当前组网中已经授权的节点管理员 .. _参数-81: 参数 '''' ====== ============ 字段 值 ====== ============ action listAllUsers ====== ============ .. _请求示例-81: 请求示例 '''''''' :: var param = {}; param.action = "onListAllUsers"; wssocket.send(JSON.stringify(param)); .. _返回结果示例-29: 返回结果示例 '''''''''''' .. code:: json { "action": "onListAllUsers", "kv": { "key": "049999ebd14ff3b96ebf7f7325e1da94a1c4c376573a1dc1cec2b4f7a3b09ed7b07252134e93b6ac2e1853268b82f4b541d34fb42b0182cd61043e99d3489e2cf7", "value": " NodeManager" }, "time": { "key": "049999ebd14ff3b96ebf7f7325e1da94a1c4c376573a1dc1cec2b4f7a3b09ed7b07252134e93b6ac2e1853268b82f4b541d34fb42b0182cd61043e99d3489e2cf7", "value": 1587398989914 } } .. _查看申请用户列表-1: 查看申请用户列表 ^^^^^^^^^^^^^^^^ .. _参数-82: 参数 '''' ====== ============= 字段 值 ====== ============= action listApplyList ====== ============= .. _请求示例-82: 请求示例 '''''''' :: var param = {}; param.action = "onListApplyList"; wssocket.send(JSON.stringify(param)); .. _返回结果-47: 返回结果 '''''''' .. code:: json { "action": "onListApplyList", "kv": { "key": "04b00f32eab70c78d1b43738f190d326d36c021af2124acefe6d057016b11ea31c750bb473e565c9d89e4993a44f4d30adf447d3026a21ff4b3b64cef523074ef7", "value": " NodeManager" }, "time": { "key": "04b00f32eab70c78d1b43738f190d326d36c021af2124acefe6d057016b11ea31c750bb473e565c9d89e4993a44f4d30adf447d3026a21ff4b3b64cef523074ef7", "value": 1587398989914 } } 查看用户类型分布 ^^^^^^^^^^^^^^^^ .. _参数-83: 参数 '''' ====== ============= 字段 值 ====== ============= action queryUserStat ====== ============= .. _请求示例-83: 请求示例 '''''''' :: var param = {}; param.action = "onQueryUserStat"; wssocket.send(JSON.stringify(param)); .. _返回结果示例-30: 返回结果示例 '''''''''''' .. code:: json { "action": "onQueryUserStat", "userListCount": 3, "applyListCount":0 } 节点管理类 ~~~~~~~~~~ 查看节点列表 ^^^^^^^^^^^^ 查看该用户有权限查看的节点列表(仅准入管理员及合约管理者可用) .. _参数-84: 参数 '''' ====== ========= 字段 值 ====== ========= action listNodes ====== ========= .. _请求示例-84: 请求示例 '''''''' :: var param = {}; param.action = "listNodes"; wssocket.send(JSON.stringify(param)); .. _返回结果-48: 返回结果 '''''''' .. code:: json { "offline": [{ "key": "0431e31...40009b4f06d", "value": "0431e311bd708...b4f06d" }], "action": "onListNodes", "online": [{ "contracts": [], "pubKey": "0431e311...09b4f06d", "nodeName": "NewNodeName", "udpID": "528822126", "cimanager": "" }] } 查看可信执行集群列表 ^^^^^^^^^^^^^^^^^^^^ 查看该用户有权限查看的节点列表(仅中心管理员及合约管理者可用) .. _参数-85: 参数 '''' ====== ============== 字段 值 ====== ============== action listTrustUnits ====== ============== .. _请求示例-85: 请求示例 '''''''' :: var param = {}; param.action = "listTrustUnits"; wssocket.send(JSON.stringify(param)); .. _返回结果-49: 返回结果 '''''''' .. code:: json { "data": [{ "key": "0470b2f27f4f6…1cb855f1ecec11", "value": "[...]" }], "action": "onListTrustUnits" } 建立可信执行集群 ^^^^^^^^^^^^^^^^ .. _参数-86: 参数 '''' ====== ====================== 字段 值 ====== ====================== action createTrustUnit data 节点公钥组成的Json数组 Msg 集群名称 ====== ====================== .. _请求示例-86: 请求示例 '''''''' :: var param = {}; param.action = "createTrustUnit"; param.data = "[\"382r0934309t...\",\"345343rr3f34...\"]"; param.msg = "newUnit1"; global.wssocket.send(JSON.stringify(param)); .. _返回结果-50: 返回结果 '''''''' .. code:: json { "action": "onCreateTrustUnit", "status": "Success" } 删除可信执行集群 ^^^^^^^^^^^^^^^^ .. _参数-87: 参数 '''' ====== =============== 字段 值 ====== =============== action deleteTrustUnit data 可信执行集群ID ====== =============== .. _请求示例-87: 请求示例 '''''''' :: var param = {}; param.action = "deleteTrustUnit"; param.data = "0475d34rf3434..._1583410158761"; global.wssocket.send(JSON.stringify(param)); .. _返回结果-51: 返回结果 '''''''' .. code:: json { "action": "onDeleteTrustUnit", "status": "Success" } .. _日志查看类-2: 日志查看类 ~~~~~~~~~~ 查看组网管理操作的统计 ^^^^^^^^^^^^^^^^^^^^^^ .. _参数-88: 参数 '''' ====== ============== 字段 值 ====== ============== action queryActionLog date 当前时间 ====== ============== .. _请求示例-88: 请求示例 '''''''' :: request.action = "onQueryActionLog"; request.date = new Date().getTime() - 24 * 3600 * 1000 * n; wssocket.send(JSON.stringify(request)); .. _返回结果-52: 返回结果 '''''''' .. code:: json { "action":"onQueryActionLog", "data":"[{\"action\":\"login\",\"pubKey\":\"null\",\"status\":\"accept\",\"date\":1583139323822}\",]" } 查看本地近n日合约日志 ^^^^^^^^^^^^^^^^^^^^^ .. _参数-89: 参数 '''' ====== ==================== 字段 值 ====== ==================== action listLocalContractLog date 当前时间 ====== ==================== .. _请求示例-89: 请求示例 '''''''' :: request.action = "listLocalContractLog"; request.date = new Date().getTime() - 24 * 3600 * 1000 * n; wssocket.send(JSON.stringify(request)); .. _返回结果-53: 返回结果 '''''''' .. code:: json { "data":"[\"{\"action\":\"startContract\",\"pubKey\":\"04405d7b...\",\"contractID\":\"845581788\",\"contractName\":\"null\",\"date\":1583141525539}\"]" } -------------- Bash接口 -------- 已废弃。可使用BDWareConfigTool代替。 通过命令行发送Socket指令, 执行调用\ ``ContractController``\ 类中方法, 完成以下功能. (需要在本机的``1615``\ 端口运行\ ``ContractManager``\ 实例) .. figure:: ./_static/imgs/bash-api.png :alt: Bash接口功能示意图 Bash接口功能示意图 指令 ~~~~ .. code:: bash java -jar yjs.jar function_name arguments ``function_name``\ 为调用的方法名; ``arguments``\ 为方法参数. .. _启动合约-2: 启动合约 ~~~~~~~~ .. _参数-90: 参数 ^^^^ ``function_name``\ 为\ ``startContract``; ``arguments``\ 为启动合约需要的参数, 包括合约类型\ ``type``, 合约ID\ ``id``, 合约脚本\ ``script``. 指令示例 ^^^^^^^^ .. code:: bash java -jar yjs.jar startContract "{\"type\":\"Algorigthm\",\"id\":\"656565\",\"script\":\"contract c{function main(arg){return arg/1.0+1;}}\"}" .. _调用合约-2: 调用合约 ~~~~~~~~ .. _参数-91: 参数 ^^^^ ``function_name``\ 为\ ``executeContract``; ``arguments``\ 为调用合约需要的参数, 包括调用参数\ ``arg``, 合约ID\ ``contractID``. .. _指令示例-1: 指令示例 ^^^^^^^^ .. code:: bash java -jar yjs.jar executeContract "{\"arg\":\"http://www.baidu.com\",\"contractID\":\"656564\"}" .. _停止合约-1: 停止合约 ~~~~~~~~ .. _参数-92: 参数 ^^^^ ``function_name``\ 为\ ``stopContract``; ``arguments``\ 为调用合约需要的参数, 即合约ID\ ``contractID``. .. _指令示例-2: 指令示例 ^^^^^^^^ .. code:: bash java -jar yjs.jar stopContract "{\"arg\":\"http://www.baidu.com\",\"contractID\":\"656564\"}" 停止全部合约 ~~~~~~~~~~~~ .. _参数-93: 参数 ^^^^ ``function_name``\ 为\ ``stopAllContracts``. .. _指令示例-3: 指令示例 ^^^^^^^^ .. code:: bash java -jar yjs.jar stopAllContracts 查询全部合约 ~~~~~~~~~~~~ .. _参数-94: 参数 ^^^^ ``function_name``\ 为\ ``listContracts``. .. _指令示例-4: 指令示例 ^^^^^^^^ .. code:: bash java -jar yjs.jar listContracts