fabric-gateway 0.2.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d791b2c862c686b8d4d6877dbf5fedd6563b4d5ba2092c832a018deb5d48c575
4
- data.tar.gz: 239128c906f1ac613d562d929a6ff5b9cc72d0e9dc1adfba3b9b4a8e306228f1
3
+ metadata.gz: 51017a36a52c447bd52777486b764ddc09fcfc1c19bca1943da465c49cbc4294
4
+ data.tar.gz: 52e5b9b209eb53cfe246c4a41b9f7d91d1abee940162cc9c23599f75d0c0e6b0
5
5
  SHA512:
6
- metadata.gz: ec91a9bca5003ec961e93ce670d8006a698c071f51b81a7d9ab6dcd011480597e7decc396607f6f4fbef5b29cd0b7ab2986239f558711ebd333599da8d07eddd
7
- data.tar.gz: 6795e691fa38795aacc3e9cf0d9472cb9924105b184d283aa13ad1b7732445a334a713bc6ed79e6c283c70aa51ebbee37ace55f84e5a9d68a0c96aee5711f499
6
+ metadata.gz: e8f61a0b72d738c832c48bbdc56b4c4aa182802e9f892eb12c701b755ff158c560e106aca0ce914e411fca58a322139d6ebd8ee09c7cf921d6ab671322912f8d
7
+ data.tar.gz: 63b48fe7fa040153d0142f537fe6d73a7285c0d7652d5e73901df816101c536108ade11f438918c69eabbb0c43a8fdd5d594b015b8140dea4d8b5208e79d3c29
@@ -0,0 +1,71 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ master ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ master ]
20
+ schedule:
21
+ - cron: '25 10 * * 6'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v2
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v1
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v1
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 https://git.io/JvXDl
60
+
61
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
+ # and modify them (or add more) to build your code if your project
63
+ # uses a compiled language
64
+
65
+ #- run: |
66
+ # make bootstrap
67
+ # make release
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v1
71
+
@@ -3,7 +3,7 @@ name: RuboCop
3
3
  on: [push, pull_request]
4
4
 
5
5
  jobs:
6
- build:
6
+ lint:
7
7
  runs-on: ubuntu-latest
8
8
 
9
9
  steps:
@@ -0,0 +1,10 @@
1
+ name: "TODO to Github Issues"
2
+ on: ["pull_request"]
3
+ jobs:
4
+ build:
5
+ runs-on: "ubuntu-latest"
6
+ steps:
7
+ - uses: "actions/checkout@master"
8
+ - name: "TODO to Issue"
9
+ uses: "alstr/todo-to-issue-action@v4.5"
10
+ id: "todo"
@@ -0,0 +1,28 @@
1
+ name: Yardoc Documentation Coverage
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - name: Set up Ruby 2.7
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: 2.7
15
+ - name: Cache gems
16
+ uses: actions/cache@v1
17
+ with:
18
+ path: vendor/bundle
19
+ key: ${{ runner.os }}-yardoc-${{ hashFiles('**/Gemfile.lock') }}
20
+ restore-keys: |
21
+ ${{ runner.os }}-yardoc-
22
+ - name: Install gems
23
+ run: |
24
+ bundle config path vendor/bundle
25
+ bundle config set without 'default doc job cable storage ujs test db'
26
+ bundle install --jobs 4 --retry 3
27
+ - name: Run yard stats
28
+ run: bundle exec yard stats --list-undoc --no-cache --fail-on-warning
data/.yardopts ADDED
@@ -0,0 +1,8 @@
1
+ --exclude lib/gateway
2
+ --exclude lib/msp
3
+ --exclude lib/gossip
4
+ --exclude lib/orderer
5
+ --exclude lib/peer
6
+ --exclude lib/common
7
+ --markup-provider=redcarpet
8
+ --markup=markdown
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Fabric::Gateway
2
2
 
3
- ![Rspec Tests](https://github.com/EthicalIdentity/fabric-gateway-ruby/actions/workflows/rspec.yml/badge.svg) [![codecov](https://codecov.io/gh/EthicalIdentity/fabric-gateway-ruby/branch/master/graph/badge.svg?token=AXHQEN0R2R)](https://codecov.io/gh/EthicalIdentity/fabric-gateway-ruby) [![Maintainability](https://api.codeclimate.com/v1/badges/84bab9bb5911d3564df6/maintainability)](https://codeclimate.com/github/EthicalIdentity/fabric-gateway-ruby/maintainability) ![Gem](https://img.shields.io/gem/v/fabric-gateway) ![Downloads](https://img.shields.io/gem/dt/fabric-gateway) [![GitHub license](https://img.shields.io/github/license/EthicalIdentity/fabric-gateway-ruby)](https://github.com/EthicalIdentity/fabric-gateway-ruby/blob/master/LICENSE.txt)
3
+ [![Rspec Tests](https://github.com/EthicalIdentity/fabric-gateway-ruby/actions/workflows/rspec.yml/badge.svg)](https://github.com/EthicalIdentity/fabric-gateway-ruby/actions/workflows/rspec.yml?query=branch%3Amaster) [![codecov](https://codecov.io/gh/EthicalIdentity/fabric-gateway-ruby/branch/master/graph/badge.svg?token=AXHQEN0R2R)](https://codecov.io/gh/EthicalIdentity/fabric-gateway-ruby) [![Maintainability](https://api.codeclimate.com/v1/badges/84bab9bb5911d3564df6/maintainability)](https://codeclimate.com/github/EthicalIdentity/fabric-gateway-ruby/maintainability) [![Gem](https://img.shields.io/gem/v/fabric-gateway)](https://rubygems.org/gems/fabric-gateway) [![Downloads](https://img.shields.io/gem/dt/fabric-gateway)](https://rubygems.org/gems/fabric-gateway) [![GitHub license](https://img.shields.io/github/license/EthicalIdentity/fabric-gateway-ruby)](https://github.com/EthicalIdentity/fabric-gateway-ruby/blob/master/LICENSE.txt)
4
4
 
5
5
 
6
6
 
7
- Hyperledger Fabric Gateway gRPC SDK generated directly from protos found at: https://github.com/hyperledger/fabric-protos.
7
+ [Hyperledger Fabric Gateway SDK](https://hyperledger-fabric.readthedocs.io/en/latest/gateway.html) ported to idiomatic ruby.
8
8
 
9
9
  ## Installation
10
10
 
@@ -32,18 +32,20 @@ Will update to new version of grpc when fix is released.
32
32
 
33
33
  ## Usage
34
34
 
35
- This is an alpha stage library suitable for early adopters. Not all Hyperledger Fabric Gateway operations have been implemented. However the operations that have been implemented have pretty good unit test coverage.
35
+ This is a beta stage library with all the main hyperledger gateway calls implemented. Although this library has good unit test coverage, it is fairly new and has not yet been run in production environments. The library will be updated to 1.0.0 when the library has proven to be stable.
36
36
 
37
- ```
37
+ ```ruby
38
38
  $ bin/console
39
39
 
40
+ # for running in application or script; not needed from bin/console
41
+ require 'fabric'
40
42
 
41
43
  def load_certs
42
44
  data_dir ='/your/certs/directory' # aka test-network/organizations
43
45
  files = [
44
46
  'peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem',
45
- 'peerOrganizations/org1.example.com/users/Admin\@org1.example.com/msp/keystore/9f7c67dd4dd6562d258593c0d5011a3bff9121e65e67ff7fd3212919ae400a88_sk',
46
- 'peerOrganizations/org1.example.com/users/Admin\@org1.example.com/msp/signcerts/cert.pem'
47
+ 'peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/9f7c67dd4dd6562d258593c0d5011a3bff9121e65e67ff7fd3212919ae400a88_sk',
48
+ 'peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/cert.pem'
47
49
  ]
48
50
  files.map { |f| File.open(File.join(data_dir, f)).read }
49
51
  end
@@ -63,13 +65,13 @@ default_call_options = {
63
65
  chaincode_events_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(60) }
64
66
  }
65
67
  creds = GRPC::Core::ChannelCredentials.new(load_certs[0])
66
- client=Fabric::Client.new('localhost:7051', creds, default_call_options: default_call_options, **client_opts)
68
+ client=Fabric::Client.new(host: 'localhost:7051', creds: creds, default_call_options: default_call_options, **client_opts)
67
69
 
68
- identity = Fabric::Gateway::Identity.new(
70
+ identity = Fabric::Identity.new(
69
71
  {
70
72
  msp_id: 'Org1MSP',
71
- private_key: Fabric::Gateway.crypto_suite.key_from_pem(load_certs[1]),
72
- pem_certificate: load_certs[2],
73
+ private_key: Fabric.crypto_suite.key_from_pem(load_certs[1]),
74
+ certificate: load_certs[2],
73
75
  }
74
76
  )
75
77
 
@@ -80,15 +82,36 @@ contract = network.new_contract('basic')
80
82
  # Evaluate
81
83
  puts contract.evaluate_transaction('GetAllAssets')
82
84
 
83
- # Submit - Not Yet Implemented!
84
- puts contract.submit_transaction('CreateAsset', 'asset13', 'yellow', '5', 'Tom', '1300')
85
+ # Submit
86
+ puts contract.submit_transaction('CreateAsset', ['asset13', 'yellow', '5', 'Tom', '1300'])
87
+ puts contract.submit_transaction('UpdateAsset', %w[asset999 yellow 5 Tom 5555])
85
88
 
86
- # Endorse - Not Yet Implemented!
89
+ # Chaincode Events - simple (blocking until deadline is reached or connection closed)
90
+ contract.chaincode_events do |event|
91
+ puts event
92
+ end
87
93
 
88
- # Commit Status - Not Yet Implemented!
94
+ # Chaincode Events - advanced
95
+ # chaincode events are blocking and run indefinitely, so this is probably the more typical use case to give
96
+ # more control over the connection
89
97
 
90
- # Chaincode Events - Not Yet Implemented!
98
+ last_processed_block = nil # store this in something persistent
99
+
100
+ op = contract.chaincode_events(start_block: last_processed_block, call_options: { return_op: true }) do |event|
101
+ last_processed_block = event.block_number # update the last_processed_block so we can resume from this point
102
+ puts event
103
+ end
91
104
 
105
+ t = Thread.new do
106
+ call = op.execute
107
+ rescue GRPC::Cancelled => e
108
+ puts 'We cancelled the operation outside of this thread.'
109
+ end
110
+
111
+ sleep 1
112
+ op.status
113
+ op.cancelled?
114
+ op.cancel
92
115
  ```
93
116
 
94
117
  Please refer to the [full reference documentation](https://rubydoc.info/github/EthicalIdentity/fabric-gateway-ruby) for complete usage information.
@@ -133,13 +156,15 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ethica
133
156
  - [x] Setup auto-generation of API docs on rubydoc.info
134
157
  - [x] Abstract connection and calls such that the protos aren't being interacted directly
135
158
  - [x] Implement, Document & Test Evaluate
136
- - [ ] Implement, Document & Test Endorse
137
- - [ ] Implement, Document & Test Submit
138
- - [ ] Implement, Document & Test CommitStatus
139
- - [ ] Implement, Document & Test ChaincodeEvents
140
- - [ ] Implement off-line signing - https://github.com/hyperledger/fabric-gateway/blob/1e4a926ddb98ec8ee969da3fc1500642ab389d01/node/src/contract.ts#L63
159
+ - [x] Implement, Document & Test Endorse
160
+ - [x] Implement, Document & Test Submit
161
+ - [x] Implement, Document & Test CommitStatus
162
+ - [x] Implement, Document & Test ChaincodeEvents
163
+ - [ ] Support Submit Async (currently blocks waiting for the transaction to be committed)
141
164
  - [ ] Consider adding error handling, invalid transaction proposals will result in random GRPC::FailedPrecondition type errors
165
+ - [ ] Consider adding transaction_id information to Fabric::Errors that are raised; would help a lot for debugging.
142
166
  - [ ] Consider adding integration tests against blockchain; might be a ton of stuff to setup
167
+ - [ ] Implement off-line signing - https://github.com/hyperledger/fabric-gateway/blob/1e4a926ddb98ec8ee969da3fc1500642ab389d01/node/src/contract.ts#L63
143
168
  - [ ] Support for offline transaction signing (write scenario test for this) - https://github.com/hyperledger/fabric-gateway/blob/cf78fc11a439ced7dfd2f9b55886c55c73119b25/pkg/client/offlinesign_test.go
144
169
 
145
170
 
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
+ require 'rake/notes/rake_task'
5
6
 
6
7
  RSpec::Core::RakeTask.new(:spec)
7
8
 
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Jonathan Chan']
9
9
  spec.email = ['jonathan.chan@ethicalidentity.com']
10
10
 
11
- spec.summary = 'Hyperledger Fabric Gateway gRPC SDK'
12
- spec.description = 'Hyperledger Fabric Gateway gRPC SDK generated directly from protos found at: https://github.com/hyperledger/fabric-protos.'
11
+ spec.summary = 'Hyperledger Fabric Gateway SDK'
12
+ spec.description = 'Ruby port of the Hyperledger Fabric Gateway SDK'
13
13
  spec.homepage = 'https://github.com/ethicalidentity/fabric-gateway-ruby'
14
14
  spec.license = 'MIT'
15
15
  spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
@@ -32,11 +32,13 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency('grpc', '~> 1.42')
33
33
  spec.add_development_dependency('codecov', '~> 0.6.0')
34
34
  spec.add_development_dependency('factory_bot', '~> 6.2.0')
35
- spec.add_development_dependency('grpc-tools', '~> 1.42')
35
+ spec.add_development_dependency('grpc-tools', '~> 1.46.2')
36
+ spec.add_development_dependency('rake-notes', '~> 0.2.0')
36
37
  spec.add_development_dependency('rubocop', '~> 1.23.0')
37
38
  spec.add_development_dependency('rubocop-rspec', '~> 2.6.0')
38
39
  spec.add_development_dependency('simplecov', '~> 0.21.2')
39
40
  spec.add_development_dependency('timecop', '~> 0.9.4')
41
+ spec.add_development_dependency('yard', '~> 0.9.27')
40
42
  spec.metadata = {
41
43
  'rubygems_mfa_required' => 'true'
42
44
  }
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fabric
4
+ module Accessors
5
+ #
6
+ # Add accessor methods to the given class.
7
+ #
8
+ # Usage: make sure the class has a contract accessor method
9
+ # and then `include Fabric::Accessors::Contract`
10
+ #
11
+ module Contract
12
+ # @!visibility private
13
+ def self.included(base)
14
+ base.send :include, Fabric::Accessors::Network
15
+ end
16
+
17
+ # @!parse include Fabric::Accessors::Network
18
+ # @!parse include Fabric::Accessors::Gateway
19
+
20
+ #
21
+ # Returns the network instance
22
+ #
23
+ # @return [Fabric::Network] network
24
+ # @!parse attr_reader :network
25
+ #
26
+ def network
27
+ contract.network
28
+ end
29
+
30
+ #
31
+ # Returns the contract name
32
+ #
33
+ # @return [String] contract name
34
+ # @!parse attr_reader :contract_name
35
+ #
36
+ def contract_name
37
+ contract.contract_name
38
+ end
39
+
40
+ #
41
+ # Returns the chaincode name
42
+ #
43
+ # @return [String] chaincode name
44
+ # @!parse attr_reader :chaincode_name
45
+ #
46
+ def chaincode_name
47
+ contract.chaincode_name
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fabric
4
+ module Accessors
5
+ #
6
+ # Add accessor methods to the given class.
7
+ #
8
+ # Usage: make sure the class has a gateway accessor method
9
+ # and then `include Fabric::Accessors::Gateway`
10
+ #
11
+ module Gateway
12
+ #
13
+ # Returns the client instance
14
+ #
15
+ # @return [Fabric::Client] client
16
+ # @!parse attr_reader :client
17
+ #
18
+ def client
19
+ gateway.client
20
+ end
21
+
22
+ #
23
+ # Returns the signer identity instance
24
+ #
25
+ # @return [Fabric::Identity] signer
26
+ # @!parse attr_reader :signer
27
+ #
28
+ def signer
29
+ gateway.signer
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fabric
4
+ module Accessors
5
+ #
6
+ # Add accessor methods to the given class.
7
+ #
8
+ # Usage: make sure the class has a network accessor method
9
+ # and then `include Fabric::Accessors::Network`
10
+ #
11
+ module Network
12
+ # @!visibility private
13
+ def self.included(base)
14
+ base.send :include, Fabric::Accessors::Gateway
15
+ end
16
+
17
+ # @!parse include Fabric::Accessors::Gateway
18
+
19
+ #
20
+ # Returns the gateway instance
21
+ #
22
+ # @return [Fabric::Gateway] gateway
23
+ # @!parse attr_reader :gateway
24
+ #
25
+ def gateway
26
+ network.gateway
27
+ end
28
+
29
+ #
30
+ # Network name or the channel name or channel id
31
+ #
32
+ # @return [String] network name
33
+ # @!parse attr_reader :network_name
34
+ #
35
+ def network_name
36
+ network.name
37
+ end
38
+ end
39
+ end
40
+ end
data/lib/fabric/client.rb CHANGED
@@ -10,22 +10,34 @@ module Fabric
10
10
  #
11
11
  # Initializes a client
12
12
  #
13
- # @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:initialize
14
- #
15
- # @param [Gateway::Gateway::Stub] grpc_client grpc gateway client stub
16
- # @param [string] host hostname and port of the gateway
17
- # @param [GRPC::Core::ChannelCredentials|GRPC::Core::XdsChannelCredentials|Symbol] creds channel credentials
18
- # (usually the CA certificate)
19
- # @param [Hash] default_call_options call options to use by default for different operations
20
- # @option default_call_options [Hash] :endorse_options default options for endorse call; @see keyword arguments in https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response
21
- # @option default_call_options [Hash] :evaluate_options default options for evaluate call; @see keyword arguments in
22
- # https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response
23
- # @option default_call_options [Hash] :submit_options default options for submit call; @see keyword arguments in https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response
24
- # @option default_call_options [Hash] :commit_status_options default options for commit_status call;
25
- # @see keyword arguments in https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response
26
- # @option default_call_options [Hash] :chaincode_events_options default options for chaincode_events call;
27
- # @see keyword arguments in https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response
28
- # @param [Hash] **client_opts client initialization options; @see keyword arguments at https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:initialize
13
+ #
14
+ # @overload initialize(grpc_client: client, default_call_options: {}, **client_opts)
15
+ # Initializes a client from a gRPC Gateway client stub
16
+ # @param [Gateway::Gateway::Stub] grpc_client grpc gateway client stub
17
+ # @param [Hash] default_call_options call options to use by default for different operations
18
+ # @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response Keyword Argument call options for
19
+ # *_options default_call_options
20
+ # @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:initialize Keyword arguments for **client_opts
21
+ # @option default_call_options [Hash] :endorse_options default options for endorse call
22
+ # @option default_call_options [Hash] :evaluate_options default options for evaluate call
23
+ # @option default_call_options [Hash] :submit_options default options for submit call
24
+ # @option default_call_options [Hash] :commit_status_options default options for commit_status call
25
+ # @option default_call_options [Hash] :chaincode_events_options default options for chaincode_events call
26
+ # @param [Hash] **client_opts client initialization options
27
+ # @overload initialize(host: host, creds: creds, default_call_options: {}, **client_opts)
28
+ # Instantiates a new gRPC Gateway client stub from the parameters
29
+ # @param [string] host hostname and port of the gateway
30
+ # @param [GRPC::Core::ChannelCredentials|GRPC::Core::XdsChannelCredentials|Symbol] creds channel credentials
31
+ # (usually the CA certificate)
32
+ # @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response Keyword Argument call options for
33
+ # *_options default_call_options
34
+ # @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:initialize Keyword arguments for **client_opts
35
+ # @option default_call_options [Hash] :endorse_options default options for endorse call
36
+ # @option default_call_options [Hash] :evaluate_options default options for evaluate call
37
+ # @option default_call_options [Hash] :submit_options default options for submit call
38
+ # @option default_call_options [Hash] :commit_status_options default options for commit_status call
39
+ # @option default_call_options [Hash] :chaincode_events_options default options for chaincode_events call
40
+ # @param [Hash] **client_opts client initialization options
29
41
  #
30
42
  def initialize(grpc_client: nil, host: nil, creds: nil, default_call_options: {}, **client_opts)
31
43
  if grpc_client
@@ -41,8 +53,9 @@ module Fabric
41
53
  #
42
54
  # Submits an evaluate_request to the gateway to be evaluted.
43
55
  #
56
+ # @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response Call options for options parameter
44
57
  # @param [Gateway::EvaluateRequest] evaluate_request
45
- # @param [Hash] options gRPC call options (merged with default options) @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response
58
+ # @param [Hash] options gRPC call options (merged with default_call_options from initializer)
46
59
  #
47
60
  # @return [Gateway::EvaluateResponse] evaluate_response
48
61
  #
@@ -80,6 +93,7 @@ module Fabric
80
93
  # @param [Gateway::CommitStatusRequest] commit_status_request
81
94
  # @param [Hash] options gRPC call options (merged with default options) @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:request_response
82
95
  #
96
+ # Returns an enum or if you pass a block, use the block.
83
97
  # @return [Gateway::CommitStatusResponse] commit_status_response
84
98
  #
85
99
  def commit_status(commit_status_request, options = {})
@@ -89,13 +103,64 @@ module Fabric
89
103
  #
90
104
  # Subscribe to chaincode events
91
105
  #
92
- # @NOTE: This function has never been utilized or tested. This function is probably wrong, missing a block.
93
- # @TODO: add testing!
94
- #
95
- # @param [Gateway::ChaincodeEventsRequest] chaincode_events_request
96
- # @param [Hash] options gRPC call options (merged with default options) @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:server_streamer
97
- #
98
- # @return [Gateway::ChaincodeEventsResponse] commit_status_response (probably wrong, this is a stream.)
106
+ # @see https://www.rubydoc.info/gems/grpc/GRPC%2FClientStub:server_streamer GRPC::ClientStub#server_streamer
107
+ # - gRPC Underlying Call Reference
108
+ #
109
+ #
110
+ # @overload chaincode_events(chaincode_events_request)
111
+ # @example Utilizing Blocking Enumerator
112
+ # call = client.chaincode_events(chaincode_events_request)
113
+ # call.each do |event|
114
+ # pp event
115
+ # end
116
+ # @param [Gateway::ChaincodeEventsRequest] chaincode_events_request
117
+ # @param [Hash] options gRPC call options (merged with default options)
118
+ # @return [Enumerator] enumerator with Gateway::ChaincodeEventsResponse objects
119
+ # @overload chaincode_events(chaincode_events_request)
120
+ # @example Utilizing a blocking block
121
+ # client.chaincode_events(chaincode_events_request) do |event|
122
+ # pp event
123
+ # end
124
+ # @param [Gateway::ChaincodeEventsRequest] chaincode_events_request
125
+ # @param [Hash] options gRPC call options (merged with default options)
126
+ # @yield [event] Blocking call that yields Gateway::ChaincodeEventsResponse objects when received from the server
127
+ # @yieldparam event [Gateway::ChaincodeEventsResponse] chaincode event
128
+ # @return [nil]
129
+ # @overload chaincode_events(chaincode_events_request, {return_op: true})
130
+ # @example Utilizing an operation control object and a enumerator
131
+ # op = client.chaincode_events(chaincode_events_request, {return_op: true})
132
+ #
133
+ # t = Thread.new do
134
+ # call = op.execute
135
+ # call.each do |event|
136
+ # pp event
137
+ # end
138
+ # end
139
+ #
140
+ # op.status
141
+ # op.cancelled?
142
+ # op.cancel
143
+ # @param [Gateway::ChaincodeEventsRequest] chaincode_events_request
144
+ # @param [Hash] options gRPC call options (merged with default options)
145
+ # @return [GRPC::ActiveCall::Operation]
146
+ # @overload chaincode_events(chaincode_events_request, {return_op: true})
147
+ # @example Utilizing an operation control object and a block
148
+ # op = client.chaincode_events(chaincode_events_request, {return_op: true}) do |event|
149
+ # pp event
150
+ # end
151
+ #
152
+ # t = Thread.new do
153
+ # call = op.execute
154
+ # end
155
+ #
156
+ # op.status
157
+ # op.cancelled?
158
+ # op.cancel
159
+ # @param [Gateway::ChaincodeEventsRequest] chaincode_events_request
160
+ # @param [Hash] options gRPC call options (merged with default options)
161
+ # @yield [event] Blocking call that yields Gateway::ChaincodeEventsResponse objects when received from the server
162
+ # @yieldparam event [Gateway::ChaincodeEventsResponse] chaincode event
163
+ # @return [GRPC::ActiveCall::Operation]
99
164
  #
100
165
  def chaincode_events(chaincode_events_request, options = {}, &block)
101
166
  @grpc_client.chaincode_events(chaincode_events_request,