fabric-gateway 0.0.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +3 -0
  3. data/.github/workflows/rspec.yml +37 -0
  4. data/.github/workflows/rubocop.yml +28 -0
  5. data/.gitignore +1 -0
  6. data/.rubocop.yml +23 -0
  7. data/.ruby-version +1 -0
  8. data/.vscode/settings.json +7 -0
  9. data/.yardopts +2 -0
  10. data/CODE_OF_CONDUCT.md +105 -46
  11. data/Gemfile +5 -3
  12. data/LICENSE.txt +1 -1
  13. data/README.md +105 -7
  14. data/Rakefile +7 -3
  15. data/bin/console +4 -3
  16. data/bin/regenerate +19 -0
  17. data/bin/release +5 -0
  18. data/fabric-gateway.gemspec +32 -17
  19. data/lib/common/common_pb.rb +113 -0
  20. data/lib/common/policies_pb.rb +61 -0
  21. data/lib/fabric/accessors/contract.rb +51 -0
  22. data/lib/fabric/accessors/gateway.rb +33 -0
  23. data/lib/fabric/accessors/network.rb +40 -0
  24. data/lib/fabric/client.rb +146 -0
  25. data/lib/fabric/constants.rb +8 -0
  26. data/lib/fabric/contract.rb +154 -0
  27. data/lib/fabric/ec_crypto_suite.rb +199 -0
  28. data/lib/fabric/entities/envelope.rb +153 -0
  29. data/lib/fabric/entities/identity.rb +87 -0
  30. data/lib/fabric/entities/proposal.rb +189 -0
  31. data/lib/fabric/entities/proposed_transaction.rb +163 -0
  32. data/lib/fabric/entities/status.rb +32 -0
  33. data/lib/fabric/entities/transaction.rb +247 -0
  34. data/lib/fabric/gateway.rb +31 -6
  35. data/lib/fabric/network.rb +56 -0
  36. data/lib/fabric/version.rb +5 -0
  37. data/lib/fabric.rb +57 -0
  38. data/lib/gossip/message_pb.rb +236 -0
  39. data/lib/gossip/message_services_pb.rb +31 -0
  40. data/lib/msp/identities_pb.rb +25 -0
  41. data/lib/msp/msp_principal_pb.rb +57 -0
  42. data/lib/orderer/ab_pb.rb +64 -0
  43. data/lib/orderer/ab_services_pb.rb +30 -0
  44. data/lib/peer/chaincode_event_pb.rb +19 -0
  45. data/lib/peer/chaincode_pb.rb +69 -0
  46. data/lib/peer/proposal_pb.rb +41 -0
  47. data/lib/peer/proposal_response_pb.rb +52 -0
  48. data/lib/peer/transaction_pb.rb +74 -0
  49. metadata +184 -10
  50. data/lib/fabric/gateway/version.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0682847b6d6baf8c6c7e42969ea1df4ea1270a71c08ff738e7d50e437dc21f03'
4
- data.tar.gz: 2d810690b719fe2d821c52994f98ee075ca1d2d64f33cfd3ddfc92ca9b3d285c
3
+ metadata.gz: 84dbcb3d572350e328ca48178859e0edfc7f57bbc331980612c4c5f537701b12
4
+ data.tar.gz: 9aaeed65be8ea7b5296e4e4fb12d8027583581cca24c96ccdf4f7a3afb781758
5
5
  SHA512:
6
- metadata.gz: 9af5b6d596e8044386b6cfd02de491c7ef40c16870ea2e70ea93e80402e06df6af87373b14c416644a19e08452509b2251d885da6fa2c35c5ab2c2332d49b900
7
- data.tar.gz: ba1cec9dc77522e98bb55bc44eabe9b17bea003abe79f13d2d9b189a572d9bd5b8e09f9459cbac933eedcd864672c99b83bf3011d9bf70887c60df6b50a0771d
6
+ metadata.gz: a931d1e6fff596991560afedd817f3091e0c393c4b6aefa9eed5f3dfee19f37db8b1f744c9ea9b4375d661bdf1c0b4c72402eb9048225be7d028569520fb8d23
7
+ data.tar.gz: 553c329d4dbb5b9b7729e5c1226f2c680901e40e27f630ce1f577fd9f4c33eb648b06a8ab92630873c8ded4be7ba4870b82fbef236a0520d848371b09d5de848
data/.editorconfig ADDED
@@ -0,0 +1,3 @@
1
+ indent_style = space
2
+ indent_size = 2
3
+ root = true
@@ -0,0 +1,37 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: RSpec Tests
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.6', '2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ # uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run tests
35
+ run: bundle exec rake
36
+ env:
37
+ CODECOV_TOKEN: 4b75ccca-3149-4610-99fb-3a5aeff4ff00
@@ -0,0 +1,28 @@
1
+ name: RuboCop
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 }}-rubocop-${{ hashFiles('**/Gemfile.lock') }}
20
+ restore-keys: |
21
+ ${{ runner.os }}-rubocop-
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 RuboCop
28
+ run: bundle exec rubocop --parallel
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ Gemfile.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,23 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ Metrics/BlockLength:
5
+ Exclude:
6
+ - '*.gemspec'
7
+ - 'spec/**/*_spec.rb'
8
+ - spec/factories.rb
9
+
10
+ AllCops:
11
+ NewCops: enable
12
+ TargetRubyVersion: 2.6
13
+ Exclude:
14
+ - vendor/bundle/**/*
15
+ # exclude protoc generated code
16
+ - 'lib/gateway/*'
17
+ - 'lib/common/*'
18
+ - 'lib/gossip/*'
19
+ - 'lib/msp/*'
20
+ - 'lib/orderer/*'
21
+ - 'lib/peer/*'
22
+
23
+
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.5
@@ -0,0 +1,7 @@
1
+ {
2
+ "[ruby]": {
3
+ "editor.formatOnSave": true,
4
+ "editor.defaultFormatter": "misogi.ruby-rubocop"
5
+ },
6
+ "editor.formatOnSave": true
7
+ }
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup-provider=redcarpet
2
+ --markup=markdown
data/CODE_OF_CONDUCT.md CHANGED
@@ -2,73 +2,132 @@
2
2
 
3
3
  ## Our Pledge
4
4
 
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
11
14
 
12
15
  ## Our Standards
13
16
 
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
16
19
 
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
22
27
 
23
- Examples of unacceptable behavior by participants include:
28
+ Examples of unacceptable behavior include:
24
29
 
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
28
33
  * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
31
36
  * Other conduct which could reasonably be considered inappropriate in a
32
37
  professional setting
33
38
 
34
- ## Our Responsibilities
39
+ ## Enforcement Responsibilities
35
40
 
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
39
45
 
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
45
50
 
46
51
  ## Scope
47
52
 
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
54
58
 
55
59
  ## Enforcement
56
60
 
57
61
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at jonathan.chan@ethicalidentity.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
62
+ reported to the community leaders responsible for enforcement at
63
+ oss@ethicalidentity.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
63
87
 
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
67
114
 
68
115
  ## Attribution
69
116
 
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [https://contributor-covenant.org/version/1/4][version]
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
72
133
 
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in fabric-gateway.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
+ gem 'rake', '~> 12.3.3'
9
+ gem 'rspec', '~> 3.0'
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 TODO: Write your name
3
+ Copyright (c) 2021 The Ethical Identity Company
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Fabric::Gateway
2
2
 
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
+
5
+
6
+
3
7
  Hyperledger Fabric Gateway gRPC SDK generated directly from protos found at: https://github.com/hyperledger/fabric-protos.
4
8
 
5
9
  ## Installation
@@ -18,9 +22,75 @@ Or install it yourself as:
18
22
 
19
23
  $ gem install fabric-gateway
20
24
 
25
+ ### ISSUES
26
+
27
+ Note, there is an issue with the grpc library for MacOS (https://github.com/grpc/grpc/issues/28271). It results in a segfault in ruby when trying to make a connection.
28
+
29
+ Workaround: Either run on linux or use a docker container as a workaround.
30
+
31
+ Will update to new version of grpc when fix is released.
32
+
21
33
  ## Usage
22
34
 
23
- This is a pre-alpha library. None of the code has been tested or confirmed working yet.
35
+ This is an alpha stage library suitable for early adopters. The basic evaluate and submit gateway functions are implemented. Chaincode events monitoring is not yet implemented.
36
+
37
+ ```ruby
38
+ $ bin/console
39
+
40
+ # for running in application or script; not needed from bin/console
41
+ require 'fabric'
42
+
43
+ def load_certs
44
+ data_dir ='/your/certs/directory' # aka test-network/organizations
45
+ files = [
46
+ 'peerOrganizations/org1.example.com/ca/ca.org1.example.com-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'
49
+ ]
50
+ files.map { |f| File.open(File.join(data_dir, f)).read }
51
+ end
52
+
53
+ # needed if you are connecting via a different dns name or IP address
54
+ client_opts = {
55
+ channel_args: {
56
+ GRPC::Core::Channel::SSL_TARGET => 'peer0.org1.example.com'
57
+ }
58
+ }
59
+ # optional, if you want to set deadlines to the individual calls (in seconds)
60
+ default_call_options = {
61
+ endorse_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(5) },
62
+ evaluate_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(5) },
63
+ submit_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(5) },
64
+ commit_status_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(5) },
65
+ chaincode_events_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(60) }
66
+ }
67
+ creds = GRPC::Core::ChannelCredentials.new(load_certs[0])
68
+ client=Fabric::Client.new('localhost:7051', creds, default_call_options: default_call_options, **client_opts)
69
+
70
+ identity = Fabric::Gateway::Identity.new(
71
+ {
72
+ msp_id: 'Org1MSP',
73
+ private_key: Fabric::Gateway.crypto_suite.key_from_pem(load_certs[1]),
74
+ pem_certificate: load_certs[2],
75
+ }
76
+ )
77
+
78
+ gateway = identity.new_gateway(client)
79
+ network = gateway.new_network('my_channel')
80
+ contract = network.new_contract('basic')
81
+
82
+ # Evaluate
83
+ puts contract.evaluate_transaction('GetAllAssets')
84
+
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])
88
+
89
+ # Chaincode Events - Not Yet Implemented!
90
+
91
+ ```
92
+
93
+ Please refer to the [full reference documentation](https://rubydoc.info/github/EthicalIdentity/fabric-gateway-ruby) for complete usage information.
24
94
 
25
95
  ## Development
26
96
 
@@ -28,13 +98,23 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
28
98
 
29
99
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
100
 
31
- To rebuild the proto code:
101
+ To rebuild the proto code, run the regenerate script:
32
102
 
33
103
  ```
34
- $ git submodule update --init --recursive
35
- $ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/gateway/gateway.proto
104
+ $ bin/regenerate
36
105
  ```
37
106
 
107
+ Effort has been made to follow the design patterns and naming convention where possible from the official [Hyperledger Fabric Gateway SDK](https://github.com/hyperledger/fabric-gateway) while at the same time producing an idiomatic ruby gem. Our intention is to produce a gem that would be compatible with the documentation of the official SDK while natural to use for a seasoned ruby developer.
108
+
109
+ ## Development References & Resources
110
+
111
+ These are the libraries and knowledge necessary for developing this gem:
112
+
113
+ * gRPC - [gRPC Intro](https://grpc.io/docs/what-is-grpc/introduction/) / [gRPC on ruby](https://grpc.io/docs/languages/ruby/)
114
+ * Protocol Buffers (Protobuf) - [overview](https://developers.google.com/protocol-buffers/docs/proto3) / [ruby reference](https://developers.google.com/protocol-buffers/docs/reference/ruby-generated)
115
+ * [Hyperledger Fabric Protocol Specifications](https://openblockchain.readthedocs.io/en/latest/protocol-spec/)
116
+ * [Hyperledger Fabric Gateway Overview](https://hyperledger-fabric.readthedocs.io/en/latest/gateway.html) / [Fabric Gateway RFC](https://hyperledger.github.io/fabric-rfcs/text/0000-fabric-gateway.html)
117
+
38
118
  ## Contributing
39
119
 
40
120
  Bug reports and pull requests are welcome on GitHub at https://github.com/ethicalidentity/fabric-gateway. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ethicalidentity/fabric-gateway/blob/master/CODE_OF_CONDUCT.md).
@@ -45,15 +125,33 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ethica
45
125
 
46
126
  - [x] Add license
47
127
  - [x] Add ChangeLog
48
- - [ ] Create Gem
49
- - [ ] Add usage instructions
50
- - [ ] Add testing?
128
+ - [x] Create Gem
129
+ - [x] Add testing & CI/CD
130
+ - [x] Add rubocop and linting
131
+ - [x] Add usage instructions
132
+ - [x] Setup auto-generation of API docs on rubydoc.info
133
+ - [x] Abstract connection and calls such that the protos aren't being interacted directly
134
+ - [x] Implement, Document & Test Evaluate
135
+ - [x] Implement, Document & Test Endorse
136
+ - [x] Implement, Document & Test Submit
137
+ - [x] Implement, Document & Test CommitStatus
138
+ - [ ] Implement, Document & Test ChaincodeEvents
139
+ - [ ] Support Submit Async (currently blocks waiting for the transaction to be committed)
140
+ - [ ] Consider adding error handling, invalid transaction proposals will result in random GRPC::FailedPrecondition type errors
141
+ - [ ] Consider adding transaction_id information to Fabric::Errors that are raised; would help a lot for debugging.
142
+ - [ ] Consider adding integration tests against blockchain; might be a ton of stuff to setup
143
+ - [ ] Implement off-line signing - https://github.com/hyperledger/fabric-gateway/blob/1e4a926ddb98ec8ee969da3fc1500642ab389d01/node/src/contract.ts#L63
144
+ - [ ] Support for offline transaction signing (write scenario test for this) - https://github.com/hyperledger/fabric-gateway/blob/cf78fc11a439ced7dfd2f9b55886c55c73119b25/pkg/client/offlinesign_test.go
145
+
146
+
51
147
 
52
148
 
53
149
  ## License
54
150
 
55
151
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
56
152
 
153
+ Portions of the code are from https://github.com/kirshin/hyperledger-fabric-sdk.
154
+
57
155
  ## Code of Conduct
58
156
 
59
157
  Everyone interacting in the Fabric::Gateway project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ethicalidentity/fabric-gateway/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rake/notes/rake_task'
3
6
 
4
7
  RSpec::Core::RakeTask.new(:spec)
5
8
 
6
- task :default => :spec
9
+ task default: :spec
10
+
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "fabric/gateway"
4
+ require 'bundler/setup'
5
+ require 'fabric'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "fabric/gateway"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/bin/regenerate ADDED
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+
3
+ if ! which grpc_tools_ruby_protoc > /dev/null; then
4
+ echo "grpc_tools_ruby_protoc missing, installing from ruby-gems..."
5
+ gem install grpc-tools
6
+ fi
7
+
8
+ git submodule update --init --recursive
9
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/gateway/gateway.proto
10
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/peer/chaincode.proto
11
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/peer/chaincode_event.proto
12
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/peer/proposal_response.proto
13
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/peer/proposal.proto
14
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/peer/transaction.proto
15
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/common/common.proto
16
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/orderer/ab.proto
17
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/gossip/message.proto
18
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/msp/msp_principal.proto
19
+ grpc_tools_ruby_protoc -I ./fabric-protos --ruby_out=./lib --grpc_out=./lib ./fabric-protos/msp/identities.proto
data/bin/release ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ # Requires gem install gem-release
4
+ # usage: bin/relase -v minor|major|etc.
5
+ gem bump --file lib/fabric/version.rb -t -r $@
@@ -1,29 +1,44 @@
1
- require_relative 'lib/fabric/gateway/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/fabric/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
4
- spec.name = "fabric-gateway"
5
- spec.version = Fabric::Gateway::VERSION
6
- spec.authors = ["Jonathan Chan"]
7
- spec.email = ["jonathan.chan@ethicalidentity.com"]
6
+ spec.name = 'fabric-gateway'
7
+ spec.version = Fabric::VERSION
8
+ spec.authors = ['Jonathan Chan']
9
+ spec.email = ['jonathan.chan@ethicalidentity.com']
8
10
 
9
- spec.summary = %q{Hyperledger Fabric Gateway gRPC SDK}
10
- spec.description = %q{Hyperledger Fabric Gateway gRPC SDK generated directly from protos found at: https://github.com/hyperledger/fabric-protos.}
11
- spec.homepage = "https://github.com/ethicalidentity/fabric-gateway-ruby"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
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.'
13
+ spec.homepage = 'https://github.com/ethicalidentity/fabric-gateway-ruby'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
14
16
 
15
- spec.metadata["allowed_push_host"] = 'https://rubygems.org'
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
16
18
 
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/ethicalidentity/fabric-gateway-ruby"
19
- spec.metadata["changelog_uri"] = "https://github.com/EthicalIdentity/fabric-gateway-ruby/blob/master/CHANGELOG.md"
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/ethicalidentity/fabric-gateway-ruby'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/EthicalIdentity/fabric-gateway-ruby/blob/master/CHANGELOG.md'
20
22
 
21
23
  # Specify which files should be added to the gem when it is released.
22
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
26
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
27
  end
26
- spec.bindir = "exe"
28
+ spec.bindir = 'exe'
27
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
30
+ spec.require_paths = ['lib']
31
+ spec.add_dependency('google-protobuf', '>= 3.19.1')
32
+ spec.add_dependency('grpc', '~> 1.42')
33
+ spec.add_development_dependency('codecov', '~> 0.6.0')
34
+ spec.add_development_dependency('factory_bot', '~> 6.2.0')
35
+ spec.add_development_dependency('grpc-tools', '~> 1.42')
36
+ spec.add_development_dependency('rake-notes', '~> 0.2.0')
37
+ spec.add_development_dependency('rubocop', '~> 1.23.0')
38
+ spec.add_development_dependency('rubocop-rspec', '~> 2.6.0')
39
+ spec.add_development_dependency('simplecov', '~> 0.21.2')
40
+ spec.add_development_dependency('timecop', '~> 0.9.4')
41
+ spec.metadata = {
42
+ 'rubygems_mfa_required' => 'true'
43
+ }
29
44
  end