def _create_instantiation_proposal(tran_prop_req, chain): """Create a chaincode instantiation proposal This involves assembling the proposal with the data (chaincodeID, chaincode invocation spec, etc.) and signing it using the private key corresponding to the ECert to sign. Args: tran_prop_req: see TransactionProposalRequest Returns: (Proposal): The created Proposal instance or None. """ args = ["init" if not tran_prop_req.fcn else tran_prop_req.fcn] + tran_prop_req.args cc_deployment_spec = chaincode_pb2.ChaincodeDeploymentSpec() cc_deployment_spec.chaincode_spec.type = \ chaincode_pb2.ChaincodeSpec.Type.Value('GOLANG') cc_deployment_spec.chaincode_spec.chaincode_id.name = \ proto_str(tran_prop_req.chaincode_id) cc_deployment_spec.chaincode_spec.chaincode_id.path = \ proto_str(tran_prop_req.chaincode_path) cc_deployment_spec.chaincode_spec.chaincode_id.version = \ proto_str(tran_prop_req.chaincode_version) cc_deployment_spec.chaincode_spec.input.args.extend(list(map( lambda x: proto_b(x), args))) header = build_header(tran_prop_req.signing_identity, tran_prop_req.nonce, common_pb2.ENDORSER_TRANSACTION, chain, tran_prop_req.prop_type, chaincode_id=tran_prop_req.chaincode_id ) cci_spec = chaincode_pb2.ChaincodeInvocationSpec() cci_spec.chaincode_spec.type = \ chaincode_pb2.ChaincodeSpec.Type.Value('GOLANG') cci_spec.chaincode_spec.chaincode_id.name = proto_str("lscc") cci_spec.chaincode_spec.input.args.extend( [proto_b(CC_INSTANTIATE), proto_b('default'), cc_deployment_spec.SerializeToString()]) proposal = build_proposal(cci_spec, header) signed_proposal = sign_proposal( tran_prop_req.signing_identity, proposal) return signed_proposal
def _create_invocation_proposal(tran_prop_req, chain): """Create a chaincode invocation proposal This involves assembling the proposal with the data (chaincodeID, chaincode invocation spec, etc.) and signing it using the private key corresponding to the ECert to sign. Args: tran_prop_req: see TransactionProposalRequest Returns: (Proposal): The created Proposal instance or None. """ args = ["invoke" if not tran_prop_req.fcn else tran_prop_req.fcn] + tran_prop_req.args if tran_prop_req.bytes_args: args += tran_prop_req.bytes_args header = build_header(tran_prop_req.signing_identity, tran_prop_req.nonce, common_pb2.ENDORSER_TRANSACTION, chain, tran_prop_req.prop_type, chaincode_id=tran_prop_req.chaincode_id ) cci_spec = chaincode_pb2.ChaincodeInvocationSpec() cci_spec.chaincode_spec.type = \ chaincode_pb2.ChaincodeSpec.Type.Value('GOLANG') cci_spec.chaincode_spec.chaincode_id.name = \ proto_str(tran_prop_req.chaincode_id) cci_spec.chaincode_spec.chaincode_id.version = \ proto_str(tran_prop_req.chaincode_version) cci_spec.chaincode_spec.input.args.extend(list(map( lambda x: proto_b(x), args))) proposal = build_proposal(cci_spec, header) signed_proposal = sign_proposal( tran_prop_req.signing_identity, proposal) return signed_proposal