fabric-gateway 0.0.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +3 -0
- data/.github/workflows/rspec.yml +37 -0
- data/.github/workflows/rubocop.yml +28 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +23 -0
- data/.ruby-version +1 -0
- data/.vscode/settings.json +7 -0
- data/.yardopts +2 -0
- data/CODE_OF_CONDUCT.md +105 -46
- data/Gemfile +5 -3
- data/LICENSE.txt +1 -1
- data/README.md +105 -7
- data/Rakefile +7 -3
- data/bin/console +4 -3
- data/bin/regenerate +19 -0
- data/bin/release +5 -0
- data/fabric-gateway.gemspec +32 -17
- data/lib/common/common_pb.rb +113 -0
- data/lib/common/policies_pb.rb +61 -0
- data/lib/fabric/accessors/contract.rb +51 -0
- data/lib/fabric/accessors/gateway.rb +33 -0
- data/lib/fabric/accessors/network.rb +40 -0
- data/lib/fabric/client.rb +146 -0
- data/lib/fabric/constants.rb +8 -0
- data/lib/fabric/contract.rb +154 -0
- data/lib/fabric/ec_crypto_suite.rb +199 -0
- data/lib/fabric/entities/envelope.rb +153 -0
- data/lib/fabric/entities/identity.rb +87 -0
- data/lib/fabric/entities/proposal.rb +189 -0
- data/lib/fabric/entities/proposed_transaction.rb +163 -0
- data/lib/fabric/entities/status.rb +32 -0
- data/lib/fabric/entities/transaction.rb +247 -0
- data/lib/fabric/gateway.rb +31 -6
- data/lib/fabric/network.rb +56 -0
- data/lib/fabric/version.rb +5 -0
- data/lib/fabric.rb +57 -0
- data/lib/gossip/message_pb.rb +236 -0
- data/lib/gossip/message_services_pb.rb +31 -0
- data/lib/msp/identities_pb.rb +25 -0
- data/lib/msp/msp_principal_pb.rb +57 -0
- data/lib/orderer/ab_pb.rb +64 -0
- data/lib/orderer/ab_services_pb.rb +30 -0
- data/lib/peer/chaincode_event_pb.rb +19 -0
- data/lib/peer/chaincode_pb.rb +69 -0
- data/lib/peer/proposal_pb.rb +41 -0
- data/lib/peer/proposal_response_pb.rb +52 -0
- data/lib/peer/transaction_pb.rb +74 -0
- metadata +184 -10
- data/lib/fabric/gateway/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84dbcb3d572350e328ca48178859e0edfc7f57bbc331980612c4c5f537701b12
|
4
|
+
data.tar.gz: 9aaeed65be8ea7b5296e4e4fb12d8027583581cca24c96ccdf4f7a3afb781758
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a931d1e6fff596991560afedd817f3091e0c393c4b6aefa9eed5f3dfee19f37db8b1f744c9ea9b4375d661bdf1c0b4c72402eb9048225be7d028569520fb8d23
|
7
|
+
data.tar.gz: 553c329d4dbb5b9b7729e5c1226f2c680901e40e27f630ce1f577fd9f4c33eb648b06a8ab92630873c8ded4be7ba4870b82fbef236a0520d848371b09d5de848
|
data/.editorconfig
ADDED
@@ -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
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
|
data/.yardopts
ADDED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -2,73 +2,132 @@
|
|
2
2
|
|
3
3
|
## Our Pledge
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
nationality, personal appearance, race, religion, or sexual
|
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
|
15
|
-
include:
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
16
19
|
|
17
|
-
*
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
*
|
20
|
-
*
|
21
|
-
|
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
|
28
|
+
Examples of unacceptable behavior include:
|
24
29
|
|
25
|
-
* The use of sexualized language or imagery and
|
26
|
-
|
27
|
-
* Trolling, insulting
|
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
|
30
|
-
|
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
|
-
##
|
39
|
+
## Enforcement Responsibilities
|
35
40
|
|
36
|
-
|
37
|
-
behavior and
|
38
|
-
response to any
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
representative at an online or offline event.
|
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
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
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],
|
71
|
-
available at
|
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
|
-
|
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
|
7
|
-
gem
|
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
|
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
|
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
|
-
$
|
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
|
-
- [
|
49
|
-
- [
|
50
|
-
- [
|
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
|
-
|
2
|
-
|
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 :
|
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
|
4
|
-
require
|
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
|
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
data/fabric-gateway.gemspec
CHANGED
@@ -1,29 +1,44 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/fabric/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name =
|
5
|
-
spec.version = Fabric::
|
6
|
-
spec.authors = [
|
7
|
-
spec.email = [
|
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 =
|
10
|
-
spec.description =
|
11
|
-
spec.homepage =
|
12
|
-
spec.license =
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
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[
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
16
18
|
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
19
|
-
spec.metadata[
|
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
|
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 =
|
28
|
+
spec.bindir = 'exe'
|
27
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = [
|
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
|