hive-ruby 1.0.0.pre.1
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.
- checksums.yaml +7 -0
- data/.gitignore +54 -0
- data/CONTRIBUTING.md +79 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +91 -0
- data/LICENSE +21 -0
- data/README.md +248 -0
- data/Rakefile +358 -0
- data/gource.sh +6 -0
- data/hive-ruby.gemspec +40 -0
- data/images/Anthony Martin.png +0 -0
- data/lib/hive.rb +89 -0
- data/lib/hive/api.rb +223 -0
- data/lib/hive/base_error.rb +218 -0
- data/lib/hive/block_api.rb +78 -0
- data/lib/hive/bridge.rb +12 -0
- data/lib/hive/broadcast.rb +1334 -0
- data/lib/hive/chain_config.rb +34 -0
- data/lib/hive/fallback.rb +287 -0
- data/lib/hive/formatter.rb +14 -0
- data/lib/hive/jsonrpc.rb +112 -0
- data/lib/hive/marshal.rb +231 -0
- data/lib/hive/mixins/jsonable.rb +37 -0
- data/lib/hive/mixins/retriable.rb +58 -0
- data/lib/hive/mixins/serializable.rb +45 -0
- data/lib/hive/operation.rb +141 -0
- data/lib/hive/operation/account_create.rb +10 -0
- data/lib/hive/operation/account_create_with_delegation.rb +12 -0
- data/lib/hive/operation/account_update.rb +8 -0
- data/lib/hive/operation/account_witness_proxy.rb +4 -0
- data/lib/hive/operation/account_witness_vote.rb +5 -0
- data/lib/hive/operation/cancel_transfer_from_savings.rb +4 -0
- data/lib/hive/operation/challenge_authority.rb +5 -0
- data/lib/hive/operation/change_recovery_account.rb +5 -0
- data/lib/hive/operation/claim_account.rb +5 -0
- data/lib/hive/operation/claim_reward_balance.rb +6 -0
- data/lib/hive/operation/comment.rb +9 -0
- data/lib/hive/operation/comment_options.rb +10 -0
- data/lib/hive/operation/convert.rb +5 -0
- data/lib/hive/operation/create_claimed_account.rb +10 -0
- data/lib/hive/operation/custom.rb +5 -0
- data/lib/hive/operation/custom_binary.rb +8 -0
- data/lib/hive/operation/custom_json.rb +6 -0
- data/lib/hive/operation/decline_voting_rights.rb +4 -0
- data/lib/hive/operation/delegate_vesting_shares.rb +5 -0
- data/lib/hive/operation/delete_comment.rb +4 -0
- data/lib/hive/operation/escrow_approve.rb +8 -0
- data/lib/hive/operation/escrow_dispute.rb +7 -0
- data/lib/hive/operation/escrow_release.rb +10 -0
- data/lib/hive/operation/escrow_transfer.rb +12 -0
- data/lib/hive/operation/feed_publish.rb +4 -0
- data/lib/hive/operation/limit_order_cancel.rb +4 -0
- data/lib/hive/operation/limit_order_create.rb +8 -0
- data/lib/hive/operation/limit_order_create2.rb +8 -0
- data/lib/hive/operation/prove_authority.rb +4 -0
- data/lib/hive/operation/recover_account.rb +6 -0
- data/lib/hive/operation/report_over_production.rb +5 -0
- data/lib/hive/operation/request_account_recovery.rb +6 -0
- data/lib/hive/operation/reset_account.rb +5 -0
- data/lib/hive/operation/set_reset_account.rb +5 -0
- data/lib/hive/operation/set_withdraw_vesting_route.rb +6 -0
- data/lib/hive/operation/transfer.rb +6 -0
- data/lib/hive/operation/transfer_from_savings.rb +7 -0
- data/lib/hive/operation/transfer_to_savings.rb +6 -0
- data/lib/hive/operation/transfer_to_vesting.rb +5 -0
- data/lib/hive/operation/vote.rb +6 -0
- data/lib/hive/operation/withdraw_vesting.rb +4 -0
- data/lib/hive/operation/witness_set_properties.rb +5 -0
- data/lib/hive/operation/witness_update.rb +7 -0
- data/lib/hive/rpc/base_client.rb +179 -0
- data/lib/hive/rpc/http_client.rb +143 -0
- data/lib/hive/rpc/thread_safe_http_client.rb +35 -0
- data/lib/hive/stream.rb +385 -0
- data/lib/hive/transaction.rb +115 -0
- data/lib/hive/transaction_builder.rb +406 -0
- data/lib/hive/type/amount.rb +126 -0
- data/lib/hive/type/base_type.rb +10 -0
- data/lib/hive/utils.rb +17 -0
- data/lib/hive/version.rb +4 -0
- metadata +502 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f12eb926857666814b1ddd99302952102c91299bba3d2efc9ffb75888f72c520
|
4
|
+
data.tar.gz: e1103584e3aec71e89f336c3a044d54ad8f3f8bd0056fdf6d1cf694ce3c4f816
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 16e20294bf841fa651c9a236c499f659dbf10b136876e31acead394e4362f68583fcb846a86cd19cfdd7505c46dda22d13c05f008f290e1b92c4b7b36b2589dc
|
7
|
+
data.tar.gz: 4c3104a416ce1010e6e4543bb9830aad3a884e7af34d8083d59f8b57d4043cdb3454a37eefe3927aeee516f9eda9c12109495deb7ec0252fd5d454d50b9d7222
|
data/.gitignore
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/fixtures/vcr_cassettes/*.yml
|
11
|
+
/test/version_tmp/
|
12
|
+
/tmp/
|
13
|
+
|
14
|
+
# Used by dotenv library to load environment variables.
|
15
|
+
# .env
|
16
|
+
|
17
|
+
## Specific to RubyMotion:
|
18
|
+
.dat*
|
19
|
+
.repl_history
|
20
|
+
build/
|
21
|
+
*.bridgesupport
|
22
|
+
build-iPhoneOS/
|
23
|
+
build-iPhoneSimulator/
|
24
|
+
|
25
|
+
## Specific to RubyMotion (use of CocoaPods):
|
26
|
+
#
|
27
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
28
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
29
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
30
|
+
#
|
31
|
+
# vendor/Pods/
|
32
|
+
|
33
|
+
## Documentation cache and generated files:
|
34
|
+
/.yardoc/
|
35
|
+
/_yardoc/
|
36
|
+
/doc/
|
37
|
+
/rdoc/
|
38
|
+
|
39
|
+
## Environment normalization:
|
40
|
+
/.bundle/
|
41
|
+
/vendor/bundle
|
42
|
+
/lib/bundler/man/
|
43
|
+
|
44
|
+
# for a library or gem, you might want to ignore these files since the code is
|
45
|
+
# intended to run in multiple environments; otherwise, check them in:
|
46
|
+
# Gemfile.lock
|
47
|
+
# .ruby-version
|
48
|
+
# .ruby-gemset
|
49
|
+
|
50
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
51
|
+
.rvmrc
|
52
|
+
|
53
|
+
# gource output
|
54
|
+
output.mp4
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
|
2
|
+
# Contributing
|
3
|
+
|
4
|
+
Everyone is welcome to contribute code to Galactica Actual projects. We have a Code of Conduct;
|
5
|
+
we ask that you please follow it in all your interactions with our team and your fellow
|
6
|
+
contributors.
|
7
|
+
|
8
|
+
Please note that this contributing guide only applies to our development presence.
|
9
|
+
|
10
|
+
## How to contribute
|
11
|
+
|
12
|
+
1. File an issue describing the problem you would like to
|
13
|
+
solve or the feature you would like to add. It saves unnecessary work on your part,
|
14
|
+
in case there's a nontechnical reason we can't accept a particular change.
|
15
|
+
Please note that we can and will _automatically close all pull requests that do not refer to
|
16
|
+
an issue_.
|
17
|
+
2. Learn the conventions of the project you are submitting code to, even implicit ones,
|
18
|
+
and follow them. In case you have a question about a project's conventions, please
|
19
|
+
ask on the issue you filed. This includes writing tests, formatting code, and documentation.
|
20
|
+
3. File a pull request against your Github issue and fill out the pull request template.
|
21
|
+
Remember, you are agreeing to license your code and any intellectual property associated
|
22
|
+
with your code under the same terms as the repository you are contributing to.
|
23
|
+
4. If one of our teammates asks you to make changes, please make them. Our rule is that all
|
24
|
+
requests for changes in code review are resolved in favor of the reviewer. Our teammates
|
25
|
+
follow this rule too!
|
26
|
+
|
27
|
+
## Code of Conduct
|
28
|
+
|
29
|
+
Again, please note that this Code of Conduct _only applies to our development presence_.
|
30
|
+
|
31
|
+
### Our Pledge
|
32
|
+
|
33
|
+
We welcome your membership in our project and community under the rules that we have set below.
|
34
|
+
|
35
|
+
In the interest of fostering an open and welcoming environment, we as
|
36
|
+
contributors and maintainers will work to make your participation in
|
37
|
+
our project and community as fulfilling as possible.
|
38
|
+
|
39
|
+
### Our Rules
|
40
|
+
|
41
|
+
All members of our project and community must:
|
42
|
+
|
43
|
+
1. Show empathy toward other project and community members
|
44
|
+
2. Use welcoming and inclusive language
|
45
|
+
3. Respect differing viewpoints and experiences
|
46
|
+
4. Gracefully accept constructive criticism
|
47
|
+
|
48
|
+
All members of our project and community must not:
|
49
|
+
|
50
|
+
1. Harm our project and community, or advocate harm to our project and community
|
51
|
+
2. Insult or make derogatory comments about others
|
52
|
+
3. Interact with others after they have withdrawn permission to do so
|
53
|
+
|
54
|
+
### Our Responsibilities
|
55
|
+
|
56
|
+
We will use any and all lawful means at our disposal to enforce our rules. This includes
|
57
|
+
but is not limited to:
|
58
|
+
|
59
|
+
1. Rejecting contributions
|
60
|
+
2. Removing comments, commits, code, wiki edits, and issues
|
61
|
+
3. Banning abusers
|
62
|
+
|
63
|
+
We will clarify standards of acceptable behavior and we will take appropriate
|
64
|
+
and fair corrective action in response to any instances of unacceptable behavior.
|
65
|
+
|
66
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
67
|
+
reported by contacting us at github.abuse@martin-studio.com. All
|
68
|
+
complaints will be reviewed and investigated and will result in a response that
|
69
|
+
is deemed necessary and appropriate to the circumstances. We
|
70
|
+
maintain strict confidentiality with regard to the reporter of an incident.
|
71
|
+
Further details of specific enforcement policies may be posted separately.
|
72
|
+
|
73
|
+
### Attribution
|
74
|
+
|
75
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
76
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
77
|
+
|
78
|
+
[homepage]: http://contributor-covenant.org
|
79
|
+
[version]: http://contributor-covenant.org/version/1/4/gg
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hive-ruby (1.0.0.pre.1)
|
5
|
+
base58 (~> 0.2, >= 0.2.3)
|
6
|
+
bindata (~> 2.4, >= 2.4.4)
|
7
|
+
bitcoin-ruby (~> 0.0, >= 0.0.18)
|
8
|
+
ffi (~> 1.9, >= 1.9.23)
|
9
|
+
hashie (~> 3.5, >= 3.5.7)
|
10
|
+
json (~> 2.1, >= 2.1.0)
|
11
|
+
logging (~> 2.2, >= 2.2.0)
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
addressable (2.7.0)
|
17
|
+
public_suffix (>= 2.0.2, < 5.0)
|
18
|
+
awesome_print (1.8.0)
|
19
|
+
base58 (0.2.3)
|
20
|
+
bindata (2.4.7)
|
21
|
+
bitcoin-ruby (0.0.20)
|
22
|
+
eventmachine
|
23
|
+
ffi
|
24
|
+
scrypt
|
25
|
+
coderay (1.1.2)
|
26
|
+
crack (0.4.3)
|
27
|
+
safe_yaml (~> 1.0.0)
|
28
|
+
docile (1.3.2)
|
29
|
+
eventmachine (1.2.7)
|
30
|
+
ffi (1.12.2)
|
31
|
+
ffi-compiler (1.0.1)
|
32
|
+
ffi (>= 1.0.0)
|
33
|
+
rake
|
34
|
+
hashdiff (1.0.1)
|
35
|
+
hashie (3.6.0)
|
36
|
+
io-console (0.5.6)
|
37
|
+
irb (1.2.4)
|
38
|
+
reline (>= 0.0.1)
|
39
|
+
json (2.3.0)
|
40
|
+
little-plugger (1.1.4)
|
41
|
+
logging (2.2.2)
|
42
|
+
little-plugger (~> 1.1)
|
43
|
+
multi_json (~> 1.10)
|
44
|
+
method_source (1.0.0)
|
45
|
+
minitest (5.14.0)
|
46
|
+
minitest-line (0.6.5)
|
47
|
+
minitest (~> 5.0)
|
48
|
+
minitest-proveit (1.0.0)
|
49
|
+
minitest (> 5, < 7)
|
50
|
+
multi_json (1.14.1)
|
51
|
+
pry (0.13.1)
|
52
|
+
coderay (~> 1.1)
|
53
|
+
method_source (~> 1.0)
|
54
|
+
public_suffix (4.0.4)
|
55
|
+
rake (13.0.1)
|
56
|
+
reline (0.1.4)
|
57
|
+
io-console (~> 0.5)
|
58
|
+
safe_yaml (1.0.5)
|
59
|
+
scrypt (3.0.7)
|
60
|
+
ffi-compiler (>= 1.0, < 2.0)
|
61
|
+
simplecov (0.18.5)
|
62
|
+
docile (~> 1.1)
|
63
|
+
simplecov-html (~> 0.11)
|
64
|
+
simplecov-html (0.12.2)
|
65
|
+
vcr (5.1.0)
|
66
|
+
webmock (3.8.3)
|
67
|
+
addressable (>= 2.3.6)
|
68
|
+
crack (>= 0.3.2)
|
69
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
70
|
+
yard (0.9.25)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
awesome_print (~> 1.8, >= 1.8.0)
|
77
|
+
bundler (~> 1.16, >= 1.16.1)
|
78
|
+
hive-ruby!
|
79
|
+
irb (~> 1.2, >= 1.2.3)
|
80
|
+
minitest (~> 5.10, >= 5.10.3)
|
81
|
+
minitest-line (~> 0.6, >= 0.6.4)
|
82
|
+
minitest-proveit (~> 1.0, >= 1.0.0)
|
83
|
+
pry (~> 0.11, >= 0.11.3)
|
84
|
+
rake (~> 13.0.1, >= 12.3.0)
|
85
|
+
simplecov (~> 0.15, >= 0.15.1)
|
86
|
+
vcr (~> 5.1, >= 4.0.0)
|
87
|
+
webmock (~> 3.3, >= 3.3.0)
|
88
|
+
yard (~> 0.9, >= 0.9.12)
|
89
|
+
|
90
|
+
BUNDLED WITH
|
91
|
+
1.16.6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 hive-ruby
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
[](https://badge.fury.io/rb/hive-ruby)
|
2
|
+
<!-- [](http://inch-ci.org/github/GalacticaActual/hive-ruby) -->
|
3
|
+
|
4
|
+
# `hive-ruby`
|
5
|
+
|
6
|
+
Hive-ruby the Ruby API for Hive blockchain.
|
7
|
+
|
8
|
+
<!-- Full documentation: http://www.rubydoc.info/gems/hive-ruby -->
|
9
|
+
|
10
|
+
## `radiator` vs. `hive-ruby`
|
11
|
+
|
12
|
+
The `hive-ruby` gem was written from the ground up by `@inertia`, who is also the author of [`radiator`](https://github.com/inertia186/radiator).
|
13
|
+
|
14
|
+
> "I intend to continue work on `radiator` indefinitely. But in `radiator-0.5`, I intend to refactor `radiator` so that is uses `hive-ruby` as its core. This means that some features of `radiator` like Serialization will become redundant. I think it's still useful for radiator to do its own serialization because it reduces the number of API requests." - @inertia
|
15
|
+
|
16
|
+
`radiator` | `hive-ruby`
|
17
|
+
---------- | ------------
|
18
|
+
Has internal failover logic | Can have failover delegated externally
|
19
|
+
Passes `error` responses to the caller | Handles `error` responses and raises exceptions
|
20
|
+
Supports tx signing, does its own serialization | Also supports tx signing, but delegates serialization to `database_api.get_transaction_hex`, then deserializes to verify
|
21
|
+
All apis and methods are hardcoded | Asks `jsonrpc` what apis and methods are available from the node
|
22
|
+
(`radiator-0.4.x`) Only supports AppBase but relies on `condenser_api` | Only supports AppBase but does not rely on `condenser_api` **(WIP)**
|
23
|
+
Small list of helper methods for select ops (in addition to build your own transaction) | Complete implementation of helper methods for every op (in addition to build your own transaction)
|
24
|
+
Does not (yet) support `json-rpc-batch` requests | Supports `json-rpc-batch` requests
|
25
|
+
|
26
|
+
## Getting Started
|
27
|
+
|
28
|
+
The hive-ruby gem is compatible with Ruby 2.2.5 or later.
|
29
|
+
|
30
|
+
### Install the gem for your project
|
31
|
+
|
32
|
+
*(Assuming that [Ruby is installed](https://www.ruby-lang.org/en/downloads/) on your computer, as well as [RubyGems](http://rubygems.org/pages/download))*
|
33
|
+
|
34
|
+
To install the gem on your computer, run in shell:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
gem install hive-ruby
|
38
|
+
```
|
39
|
+
|
40
|
+
... then add in your code:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
require 'hive'
|
44
|
+
```
|
45
|
+
|
46
|
+
To add the gem as a dependency to your project with [Bundler](http://bundler.io/), you can add this line in your Gemfile:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
gem 'hive-ruby', require: 'hive'
|
50
|
+
```
|
51
|
+
|
52
|
+
## Examples
|
53
|
+
|
54
|
+
### Broadcast Vote
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
params = {
|
58
|
+
voter: voter,
|
59
|
+
author: author,
|
60
|
+
permlink: permlink,
|
61
|
+
weight: weight
|
62
|
+
}
|
63
|
+
|
64
|
+
Hive::Broadcast.vote(wif: wif, params: params) do |result|
|
65
|
+
puts result
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
<!-- *See: [Broadcast](https://www.rubydoc.info/gems/hive-ruby/Hive/Broadcast)* -->
|
70
|
+
|
71
|
+
### Streaming
|
72
|
+
|
73
|
+
The value passed to the block is an object, with the keys: `:type` and `:value`.
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
stream = Hive::Stream.new
|
77
|
+
|
78
|
+
stream.operations do |op|
|
79
|
+
puts "#{op.type}: #{op.value}"
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
83
|
+
To start a stream from a specific block number, pass it as an argument:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
stream = Hive::Stream.new
|
87
|
+
|
88
|
+
stream.operations(at_block_num: 9001) do |op|
|
89
|
+
puts "#{op.type}: #{op.value}"
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
You can also grab the related transaction id and block number for each operation:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
stream = Hive::Stream.new
|
97
|
+
|
98
|
+
stream.operations do |op, trx_id, block_num|
|
99
|
+
puts "#{block_num} :: #{trx_id}"
|
100
|
+
puts "#{op.type}: #{op.value}"
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
To stream only certain operations:
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
stream = Hive::Stream.new
|
108
|
+
|
109
|
+
stream.operations(types: :vote_operation) do |op|
|
110
|
+
puts "#{op.type}: #{op.value}"
|
111
|
+
end
|
112
|
+
```
|
113
|
+
|
114
|
+
Or pass an array of certain operations:
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
stream = Hive::Stream.new
|
118
|
+
|
119
|
+
stream.operations(types: [:comment_operation, :vote_operation]) do |op|
|
120
|
+
puts "#{op.type}: #{op.value}"
|
121
|
+
end
|
122
|
+
```
|
123
|
+
|
124
|
+
Or (optionally) just pass the operation(s) you want as the only arguments. This is semantic sugar for when you want specific types and take all of the defaults.
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
stream = Hive::Stream.new
|
128
|
+
|
129
|
+
stream.operations(:vote_operation) do |op|
|
130
|
+
puts "#{op.type}: #{op.value}"
|
131
|
+
end
|
132
|
+
```
|
133
|
+
|
134
|
+
To also include virtual operations:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
stream = Hive::Stream.new
|
138
|
+
|
139
|
+
stream.operations(include_virtual: true) do |op|
|
140
|
+
puts "#{op.type}: #{op.value}"
|
141
|
+
end
|
142
|
+
```
|
143
|
+
|
144
|
+
### Multisig
|
145
|
+
|
146
|
+
You can use multisignature to broadcast an operation.
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
params = {
|
150
|
+
voter: voter,
|
151
|
+
author: author,
|
152
|
+
permlink: permlink,
|
153
|
+
weight: weight
|
154
|
+
}
|
155
|
+
|
156
|
+
Hive::Broadcast.vote(wif: [wif1, wif2], params: params) do |result|
|
157
|
+
puts result
|
158
|
+
end
|
159
|
+
```
|
160
|
+
|
161
|
+
In addition to signing with multiple `wif` private keys, it is possible to also export a partially signed transaction to have signing completed by someone else.
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
builder = Hive::TransactionBuilder.new(wif: wif1)
|
165
|
+
|
166
|
+
builder.put(vote: {
|
167
|
+
voter: voter,
|
168
|
+
author: author,
|
169
|
+
permlink: permlink,
|
170
|
+
weight: weight
|
171
|
+
})
|
172
|
+
|
173
|
+
trx = builder.sign.to_json
|
174
|
+
|
175
|
+
File.open('trx.json', 'w') do |f|
|
176
|
+
f.write(trx)
|
177
|
+
end
|
178
|
+
```
|
179
|
+
|
180
|
+
Then send the contents of `trx.json` to the other signing party so they can privately sign and broadcast the transaction.
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
trx = open('trx.json').read
|
184
|
+
builder = Hive::TransactionBuilder.new(wif: wif2, trx: trx)
|
185
|
+
api = Hive::CondenserApi.new
|
186
|
+
trx = builder.transaction
|
187
|
+
api.broadcast_transaction_synchronous(trx)
|
188
|
+
```
|
189
|
+
|
190
|
+
### Get Accounts
|
191
|
+
|
192
|
+
```ruby
|
193
|
+
api = Hive::DatabaseApi.new
|
194
|
+
|
195
|
+
api.find_accounts(accounts: ['hiveio', 'alice']) do |result|
|
196
|
+
puts result.accounts
|
197
|
+
end
|
198
|
+
```
|
199
|
+
|
200
|
+
<!-- *See: [Api](https://www.rubydoc.info/gems/hive-ruby/Hive/Api)* -->
|
201
|
+
|
202
|
+
### Reputation Formatter
|
203
|
+
|
204
|
+
```ruby
|
205
|
+
rep = Hive::Formatter.reputation(account.reputation)
|
206
|
+
puts rep
|
207
|
+
```
|
208
|
+
|
209
|
+
### Tests
|
210
|
+
|
211
|
+
* Clone the client repository into a directory of your choice:
|
212
|
+
* `git clone https://gitlab.syncad.com/hive/hive-ruby.git`
|
213
|
+
* Navigate into the new folder
|
214
|
+
* `cd hive-ruby`
|
215
|
+
* All tests can be invoked as follows:
|
216
|
+
* `bundle exec rake test`
|
217
|
+
* To run `static` tests:
|
218
|
+
* `bundle exec rake test:static`
|
219
|
+
* To run `broadcast` tests (broadcast is simulated, only `verify` is actually used):
|
220
|
+
* `bundle exec rake test:broadcast`
|
221
|
+
* To run `threads` tests (which quickly verifies thread safety):
|
222
|
+
* `bundle exec rake test:threads`
|
223
|
+
* To run `testnet` tests (which does actual broadcasts)
|
224
|
+
* `TEST_NODE=https://testnet-api.openhive.network bundle exec rake test:testnet`
|
225
|
+
|
226
|
+
You can also run other tests that are not part of the above `test` execution:
|
227
|
+
|
228
|
+
* To run `block_range`, which streams blocks (using `json-rpc-batch`)
|
229
|
+
* `bundle exec rake stream:block_range`
|
230
|
+
|
231
|
+
|
232
|
+
If you want to point to any node for tests, instead of letting the test suite pick the default, set the environment variable to `TEST_NODE`, e.g.:
|
233
|
+
|
234
|
+
```bash
|
235
|
+
$ TEST_NODE=https://testnet-api.openhive.network bundle exec rake test
|
236
|
+
```
|
237
|
+
|
238
|
+
## Contributions
|
239
|
+
|
240
|
+
Patches are welcome! Contributors are listed in the `hive-ruby.gemspec` file. Please run the tests (`rake test`) before opening a pull request and make sure that you are passing all of them. If you would like to contribute, but don't know what to work on, check the issues list.
|
241
|
+
|
242
|
+
## Issues
|
243
|
+
|
244
|
+
When you find issues, please report them!
|
245
|
+
|
246
|
+
## License
|
247
|
+
|
248
|
+
MIT
|