repchain/json/gensis.json
2019-03-22 17:31:51 +08:00

308 lines
23 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"version" : 1,
"height" : "1",
"transactions" : [ {
"id" : "e560fdb3-465b-491a-9d5f-5691a49279a2",
"type" : "CHAINCODE_DEPLOY",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"spec" : {
"timeout" : 5000,
"codePackage" : "package rep.sc.tpl\n\nimport rep.sc.contract._\nimport rep.protos.peer._\nimport org.json4s.jackson.JsonMethods._\n\nimport scala.collection.mutable.Map\nimport org.json4s.DefaultFormats\nimport rep.app.conf.SystemProfile\nimport rep.utils.{IdTool, SerializeUtils}\n\n/**\n * @author zyf\n */\n// 证书状态\ncase class CertStatus(credit_code: String, name: String, status: Boolean)\ncase class CertInfo(credit_code: String,name: String, cert: Certificate)\n\nclass ContractCert extends IContract {\n implicit val formats = DefaultFormats\n\n val notNodeCert = \"非管理员操作\"\n val signerExists = \"账户已存在\"\n val signerNotExists = \"账户不存在\"\n val certExists = \"证书已存在\"\n val certNotExists = \"证书不存在\"\n val unknownError = \"未知错误\"\n val chaincodeName = SystemProfile.getAccountChaincodeName\n val chaincodeVersion = SystemProfile.getAccountChaincodeVersion\n //val prefix = IdTool.getCid(ChaincodeId(chaincodeName, chaincodeVersion))\n val underline = \"_\"\n val dot = \".\"\n // 锚点,错误回退\n var anchor: Map[String, Any] = Map()\n\n object ACTION {\n val SignUpSigner = \"SignUpSigner\"\n val SignUpCert = \"SignUpCert\"\n val UpdateCertStatus = \"UpdateCertStatus\"\n val UpdateSigner = \"UpdateSigner\"\n }\n\n \n\n /**\n * 注册Signer账户\n * @param ctx\n * @param data\n * @return\n */\n def signUpSigner(ctx: ContractContext, data:Signer):ActionResult = {\n val isNodeCert = ctx.api.bNodeCreditCode(ctx.t.getSignature.getCertId.creditCode)\n if (!isNodeCert) {\n return ActionResult(0,Some(notNodeCert))\n }\n // 存Signer账户\n //val signerKey = prefix + underline + data.creditCode\n val signer = ctx.api.getState(data.creditCode)\n // 如果是null表示已注销如果不是null则判断是否有值\n if (signer == null || new String(signer).equalsIgnoreCase(\"null\")){\n ctx.api.setVal(data.creditCode, data)\n ActionResult(1,None)\n } else {\n ActionResult(0,Some(signerExists))\n }\n }\n\n /**\n * 注册用户证书1、将name加到账户中2、将Certificate保存\n * @param ctx\n * @param data\n * @return\n */\n def signUpCert(ctx: ContractContext, data:CertInfo): ActionResult = {\n val isNodeCert = ctx.api.bNodeCreditCode(ctx.t.getSignature.getCertId.creditCode)\n if (!isNodeCert) {\n return ActionResult(0,Some(notNodeCert))\n }\n val certKey = data.credit_code + dot + data.name\n val certInfo = ctx.api.getState(certKey)\n val signerKey = data.credit_code\n val signerContent = ctx.api.getState(signerKey)\n // 先判断证书若证书不存在则向账户添加name\n if (certInfo == null || new String(certInfo).equalsIgnoreCase(\"null\")) {\n if (signerContent == null || new String(signerContent).equalsIgnoreCase(\"null\")){\n return ActionResult(0,Some(signerNotExists))\n } else {\n ctx.api.setVal(certKey, data.cert)\n val signer = SerializeUtils.deserialise(signerContent).asInstanceOf[Signer]\n if (!signer.certNames.contains(data.name)){\n signer.addCertNames(data.name)\n ctx.api.setVal(signerKey, signer)\n }\n }\n ActionResult(1, None)\n } else {\n ActionResult(0, Some(certExists))\n }\n }\n\n // TODO\n def rollback(map: Map[String, Byte]): Unit = {}\n\n /**\n * 用户证书禁用、启用\n * @param ctx\n * @param data\n * @return\n */\n def updateCertStatus(ctx: ContractContext, data: CertStatus): ActionResult = {\n val isNodeCert = ctx.api.bNodeCreditCode(ctx.t.getSignature.getCertId.creditCode)\n if (!isNodeCert) {\n return ActionResult(0,Some(notNodeCert))\n }\n val certKey = data.credit_code + dot + data.name\n val certInfo = ctx.api.getState(certKey)\n if (certInfo == null || new String(certInfo).equalsIgnoreCase(\"null\")) {\n ActionResult(0,Some(certNotExists))\n } else {\n val cert = SerializeUtils.deserialise(certInfo).asInstanceOf[Certificate]\n cert.withCertValid(data.status)\n ctx.api.setVal(certKey, cert)\n ActionResult(1,None)\n }\n }\n\n /**\n * 更新账户相关信息\n * @param ctx\n * @param data\n * @return\n */\n def updateSigner(ctx: ContractContext, data: Signer): ActionResult = {\n val isNodeCert = ctx.api.bNodeCreditCode(ctx.t.getSignature.getCertId.creditCode)\n if (!isNodeCert) {\n return ActionResult(0,Some(notNodeCert))\n }\n val signer = ctx.api.getState(data.creditCode)\n // 如果是null账户不存在不存在则不能更新\n if (signer == null || new String(signer).equalsIgnoreCase(\"null\")){\n ActionResult(0,Some(signerNotExists))\n } else {\n ctx.api.setVal(data.creditCode, data)\n ActionResult(1,None)\n }\n }\n\n def init(ctx: ContractContext){\n println(s\"tid: $ctx.t.txid\")\n }\n\n\n /**\n * 合约方法入口\n */\n def onAction(ctx: ContractContext,action:String, sdata:String ): ActionResult={\n val json = parse(sdata)\n\n action match {\n case ACTION.SignUpSigner =>\n println(\"SignUpSigner\")\n signUpSigner(ctx, json.extract[Signer])\n case ACTION.SignUpCert =>\n println(\"SignUpCert\")\n signUpCert(ctx, json.extract[CertInfo])\n case ACTION.UpdateCertStatus =>\n println(\"UpdateCertStatus\")\n updateCertStatus(ctx, json.extract[CertStatus])\n case ACTION.UpdateSigner =>\n println(\"UpdateSigner\")\n updateSigner(ctx, json.extract[Signer])\n }\n }\n\n}",
"ctype" : "CODE_SCALA"
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.589Z",
"signature" : "MEQCIFugxRKz7pGrAG3BkbXLTmEox1g0/sHJ7z7FzNhgWZUiAiBQ9c+uan6VGpZj8nNMaq4hot6gNMZV3mhcSUh/CBP2ow=="
}
}, {
"id" : "b9e9d930-18a1-48d8-97c5-7275489e715c",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpSigner",
"args" : [ "{\"name\":\"node1\",\"creditCode\":\"121000005l35120456\",\"mobile\":\"18912345678\",\"certNames\":[\"node1\"]}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.773Z",
"signature" : "MEUCIQDa3749TypN3dl29tnZYLC/LjN7ZiVTN9hSYWmtl5XItwIgSvFveyQVvo98AqlfWKacc5X2gcKCGyRejrXUoJA17Jc="
}
}, {
"id" : "e6bb304a-6c68-4031-91e2-284f45efb5f1",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpSigner",
"args" : [ "{\"name\":\"node2\",\"creditCode\":\"12110107bi45jh675g\",\"mobile\":\"18912345678\",\"certNames\":[\"node2\"]}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.780Z",
"signature" : "MEQCIH6iyzb3xw0e5SxsFrsvpyopIkrn5h3Ji0oHswf+VQl0AiBVN7mhv05smwuKzmOb5J5kD9vmXSUiSvtsgAlErrOMFw=="
}
}, {
"id" : "eed38d56-d7b4-43ec-9993-776ed13e9a9d",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpSigner",
"args" : [ "{\"name\":\"node3\",\"creditCode\":\"122000002n00123567\",\"mobile\":\"18912345678\",\"certNames\":[\"node3\"]}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.782Z",
"signature" : "MEQCIEf+/9opj9PDuqAOlh2D646TutI4Sn61Oay1TZAfj6NZAiAaPiXskbkvzR/7fW1SEH1QtkD38I6zURe9AiTKPQXt+g=="
}
}, {
"id" : "2fed6f00-241a-4cc0-979d-48b8f0f9fbd8",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpSigner",
"args" : [ "{\"name\":\"node4\",\"creditCode\":\"921000005k36123789\",\"mobile\":\"18912345678\",\"certNames\":[\"node4\"]}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.783Z",
"signature" : "MEUCIGAGxYNZVP4UB578qtjlAnuLdqJx7ABT1UMQsmnqUZ2lAiEAwTZM+HSiZJSGUZ3T3yPH3cwOAimqNty1LrAB6xIQmzU="
}
}, {
"id" : "6147fa2d-4c81-46fb-ac29-6ac679e55456",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpSigner",
"args" : [ "{\"name\":\"node5\",\"creditCode\":\"921000006e0012v696\",\"mobile\":\"18912345678\",\"certNames\":[\"node5\"]}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.785Z",
"signature" : "MEUCICnm3GrZo3hjfgsgEDIN2olz6Y0QCStSKkQuzYnk1ihIAiEA37ZQPtiAjMcHFnzC+d2JGuUiPcKdGB7ApAyb302N/+w="
}
}, {
"id" : "84f99292-9d94-42fc-b300-f9a77f01cbb3",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpSigner",
"args" : [ "{\"name\":\"super_admin\",\"creditCode\":\"951002007l78123233\",\"mobile\":\"18912345678\",\"certNames\":[\"super_admin\"]}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.787Z",
"signature" : "MEQCIGr6LcTLg5R0U3yvMCtbZX+1P8kO1NtVQuXtrKf3g1sqAiA99P/Yr9AX8zQpq4Pj2DJUhTLyUITKma296Ood5FyHGQ=="
}
}, {
"id" : "ad92d35a-f040-4d50-b810-58649d634334",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpCert",
"args" : [ "{\"credit_code\":\"121000005l35120456\",\"name\":\"node1\",\"cert\":{\"certificate\":\"-----BEGIN CERTIFICATE-----\\nMIIBmjCCAT+gAwIBAgIEXIn07TAKBggqhkjOPQQDAjBWMQswCQYDVQQGEwJjbjEL\\nMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJqMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwG\\nA1UECwwFaXNjYXMxCjAIBgNVBAMMATEwHhcNMTkwMzE0MDYzMDA1WhcNMjAwMzEz\\nMDYzMDA1WjBWMQswCQYDVQQGEwJjbjELMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJq\\nMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwGA1UECwwFaXNjYXMxCjAIBgNVBAMMATEw\\nVjAQBgcqhkjOPQIBBgUrgQQACgNCAASlh+oDBPdwHEkpQT4/g4RX9ubP7jMM2Qod\\niFtsnv+ObQ3dxfQN/S515ePssn3HjPCwfzR3S1KY4O9vFtH1Jql9MAoGCCqGSM49\\nBAMCA0kAMEYCIQCG2NFkYx06oWahUDflmXDkoXyTBIvjnA/M2yJlou3RIQIhAJcA\\n1X1djf5oGPc+6GYh9g4YhQ59HxV3p6kAEuRI13PP\\n-----END CERTIFICATE-----\\n\",\"algType\":\"SHA1withECDSA\",\"certValid\":true,\"regTime\":{\"seconds\":1553247052,\"nanos\":789000000}}}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.810Z",
"signature" : "MEUCIQCRMfKIF7X5BvbjFWCcI1yAXTx239L2JW4J3AyaChqBVAIgJQeNOehWyz6zFENQb5S9X8zpu8KsCIrbu8dk0dQI09g="
}
}, {
"id" : "329db75e-4b21-4f75-bce9-795dfc9de1e6",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpCert",
"args" : [ "{\"credit_code\":\"12110107bi45jh675g\",\"name\":\"node2\",\"cert\":{\"certificate\":\"-----BEGIN CERTIFICATE-----\\nMIIBmTCCAT+gAwIBAgIEXIn2LzAKBggqhkjOPQQDAjBWMQswCQYDVQQGEwJjbjEL\\nMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJqMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwG\\nA1UECwwFaXNjYXMxCjAIBgNVBAMMATIwHhcNMTkwMzE0MDYzNTI3WhcNMjAwMzEz\\nMDYzNTI3WjBWMQswCQYDVQQGEwJjbjELMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJq\\nMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwGA1UECwwFaXNjYXMxCjAIBgNVBAMMATIw\\nVjAQBgcqhkjOPQIBBgUrgQQACgNCAAQbGHprzZj8UABd4LFvAoFVPFc/xDkWybEJ\\noF3iey/BvIVvBrB92xskV8ULlOt+qjQGIz0SdRiCrqs+YacCAo/xMAoGCCqGSM49\\nBAMCA0gAMEUCIDdarnwrREWGu3YQMvcFItU3e5X9J7kwgVw3uvZg77r0AiEAgIhG\\nTTVwdvjjewyeOXoVT/emsGz314jZJTYbtzoZiv8=\\n-----END CERTIFICATE-----\\n\",\"algType\":\"SHA1withECDSA\",\"certValid\":true,\"regTime\":{\"seconds\":1553247052,\"nanos\":812000000}}}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.813Z",
"signature" : "MEYCIQCmvV+6nNxORB1nr0k0Dz8TF9SJ2NAFWmBusBjyAmo4CwIhAMA8jJhXIi4+HutF5utCdiwWR6iAG9RAZfYiHBHIbA85"
}
}, {
"id" : "4a3d5da5-7311-4404-a813-d2c68b0fef89",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpCert",
"args" : [ "{\"credit_code\":\"122000002n00123567\",\"name\":\"node3\",\"cert\":{\"certificate\":\"-----BEGIN CERTIFICATE-----\\nMIIBmTCCAT+gAwIBAgIEXIn6vTAKBggqhkjOPQQDAjBWMQswCQYDVQQGEwJjbjEL\\nMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJqMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwG\\nA1UECwwFaXNjYXMxCjAIBgNVBAMMATMwHhcNMTkwMzE0MDY1NDUzWhcNMjAwMzEz\\nMDY1NDUzWjBWMQswCQYDVQQGEwJjbjELMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJq\\nMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwGA1UECwwFaXNjYXMxCjAIBgNVBAMMATMw\\nVjAQBgcqhkjOPQIBBgUrgQQACgNCAASdBDKlL7mW1NEfYDDb63d6O3/MueUT0Czr\\nbzcmLhrDvRyIO2fHl/zR/qrNy76cuRi7EednNO/G7qTemnJQqC9oMAoGCCqGSM49\\nBAMCA0gAMEUCIEXfvQcCZsnBiCWEPV0gWmxnhBbRRXE9oirBwb4J0Tu+AiEAk7Z8\\n3MRWR022p7AYeshwIXpaDlIu3N4VxatMHh3rs5I=\\n-----END CERTIFICATE-----\\n\",\"algType\":\"SHA1withECDSA\",\"certValid\":true,\"regTime\":{\"seconds\":1553247052,\"nanos\":814000000}}}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.815Z",
"signature" : "MEUCIQCiiRYln2r1PCu1BFLLAyBh4f30oovI7Bd0VuNdvRrxKgIgB8JwhAzRX6ytMR3Vc1ABTiTwzEKNeP3admL0xeoMs/M="
}
}, {
"id" : "6b0ec61e-ef83-47a4-b5bd-2de638d281c1",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpCert",
"args" : [ "{\"credit_code\":\"921000005k36123789\",\"name\":\"node4\",\"cert\":{\"certificate\":\"-----BEGIN CERTIFICATE-----\\nMIIBmjCCAT+gAwIBAgIEXIn75TAKBggqhkjOPQQDAjBWMQswCQYDVQQGEwJjbjEL\\nMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJqMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwG\\nA1UECwwFaXNjYXMxCjAIBgNVBAMMATQwHhcNMTkwMzE0MDY1OTQ5WhcNMjAwMzEz\\nMDY1OTQ5WjBWMQswCQYDVQQGEwJjbjELMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJq\\nMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwGA1UECwwFaXNjYXMxCjAIBgNVBAMMATQw\\nVjAQBgcqhkjOPQIBBgUrgQQACgNCAAQy8jrMgX4TF/iuA42wEpYr82qIzBVFZmoJ\\ndyQTu2Pu5Ot4Jfg1sa/ibY4fxXX/Rc2bN8U0+88A7JiEqa0pRAQUMAoGCCqGSM49\\nBAMCA0kAMEYCIQDLBrE3v62ztcucfxZ27M0JqcgKWKT1Cow3JyCLZnhAQwIhANaQ\\nIv1SgKX7fnhR3lga4IKdaFK6bpW/9YnDUsQ22kFL\\n-----END CERTIFICATE-----\\n\",\"algType\":\"SHA1withECDSA\",\"certValid\":true,\"regTime\":{\"seconds\":1553247052,\"nanos\":817000000}}}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.818Z",
"signature" : "MEQCIAlp4xWTJdVsIl6WTj3o1hVF9nMy9ZNO1FSGt+rOCWIcAiAuWSCP6kZJOUr//vDgUIKciGf5UIwpG17TDNuM0AeUEQ=="
}
}, {
"id" : "ed609d56-e6b2-4b08-ac18-f872c392271e",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpCert",
"args" : [ "{\"credit_code\":\"921000006e0012v696\",\"name\":\"node5\",\"cert\":{\"certificate\":\"-----BEGIN CERTIFICATE-----\\nMIIBmTCCAT+gAwIBAgIEXIn8QzAKBggqhkjOPQQDAjBWMQswCQYDVQQGEwJjbjEL\\nMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJqMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwG\\nA1UECwwFaXNjYXMxCjAIBgNVBAMMATUwHhcNMTkwMzE0MDcwMTIzWhcNMjAwMzEz\\nMDcwMTIzWjBWMQswCQYDVQQGEwJjbjELMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJq\\nMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwGA1UECwwFaXNjYXMxCjAIBgNVBAMMATUw\\nVjAQBgcqhkjOPQIBBgUrgQQACgNCAASRkmXqNawcVmoRYCRbxxuGMEhBkNi7mB6E\\nTHeC+CzOw/G7spOXst4AEEcZwNwnu4yBsTI61O59+wWWoVzJMCfHMAoGCCqGSM49\\nBAMCA0gAMEUCIDUg9XvYS5gYplD2XpQIs2yYyG9yC3CYDVU3oHEbAhmgAiEA0857\\njWV0BsnABl2+s/P/WYEuZWixQuO2YNGpwVG/u7g=\\n-----END CERTIFICATE-----\\n\",\"algType\":\"SHA1withECDSA\",\"certValid\":true,\"regTime\":{\"seconds\":1553247052,\"nanos\":820000000}}}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.821Z",
"signature" : "MEQCIH7d2NKf2olEKm9ZMIHy1p7S5A2GwOHdt1BJ5DbuNjACAiAI35k1esozja27njXGJXtg+xou6OcFqOH98Zx6P5q70A=="
}
}, {
"id" : "a48be5ef-1b6e-49a1-a7de-cea92043078e",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractCert",
"version" : 1
},
"ipt" : {
"function" : "SignUpCert",
"args" : [ "{\"credit_code\":\"951002007l78123233\",\"name\":\"super_admin\",\"cert\":{\"certificate\":\"-----BEGIN CERTIFICATE-----\\nMIIBrjCCAVOgAwIBAgIEXIn9HTAKBggqhkjOPQQDAjBgMQswCQYDVQQGEwJjbjEL\\nMAkGA1UECAwCYmoxCzAJBgNVBAcMAmJqMREwDwYDVQQKDAhyZXBjaGFpbjEOMAwG\\nA1UECwwFaXNjYXMxFDASBgNVBAMMC3N1cGVyX2FkbWluMB4XDTE5MDMxNDA3MDUw\\nMVoXDTIwMDMxMzA3MDUwMVowYDELMAkGA1UEBhMCY24xCzAJBgNVBAgMAmJqMQsw\\nCQYDVQQHDAJiajERMA8GA1UECgwIcmVwY2hhaW4xDjAMBgNVBAsMBWlzY2FzMRQw\\nEgYDVQQDDAtzdXBlcl9hZG1pbjBWMBAGByqGSM49AgEGBSuBBAAKA0IABBLsxfk6\\nB86BFI3ij2YJylNGzxXNRQb45mZPNfVAkQf0hImHJMP+EgCK7UfJqa1U970ZslSC\\nVTDxNyrb5wfLOIMwCgYIKoZIzj0EAwIDSQAwRgIhANUOIZN0YmYxbtmUlJeMaeEe\\nb2STEd2Z07l1WBUN+mN9AiEAqKXR2Z/F+t0lWELgO4I+fxHiw+GIBYYLlsRVy4zZ\\nvvU=\\n-----END CERTIFICATE-----\\n\",\"algType\":\"SHA1withECDSA\",\"certValid\":true,\"regTime\":{\"seconds\":1553247052,\"nanos\":823000000}}}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.824Z",
"signature" : "MEQCIAP08NkSg+hdBUIuedekAUCQQRCfD/ih2xk3M8rHtImLAiBQveEk8Yu8u90T1La7YoXYQIBiC4Jc055PuHDjbmdNUg=="
}
}, {
"id" : "c2547ea4-6ba7-4927-b722-80f3f9a2be0e",
"type" : "CHAINCODE_DEPLOY",
"cid" : {
"chaincodeName" : "ContractAssetsTPL",
"version" : 1
},
"spec" : {
"timeout" : 5000,
"codePackage" : "\n/*\n * Copyright 2018 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BA SIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\npackage rep.sc.tpl\n\nimport org.json4s._\nimport org.json4s.jackson.JsonMethods._\nimport rep.sc.contract._\nimport rep.app.conf.SystemProfile\nimport rep.protos.peer.ChaincodeId\nimport rep.utils.IdTool\n/**\n * 资产管理合约\n */\n\ncase class Transfer(from:String, to:String, amount:Int)\n\nclass ContractAssetsTPL extends IContract{\n\n // 需要跨合约读账户\n val chaincodeName = SystemProfile.getAccountChaincodeName\n val chaincodeVersion = SystemProfile.getAccountChaincodeVersion \n //val prefix = IdTool.getCid(ChaincodeId(chaincodeName, chaincodeVersion))\n\n implicit val formats = DefaultFormats\n \n def init(ctx: ContractContext){ \n println(s\"tid: $ctx.t.txid\")\n }\n \n def set(ctx: ContractContext, data:Map[String,Int]) :ActionResult={\n println(s\"set data:$data\")\n for((k,v)<-data){\n ctx.api.setVal(k, v)\n }\n new ActionResult(1,None)\n }\n \n def transfer(ctx: ContractContext, data:Transfer) :ActionResult={\n if(!data.from.equals(ctx.t.getSignature.getCertId.creditCode))\n return new ActionResult(-1, Some(\"只允许从本人账户转出\")) \n val signerKey = data.to\n // 跨合约读账户,该处并未反序列化\n if(ctx.api.getStateEx(chaincodeName,data.to)==null)\n return new ActionResult(-2, Some(\"目标账户不存在\"))\n val sfrom = ctx.api.getVal(data.from)\n var dfrom =sfrom.asInstanceOf[Int]\n if(dfrom < data.amount)\n return new ActionResult(-3, Some(\"余额不足\"))\n var dto = ctx.api.getVal(data.to).toString.toInt\n ctx.api.setVal(data.from,dfrom - data.amount)\n ctx.api.setVal(data.to,dto + data.amount)\n new ActionResult(1,None)\n }\n /**\n * 根据action,找到对应的method并将传入的json字符串parse为method需要的传入参数\n */\n def onAction(ctx: ContractContext,action:String, sdata:String ):ActionResult={\n val json = parse(sdata) \n action match {\n case \"transfer\" => \n transfer(ctx,json.extract[Transfer])\n case \"set\" => \n set(ctx, json.extract[Map[String,Int]])\n }\n }\n \n}\n",
"ctype" : "CODE_SCALA"
},
"signature" : {
"certId" : {
"creditCode" : "121000005l35120456",
"certName" : "node1"
},
"tmLocal" : "2019-03-22T17:30:52.826Z",
"signature" : "MEYCIQCoj+W+h7cVKnu2ta/fwqhiAKyQpTB0eftw+e0CTpLZ+QIhANumYz5IuFB2LuNGuTZR6yuHixoveZb6LSQXyUaV712L"
}
}, {
"id" : "8e944cbd-4c26-4e14-8e94-bcbd5ac15527",
"type" : "CHAINCODE_INVOKE",
"cid" : {
"chaincodeName" : "ContractAssetsTPL",
"version" : 1
},
"ipt" : {
"function" : "set",
"args" : [ "{\r\n \"121000005l35120456\" : 10000000,\r\n \"12110107bi45jh675g\" : 10000000,\r\n \"122000002n00123567\" : 10000000,\r\n \"921000005k36123789\" : 10000000,\r\n \"921000006e0012v696\" : 10000000\r\n}" ]
},
"signature" : {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.828Z",
"signature" : "MEYCIQCQTCoH3ERgxvA3YVJmlTSs9OLmz8O5DyA3MnLHqswydwIhAMWd6jA3CrzqBmDVUCJyVoo58lPSBF6xBtTyba5uvrN+"
}
} ],
"endorsements" : [ {
"certId" : {
"creditCode" : "951002007l78123233",
"certName" : "super_admin"
},
"tmLocal" : "2019-03-22T17:30:52.968Z",
"signature" : "MEYCIQCqjcvwWptX/B0Ro49h1kcNZQz1G5syyRdGqiYgaIpsRQIhALHuxLpS8vJjw/jobgR9PuD6dKAMSm0ozOg9QvgX+unE"
}, {
"certId" : {
"creditCode" : "121000005l35120456",
"certName" : "node1"
},
"tmLocal" : "2019-03-22T17:30:52.969Z",
"signature" : "MEYCIQDHDED7ZR4f+NrG4GiloXKRpcu3L8l1yc5zulID7CRg+wIhAOr/HqbetpQoHwzIFW7czQH8aXWMpG+NpC7PMf1Yb92l"
} ]
}