hyperledger-fabric-sdk 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fabric/block_decoder.rb +299 -0
  3. data/lib/fabric/chaincode_response.rb +47 -0
  4. data/lib/fabric/channel.rb +55 -34
  5. data/lib/fabric/client.rb +107 -25
  6. data/lib/fabric/configuration.rb +12 -4
  7. data/lib/fabric/constants.rb +1 -1
  8. data/lib/fabric/crypto_suite.rb +145 -0
  9. data/lib/fabric/enumerator_queue.rb +26 -0
  10. data/lib/fabric/error.rb +52 -0
  11. data/lib/fabric/event_hub.rb +81 -0
  12. data/lib/fabric/helper.rb +31 -0
  13. data/lib/fabric/identity.rb +25 -19
  14. data/lib/fabric/logger.rb +37 -0
  15. data/lib/fabric/orderer.rb +18 -2
  16. data/lib/fabric/peer.rb +15 -36
  17. data/lib/fabric/proposal.rb +100 -0
  18. data/lib/{protos → fabric/protos}/common/collection_pb.rb +14 -14
  19. data/lib/{protos → fabric/protos}/common/common_pb.rb +37 -36
  20. data/lib/fabric/protos/common/configtx_pb.rb +71 -0
  21. data/lib/{protos → fabric/protos}/common/configuration_pb.rb +13 -13
  22. data/lib/{protos → fabric/protos}/common/ledger_pb.rb +2 -2
  23. data/lib/{protos → fabric/protos}/common/policies_pb.rb +19 -19
  24. data/lib/fabric/protos/discovery/protocol_pb.rb +120 -0
  25. data/lib/{protos → fabric/protos}/discovery/protocol_services_pb.rb +0 -1
  26. data/lib/fabric/protos/gossip/message_pb.rb +233 -0
  27. data/lib/{protos → fabric/protos}/gossip/message_services_pb.rb +0 -1
  28. data/lib/{protos → fabric/protos}/idemix/idemix_pb.rb +37 -37
  29. data/lib/{protos → fabric/protos}/ledger/queryresult/kv_query_result_pb.rb +5 -5
  30. data/lib/fabric/protos/ledger/rwset/kvrwset/kv_rwset_pb.rb +85 -0
  31. data/lib/fabric/protos/ledger/rwset/rwset_pb.rb +46 -0
  32. data/lib/{protos → fabric/protos}/msp/identities_pb.rb +4 -4
  33. data/lib/{protos → fabric/protos}/msp/msp_config_pb.rb +27 -27
  34. data/lib/{protos → fabric/protos}/msp/msp_principal_pb.rb +20 -20
  35. data/lib/fabric/protos/orderer/ab_pb.rb +52 -0
  36. data/lib/{protos → fabric/protos}/orderer/ab_services_pb.rb +0 -1
  37. data/lib/fabric/protos/orderer/cluster_pb.rb +31 -0
  38. data/lib/fabric/protos/orderer/cluster_services_pb.rb +31 -0
  39. data/lib/{protos → fabric/protos}/orderer/configuration_pb.rb +11 -10
  40. data/lib/fabric/protos/orderer/etcdraft/configuration_pb.rb +21 -0
  41. data/lib/{protos → fabric/protos}/orderer/kafka_pb.rb +16 -16
  42. data/lib/{protos → fabric/protos}/peer/admin_pb.rb +12 -12
  43. data/lib/{protos → fabric/protos}/peer/admin_services_pb.rb +0 -1
  44. data/lib/{protos → fabric/protos}/peer/chaincode_event_pb.rb +2 -2
  45. data/lib/fabric/protos/peer/chaincode_pb.rb +60 -0
  46. data/lib/fabric/protos/peer/chaincode_shim_pb.rb +129 -0
  47. data/lib/{protos → fabric/protos}/peer/chaincode_shim_services_pb.rb +0 -1
  48. data/lib/{protos → fabric/protos}/peer/configuration_pb.rb +10 -10
  49. data/lib/fabric/protos/peer/events_pb.rb +45 -0
  50. data/lib/fabric/protos/peer/events_services_pb.rb +34 -0
  51. data/lib/{protos → fabric/protos}/peer/peer_pb.rb +5 -5
  52. data/lib/{protos → fabric/protos}/peer/peer_services_pb.rb +0 -1
  53. data/lib/{protos → fabric/protos}/peer/proposal_pb.rb +13 -13
  54. data/lib/{protos → fabric/protos}/peer/proposal_response_pb.rb +11 -11
  55. data/lib/{protos → fabric/protos}/peer/query_pb.rb +10 -10
  56. data/lib/{protos → fabric/protos}/peer/resources_pb.rb +12 -12
  57. data/lib/{protos → fabric/protos}/peer/signed_cc_dep_spec_pb.rb +3 -3
  58. data/lib/{protos → fabric/protos}/peer/transaction_pb.rb +22 -18
  59. data/lib/fabric/protos/token/prover_pb.rb +66 -0
  60. data/lib/fabric/protos/token/prover_services_pb.rb +33 -0
  61. data/lib/fabric/protos/token/transaction_pb.rb +41 -0
  62. data/lib/{protos → fabric/protos}/transientstore/transientstore_pb.rb +4 -4
  63. data/lib/fabric/queue.rb +26 -0
  64. data/lib/fabric/transaction.rb +51 -0
  65. data/lib/fabric/transaction_info.rb +20 -0
  66. data/lib/fabric/version.rb +1 -1
  67. data/lib/fabric.rb +74 -0
  68. data/lib/fabric_ca/attribute.rb +7 -0
  69. data/lib/fabric_ca/client.rb +11 -19
  70. data/lib/fabric_ca/configuration.rb +4 -2
  71. data/lib/fabric_ca/connection.rb +22 -20
  72. data/lib/fabric_ca/error.rb +3 -2
  73. data/lib/fabric_ca/faraday_middleware/basic_auth.rb +3 -3
  74. data/lib/fabric_ca/faraday_middleware/raise_http_exception.rb +13 -13
  75. data/lib/fabric_ca/faraday_middleware/token_auth.rb +10 -12
  76. data/lib/fabric_ca/request.rb +13 -24
  77. data/lib/fabric_ca/version.rb +1 -1
  78. data/lib/fabric_ca.rb +16 -0
  79. data/lib/hyperledger-fabric-sdk.rb +2 -47
  80. metadata +161 -61
  81. data/lib/crypto_suite/ecdsa_aes.rb +0 -86
  82. data/lib/fabric/peer_endorser.rb +0 -85
  83. data/lib/fabric/transaction_id.rb +0 -11
  84. data/lib/fabric/user.rb +0 -24
  85. data/lib/fabric_ca/tools.rb +0 -35
  86. data/lib/protos/common/configtx_pb.rb +0 -71
  87. data/lib/protos/discovery/protocol_pb.rb +0 -119
  88. data/lib/protos/gossip/message_pb.rb +0 -233
  89. data/lib/protos/ledger/rwset/kvrwset/kv_rwset_pb.rb +0 -85
  90. data/lib/protos/ledger/rwset/rwset_pb.rb +0 -46
  91. data/lib/protos/orderer/ab_pb.rb +0 -52
  92. data/lib/protos/peer/chaincode_pb.rb +0 -60
  93. data/lib/protos/peer/chaincode_shim_pb.rb +0 -94
  94. data/lib/protos/peer/events_pb.rb +0 -98
  95. data/lib/protos/peer/events_services_pb.rb +0 -59
@@ -0,0 +1,45 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: peer/events.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'common/common_pb'
7
+ require 'google/protobuf/timestamp_pb'
8
+ require 'peer/chaincode_event_pb'
9
+ require 'peer/transaction_pb'
10
+ Google::Protobuf::DescriptorPool.generated_pool.build do
11
+ add_message 'protos.FilteredBlock' do
12
+ optional :channel_id, :string, 1
13
+ optional :number, :uint64, 2
14
+ repeated :filtered_transactions, :message, 4, 'protos.FilteredTransaction'
15
+ end
16
+ add_message 'protos.FilteredTransaction' do
17
+ optional :txid, :string, 1
18
+ optional :type, :enum, 2, 'common.HeaderType'
19
+ optional :tx_validation_code, :enum, 3, 'protos.TxValidationCode'
20
+ oneof :Data do
21
+ optional :transaction_actions, :message, 4, 'protos.FilteredTransactionActions'
22
+ end
23
+ end
24
+ add_message 'protos.FilteredTransactionActions' do
25
+ repeated :chaincode_actions, :message, 1, 'protos.FilteredChaincodeAction'
26
+ end
27
+ add_message 'protos.FilteredChaincodeAction' do
28
+ optional :chaincode_event, :message, 1, 'protos.ChaincodeEvent'
29
+ end
30
+ add_message 'protos.DeliverResponse' do
31
+ oneof :Type do
32
+ optional :status, :enum, 1, 'common.Status'
33
+ optional :block, :message, 2, 'common.Block'
34
+ optional :filtered_block, :message, 3, 'protos.FilteredBlock'
35
+ end
36
+ end
37
+ end
38
+
39
+ module Protos
40
+ FilteredBlock = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.FilteredBlock').msgclass
41
+ FilteredTransaction = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.FilteredTransaction').msgclass
42
+ FilteredTransactionActions = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.FilteredTransactionActions').msgclass
43
+ FilteredChaincodeAction = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.FilteredChaincodeAction').msgclass
44
+ DeliverResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.DeliverResponse').msgclass
45
+ end
@@ -0,0 +1,34 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: peer/events.proto for package 'protos'
3
+ # Original file comments:
4
+ #
5
+ # Copyright IBM Corp. All Rights Reserved.
6
+ #
7
+ # SPDX-License-Identifier: Apache-2.0
8
+ #
9
+
10
+ require 'grpc'
11
+ require 'peer/events_pb'
12
+
13
+ module Protos
14
+ module Deliver
15
+ class Service
16
+ include GRPC::GenericService
17
+
18
+ self.marshal_class_method = :encode
19
+ self.unmarshal_class_method = :decode
20
+ self.service_name = 'protos.Deliver'
21
+
22
+ # deliver first requires an Envelope of type ab.DELIVER_SEEK_INFO with
23
+ # Payload data as a marshaled orderer.SeekInfo message,
24
+ # then a stream of block replies is received
25
+ rpc :Deliver, stream(Common::Envelope), stream(DeliverResponse)
26
+ # deliver first requires an Envelope of type ab.DELIVER_SEEK_INFO with
27
+ # Payload data as a marshaled orderer.SeekInfo message,
28
+ # then a stream of **filtered** block replies is received
29
+ rpc :DeliverFiltered, stream(Common::Envelope), stream(DeliverResponse)
30
+ end
31
+
32
+ Stub = Service.rpc_stub_class
33
+ end
34
+ end
@@ -6,16 +6,16 @@ require 'google/protobuf'
6
6
  require 'peer/proposal_pb'
7
7
  require 'peer/proposal_response_pb'
8
8
  Google::Protobuf::DescriptorPool.generated_pool.build do
9
- add_message "protos.PeerID" do
9
+ add_message 'protos.PeerID' do
10
10
  optional :name, :string, 1
11
11
  end
12
- add_message "protos.PeerEndpoint" do
13
- optional :id, :message, 1, "protos.PeerID"
12
+ add_message 'protos.PeerEndpoint' do
13
+ optional :id, :message, 1, 'protos.PeerID'
14
14
  optional :address, :string, 2
15
15
  end
16
16
  end
17
17
 
18
18
  module Protos
19
- PeerID = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.PeerID").msgclass
20
- PeerEndpoint = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.PeerEndpoint").msgclass
19
+ PeerID = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.PeerID').msgclass
20
+ PeerEndpoint = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.PeerEndpoint').msgclass
21
21
  end
@@ -22,7 +22,6 @@ require 'peer/peer_pb'
22
22
  module Protos
23
23
  module Endorser
24
24
  class Service
25
-
26
25
  include GRPC::GenericService
27
26
 
28
27
  self.marshal_class_method = :encode
@@ -6,35 +6,35 @@ require 'google/protobuf'
6
6
  require 'peer/chaincode_pb'
7
7
  require 'peer/proposal_response_pb'
8
8
  Google::Protobuf::DescriptorPool.generated_pool.build do
9
- add_message "protos.SignedProposal" do
9
+ add_message 'protos.SignedProposal' do
10
10
  optional :proposal_bytes, :bytes, 1
11
11
  optional :signature, :bytes, 2
12
12
  end
13
- add_message "protos.Proposal" do
13
+ add_message 'protos.Proposal' do
14
14
  optional :header, :bytes, 1
15
15
  optional :payload, :bytes, 2
16
16
  optional :extension, :bytes, 3
17
17
  end
18
- add_message "protos.ChaincodeHeaderExtension" do
18
+ add_message 'protos.ChaincodeHeaderExtension' do
19
19
  optional :payload_visibility, :bytes, 1
20
- optional :chaincode_id, :message, 2, "protos.ChaincodeID"
20
+ optional :chaincode_id, :message, 2, 'protos.ChaincodeID'
21
21
  end
22
- add_message "protos.ChaincodeProposalPayload" do
22
+ add_message 'protos.ChaincodeProposalPayload' do
23
23
  optional :input, :bytes, 1
24
24
  map :TransientMap, :string, :bytes, 2
25
25
  end
26
- add_message "protos.ChaincodeAction" do
26
+ add_message 'protos.ChaincodeAction' do
27
27
  optional :results, :bytes, 1
28
28
  optional :events, :bytes, 2
29
- optional :response, :message, 3, "protos.Response"
30
- optional :chaincode_id, :message, 4, "protos.ChaincodeID"
29
+ optional :response, :message, 3, 'protos.Response'
30
+ optional :chaincode_id, :message, 4, 'protos.ChaincodeID'
31
31
  end
32
32
  end
33
33
 
34
34
  module Protos
35
- SignedProposal = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.SignedProposal").msgclass
36
- Proposal = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.Proposal").msgclass
37
- ChaincodeHeaderExtension = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeHeaderExtension").msgclass
38
- ChaincodeProposalPayload = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeProposalPayload").msgclass
39
- ChaincodeAction = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeAction").msgclass
35
+ SignedProposal = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.SignedProposal').msgclass
36
+ Proposal = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.Proposal').msgclass
37
+ ChaincodeHeaderExtension = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeHeaderExtension').msgclass
38
+ ChaincodeProposalPayload = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeProposalPayload').msgclass
39
+ ChaincodeAction = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeAction').msgclass
40
40
  end
@@ -5,31 +5,31 @@ require 'google/protobuf'
5
5
 
6
6
  require 'google/protobuf/timestamp_pb'
7
7
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
- add_message "protos.ProposalResponse" do
8
+ add_message 'protos.ProposalResponse' do
9
9
  optional :version, :int32, 1
10
- optional :timestamp, :message, 2, "google.protobuf.Timestamp"
11
- optional :response, :message, 4, "protos.Response"
10
+ optional :timestamp, :message, 2, 'google.protobuf.Timestamp'
11
+ optional :response, :message, 4, 'protos.Response'
12
12
  optional :payload, :bytes, 5
13
- optional :endorsement, :message, 6, "protos.Endorsement"
13
+ optional :endorsement, :message, 6, 'protos.Endorsement'
14
14
  end
15
- add_message "protos.Response" do
15
+ add_message 'protos.Response' do
16
16
  optional :status, :int32, 1
17
17
  optional :message, :string, 2
18
18
  optional :payload, :bytes, 3
19
19
  end
20
- add_message "protos.ProposalResponsePayload" do
20
+ add_message 'protos.ProposalResponsePayload' do
21
21
  optional :proposal_hash, :bytes, 1
22
22
  optional :extension, :bytes, 2
23
23
  end
24
- add_message "protos.Endorsement" do
24
+ add_message 'protos.Endorsement' do
25
25
  optional :endorser, :bytes, 1
26
26
  optional :signature, :bytes, 2
27
27
  end
28
28
  end
29
29
 
30
30
  module Protos
31
- ProposalResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ProposalResponse").msgclass
32
- Response = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.Response").msgclass
33
- ProposalResponsePayload = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ProposalResponsePayload").msgclass
34
- Endorsement = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.Endorsement").msgclass
31
+ ProposalResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ProposalResponse').msgclass
32
+ Response = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.Response').msgclass
33
+ ProposalResponsePayload = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ProposalResponsePayload').msgclass
34
+ Endorsement = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.Endorsement').msgclass
35
35
  end
@@ -4,10 +4,10 @@
4
4
  require 'google/protobuf'
5
5
 
6
6
  Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_message "protos.ChaincodeQueryResponse" do
8
- repeated :chaincodes, :message, 1, "protos.ChaincodeInfo"
7
+ add_message 'protos.ChaincodeQueryResponse' do
8
+ repeated :chaincodes, :message, 1, 'protos.ChaincodeInfo'
9
9
  end
10
- add_message "protos.ChaincodeInfo" do
10
+ add_message 'protos.ChaincodeInfo' do
11
11
  optional :name, :string, 1
12
12
  optional :version, :string, 2
13
13
  optional :path, :string, 3
@@ -16,17 +16,17 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
16
16
  optional :vscc, :string, 6
17
17
  optional :id, :bytes, 7
18
18
  end
19
- add_message "protos.ChannelQueryResponse" do
20
- repeated :channels, :message, 1, "protos.ChannelInfo"
19
+ add_message 'protos.ChannelQueryResponse' do
20
+ repeated :channels, :message, 1, 'protos.ChannelInfo'
21
21
  end
22
- add_message "protos.ChannelInfo" do
22
+ add_message 'protos.ChannelInfo' do
23
23
  optional :channel_id, :string, 1
24
24
  end
25
25
  end
26
26
 
27
27
  module Protos
28
- ChaincodeQueryResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeQueryResponse").msgclass
29
- ChaincodeInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeInfo").msgclass
30
- ChannelQueryResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChannelQueryResponse").msgclass
31
- ChannelInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChannelInfo").msgclass
28
+ ChaincodeQueryResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeQueryResponse').msgclass
29
+ ChaincodeInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeInfo').msgclass
30
+ ChannelQueryResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChannelQueryResponse').msgclass
31
+ ChannelInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChannelInfo').msgclass
32
32
  end
@@ -5,30 +5,30 @@ require 'google/protobuf'
5
5
 
6
6
  require 'common/configtx_pb'
7
7
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
- add_message "protos.ChaincodeIdentifier" do
8
+ add_message 'protos.ChaincodeIdentifier' do
9
9
  optional :hash, :bytes, 1
10
10
  optional :version, :string, 2
11
11
  end
12
- add_message "protos.ChaincodeValidation" do
12
+ add_message 'protos.ChaincodeValidation' do
13
13
  optional :name, :string, 1
14
14
  optional :argument, :bytes, 2
15
15
  end
16
- add_message "protos.VSCCArgs" do
16
+ add_message 'protos.VSCCArgs' do
17
17
  optional :endorsement_policy_ref, :string, 1
18
18
  end
19
- add_message "protos.ChaincodeEndorsement" do
19
+ add_message 'protos.ChaincodeEndorsement' do
20
20
  optional :name, :string, 1
21
21
  end
22
- add_message "protos.ConfigTree" do
23
- optional :channel_config, :message, 1, "common.Config"
24
- optional :resources_config, :message, 2, "common.Config"
22
+ add_message 'protos.ConfigTree' do
23
+ optional :channel_config, :message, 1, 'common.Config'
24
+ optional :resources_config, :message, 2, 'common.Config'
25
25
  end
26
26
  end
27
27
 
28
28
  module Protos
29
- ChaincodeIdentifier = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeIdentifier").msgclass
30
- ChaincodeValidation = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeValidation").msgclass
31
- VSCCArgs = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.VSCCArgs").msgclass
32
- ChaincodeEndorsement = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeEndorsement").msgclass
33
- ConfigTree = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ConfigTree").msgclass
29
+ ChaincodeIdentifier = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeIdentifier').msgclass
30
+ ChaincodeValidation = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeValidation').msgclass
31
+ VSCCArgs = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.VSCCArgs').msgclass
32
+ ChaincodeEndorsement = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeEndorsement').msgclass
33
+ ConfigTree = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ConfigTree').msgclass
34
34
  end
@@ -5,13 +5,13 @@ require 'google/protobuf'
5
5
 
6
6
  require 'peer/proposal_response_pb'
7
7
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
- add_message "protos.SignedChaincodeDeploymentSpec" do
8
+ add_message 'protos.SignedChaincodeDeploymentSpec' do
9
9
  optional :chaincode_deployment_spec, :bytes, 1
10
10
  optional :instantiation_policy, :bytes, 2
11
- repeated :owner_endorsements, :message, 3, "protos.Endorsement"
11
+ repeated :owner_endorsements, :message, 3, 'protos.Endorsement'
12
12
  end
13
13
  end
14
14
 
15
15
  module Protos
16
- SignedChaincodeDeploymentSpec = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.SignedChaincodeDeploymentSpec").msgclass
16
+ SignedChaincodeDeploymentSpec = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.SignedChaincodeDeploymentSpec').msgclass
17
17
  end
@@ -7,30 +7,30 @@ require 'google/protobuf/timestamp_pb'
7
7
  require 'peer/proposal_response_pb'
8
8
  require 'common/common_pb'
9
9
  Google::Protobuf::DescriptorPool.generated_pool.build do
10
- add_message "protos.SignedTransaction" do
10
+ add_message 'protos.SignedTransaction' do
11
11
  optional :transaction_bytes, :bytes, 1
12
12
  optional :signature, :bytes, 2
13
13
  end
14
- add_message "protos.ProcessedTransaction" do
15
- optional :transactionEnvelope, :message, 1, "common.Envelope"
14
+ add_message 'protos.ProcessedTransaction' do
15
+ optional :transactionEnvelope, :message, 1, 'common.Envelope'
16
16
  optional :validationCode, :int32, 2
17
17
  end
18
- add_message "protos.Transaction" do
19
- repeated :actions, :message, 1, "protos.TransactionAction"
18
+ add_message 'protos.Transaction' do
19
+ repeated :actions, :message, 1, 'protos.TransactionAction'
20
20
  end
21
- add_message "protos.TransactionAction" do
21
+ add_message 'protos.TransactionAction' do
22
22
  optional :header, :bytes, 1
23
23
  optional :payload, :bytes, 2
24
24
  end
25
- add_message "protos.ChaincodeActionPayload" do
25
+ add_message 'protos.ChaincodeActionPayload' do
26
26
  optional :chaincode_proposal_payload, :bytes, 1
27
- optional :action, :message, 2, "protos.ChaincodeEndorsedAction"
27
+ optional :action, :message, 2, 'protos.ChaincodeEndorsedAction'
28
28
  end
29
- add_message "protos.ChaincodeEndorsedAction" do
29
+ add_message 'protos.ChaincodeEndorsedAction' do
30
30
  optional :proposal_response_payload, :bytes, 1
31
- repeated :endorsements, :message, 2, "protos.Endorsement"
31
+ repeated :endorsements, :message, 2, 'protos.Endorsement'
32
32
  end
33
- add_enum "protos.TxValidationCode" do
33
+ add_enum 'protos.TxValidationCode' do
34
34
  value :VALID, 0
35
35
  value :NIL_ENVELOPE, 1
36
36
  value :BAD_PAYLOAD, 2
@@ -59,14 +59,18 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
59
59
  value :NOT_VALIDATED, 254
60
60
  value :INVALID_OTHER_REASON, 255
61
61
  end
62
+ add_enum 'protos.MetaDataKeys' do
63
+ value :VALIDATION_PARAMETER, 0
64
+ end
62
65
  end
63
66
 
64
67
  module Protos
65
- SignedTransaction = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.SignedTransaction").msgclass
66
- ProcessedTransaction = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ProcessedTransaction").msgclass
67
- Transaction = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.Transaction").msgclass
68
- TransactionAction = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.TransactionAction").msgclass
69
- ChaincodeActionPayload = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeActionPayload").msgclass
70
- ChaincodeEndorsedAction = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.ChaincodeEndorsedAction").msgclass
71
- TxValidationCode = Google::Protobuf::DescriptorPool.generated_pool.lookup("protos.TxValidationCode").enummodule
68
+ SignedTransaction = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.SignedTransaction').msgclass
69
+ ProcessedTransaction = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ProcessedTransaction').msgclass
70
+ Transaction = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.Transaction').msgclass
71
+ TransactionAction = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.TransactionAction').msgclass
72
+ ChaincodeActionPayload = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeActionPayload').msgclass
73
+ ChaincodeEndorsedAction = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ChaincodeEndorsedAction').msgclass
74
+ TxValidationCode = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.TxValidationCode').enummodule
75
+ MetaDataKeys = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.MetaDataKeys').enummodule
72
76
  end
@@ -0,0 +1,66 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: token/prover.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/protobuf/timestamp_pb'
7
+ require 'token/transaction_pb'
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_message 'protos.TokenToIssue' do
10
+ optional :recipient, :bytes, 1
11
+ optional :type, :string, 2
12
+ optional :quantity, :uint64, 3
13
+ end
14
+ add_message 'protos.ImportRequest' do
15
+ optional :credential, :bytes, 1
16
+ repeated :tokens_to_issue, :message, 2, 'protos.TokenToIssue'
17
+ end
18
+ add_message 'protos.Header' do
19
+ optional :timestamp, :message, 1, 'google.protobuf.Timestamp'
20
+ optional :channel_id, :string, 2
21
+ optional :nonce, :bytes, 3
22
+ optional :creator, :bytes, 4
23
+ end
24
+ add_message 'protos.Command' do
25
+ optional :header, :message, 1, 'protos.Header'
26
+ oneof :payload do
27
+ optional :import_request, :message, 2, 'protos.ImportRequest'
28
+ end
29
+ end
30
+ add_message 'protos.SignedCommand' do
31
+ optional :command, :bytes, 1
32
+ optional :signature, :bytes, 2
33
+ end
34
+ add_message 'protos.CommandResponseHeader' do
35
+ optional :timestamp, :message, 1, 'google.protobuf.Timestamp'
36
+ optional :command_hash, :bytes, 2
37
+ optional :creator, :bytes, 3
38
+ end
39
+ add_message 'protos.Error' do
40
+ optional :message, :string, 1
41
+ optional :payload, :bytes, 2
42
+ end
43
+ add_message 'protos.CommandResponse' do
44
+ optional :header, :message, 1, 'protos.CommandResponseHeader'
45
+ oneof :payload do
46
+ optional :err, :message, 2, 'protos.Error'
47
+ optional :token_transaction, :message, 3, 'TokenTransaction'
48
+ end
49
+ end
50
+ add_message 'protos.SignedCommandResponse' do
51
+ optional :response, :bytes, 1
52
+ optional :signature, :bytes, 2
53
+ end
54
+ end
55
+
56
+ module Protos
57
+ TokenToIssue = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.TokenToIssue').msgclass
58
+ ImportRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.ImportRequest').msgclass
59
+ Header = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.Header').msgclass
60
+ Command = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.Command').msgclass
61
+ SignedCommand = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.SignedCommand').msgclass
62
+ CommandResponseHeader = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.CommandResponseHeader').msgclass
63
+ Error = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.Error').msgclass
64
+ CommandResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.CommandResponse').msgclass
65
+ SignedCommandResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup('protos.SignedCommandResponse').msgclass
66
+ end
@@ -0,0 +1,33 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: token/prover.proto for package 'protos'
3
+ # Original file comments:
4
+ #
5
+ # Copyright IBM Corp. All Rights Reserved.
6
+ #
7
+ # SPDX-License-Identifier: Apache-2.0
8
+ #
9
+
10
+ require 'grpc'
11
+ require 'token/prover_pb'
12
+
13
+ module Protos
14
+ module Prover
15
+ # Prover provides support to clients for the creation of FabToken transactions,
16
+ # and to query the ledger.
17
+ class Service
18
+ include GRPC::GenericService
19
+
20
+ self.marshal_class_method = :encode
21
+ self.unmarshal_class_method = :decode
22
+ self.service_name = 'protos.Prover'
23
+
24
+ # ProcessCommand processes the passed command ensuring proper access control.
25
+ # The returned response allows the client to understand if the
26
+ # operation was succeffully executed and if not, the response
27
+ # reports the reason of the failure.
28
+ rpc :ProcessCommand, SignedCommand, SignedCommandResponse
29
+ end
30
+
31
+ Stub = Service.rpc_stub_class
32
+ end
33
+ end
@@ -0,0 +1,41 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: token/transaction.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_message 'TokenTransaction' do
8
+ oneof :action do
9
+ optional :plain_action, :message, 1, 'PlainTokenAction'
10
+ end
11
+ end
12
+ add_message 'PlainTokenAction' do
13
+ oneof :data do
14
+ optional :plain_import, :message, 1, 'PlainImport'
15
+ optional :plain_transfer, :message, 2, 'PlainTransfer'
16
+ end
17
+ end
18
+ add_message 'PlainImport' do
19
+ repeated :outputs, :message, 1, 'PlainOutput'
20
+ end
21
+ add_message 'PlainTransfer' do
22
+ repeated :inputs, :message, 1, 'InputId'
23
+ repeated :outputs, :message, 2, 'PlainOutput'
24
+ end
25
+ add_message 'PlainOutput' do
26
+ optional :owner, :bytes, 1
27
+ optional :type, :string, 2
28
+ optional :quantity, :uint64, 3
29
+ end
30
+ add_message 'InputId' do
31
+ optional :tx_id, :bytes, 1
32
+ optional :index, :uint32, 2
33
+ end
34
+ end
35
+
36
+ TokenTransaction = Google::Protobuf::DescriptorPool.generated_pool.lookup('TokenTransaction').msgclass
37
+ PlainTokenAction = Google::Protobuf::DescriptorPool.generated_pool.lookup('PlainTokenAction').msgclass
38
+ PlainImport = Google::Protobuf::DescriptorPool.generated_pool.lookup('PlainImport').msgclass
39
+ PlainTransfer = Google::Protobuf::DescriptorPool.generated_pool.lookup('PlainTransfer').msgclass
40
+ PlainOutput = Google::Protobuf::DescriptorPool.generated_pool.lookup('PlainOutput').msgclass
41
+ InputId = Google::Protobuf::DescriptorPool.generated_pool.lookup('InputId').msgclass
@@ -6,13 +6,13 @@ require 'google/protobuf'
6
6
  require 'ledger/rwset/rwset_pb'
7
7
  require 'common/collection_pb'
8
8
  Google::Protobuf::DescriptorPool.generated_pool.build do
9
- add_message "transientstore.TxPvtReadWriteSetWithConfigInfo" do
9
+ add_message 'transientstore.TxPvtReadWriteSetWithConfigInfo' do
10
10
  optional :endorsed_at, :uint64, 1
11
- optional :pvt_rwset, :message, 2, "rwset.TxPvtReadWriteSet"
12
- map :collection_configs, :string, :message, 3, "common.CollectionConfigPackage"
11
+ optional :pvt_rwset, :message, 2, 'rwset.TxPvtReadWriteSet'
12
+ map :collection_configs, :string, :message, 3, 'common.CollectionConfigPackage'
13
13
  end
14
14
  end
15
15
 
16
16
  module Transientstore
17
- TxPvtReadWriteSetWithConfigInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("transientstore.TxPvtReadWriteSetWithConfigInfo").msgclass
17
+ TxPvtReadWriteSetWithConfigInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup('transientstore.TxPvtReadWriteSetWithConfigInfo').msgclass
18
18
  end
@@ -0,0 +1,26 @@
1
+ module Fabric
2
+ class EnumeratorQueue
3
+ extend Forwardable
4
+ def_delegators :@q, :push
5
+ def_delegators :@q, :size
6
+
7
+ def initialize(sentinel)
8
+ @q = Queue.new
9
+ @sentinel = sentinel
10
+ end
11
+
12
+ def each
13
+ return enum_for(:each) unless block_given?
14
+
15
+ loop do
16
+ r = @q.pop
17
+
18
+ break if r.equal?(@sentinel)
19
+
20
+ raise r if r.is_a? Exception
21
+
22
+ yield r
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,51 @@
1
+ require 'peer/transaction_pb'
2
+
3
+ module Fabric
4
+ class Transaction
5
+ attr_reader :crypto_suite, :identity, :request
6
+
7
+ def initialize(crypto_suite, identity, request = {})
8
+ @crypto_suite = crypto_suite
9
+ @identity = identity
10
+ @request = request
11
+ end
12
+
13
+ def tx_id
14
+ proposal.tx_id
15
+ end
16
+
17
+ def proposal
18
+ request[:proposal]
19
+ end
20
+
21
+ def responses
22
+ request[:responses]
23
+ end
24
+
25
+ def endorsements
26
+ responses.map(&:endorsement)
27
+ end
28
+
29
+ def header
30
+ proposal.header
31
+ end
32
+
33
+ def transaction
34
+ transaction_action = Protos::TransactionAction.new header: proposal.signature_header.to_proto,
35
+ payload: chaincode_action.to_proto
36
+ Protos::Transaction.new actions: [transaction_action]
37
+ end
38
+
39
+ def chaincode_action
40
+ action =
41
+ Protos::ChaincodeEndorsedAction.new proposal_response_payload: responses.first.payload,
42
+ endorsements: endorsements
43
+
44
+ payload = Protos::ChaincodeProposalPayload.decode proposal.proposal.payload
45
+ payload_no_trans = Protos::ChaincodeProposalPayload.new input: payload.input
46
+
47
+ Protos::ChaincodeActionPayload.new action: action,
48
+ chaincode_proposal_payload: payload_no_trans.to_proto
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,20 @@
1
+ module Fabric
2
+ class TransactionInfo
3
+ attr_reader :tx_id, :nonce, :crypto_suite, :identity
4
+
5
+ def initialize(crypto_suite, identity)
6
+ @identity = identity
7
+ @nonce = crypto_suite.generate_nonce
8
+ @tx_id = crypto_suite.hexdigest(nonce + identity.serialize)
9
+ @crypto_suite = crypto_suite
10
+ end
11
+
12
+ def nonce_hex
13
+ crypto_suite.encode_hex nonce
14
+ end
15
+
16
+ def signature_header
17
+ ::Common::SignatureHeader.new creator: identity.serialize, nonce: nonce
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Fabric
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.1'.freeze
3
3
  end