From 27c3dddd2a84679f4c2d47430c43f0af67ffd158 Mon Sep 17 00:00:00 2001 From: Anthony Martin <github@martin-studio.com> Date: Thu, 7 May 2020 00:35:34 -0700 Subject: [PATCH] Initial commit. --- CONTRIBUTING.md | 4 +- Gemfile.lock | 74 +++-- LICENSE | 3 +- README.md | 72 +++-- Rakefile | 110 ++++--- steem-ruby.gemspec => hive-ruby.gemspec | 19 +- lib/hive.rb | 89 ++++++ lib/{steem => hive}/api.rb | 39 ++- lib/{steem => hive}/base_error.rb | 78 ++--- lib/{steem => hive}/block_api.rb | 6 +- lib/hive/bridge.rb | 12 + lib/{steem => hive}/broadcast.rb | 154 +++++----- lib/hive/chain_config.rb | 34 +++ lib/hive/fallback.rb | 287 ++++++++++++++++++ lib/{steem => hive}/formatter.rb | 2 +- lib/{steem => hive}/jsonrpc.rb | 10 +- lib/{steem => hive}/marshal.rb | 16 +- lib/{steem => hive}/mixins/jsonable.rb | 2 +- lib/{steem => hive}/mixins/retriable.rb | 2 +- lib/{steem => hive}/mixins/serializable.rb | 2 +- lib/{steem => hive}/operation.rb | 4 +- .../operation/account_create.rb | 2 +- .../account_create_with_delegation.rb | 2 +- .../operation/account_update.rb | 2 +- lib/hive/operation/account_witness_proxy.rb | 4 + .../operation/account_witness_vote.rb | 2 +- .../operation/cancel_transfer_from_savings.rb | 4 + .../operation/challenge_authority.rb | 2 +- .../operation/change_recovery_account.rb | 2 +- .../operation/claim_account.rb | 2 +- .../operation/claim_reward_balance.rb | 2 +- lib/{steem => hive}/operation/comment.rb | 2 +- .../operation/comment_options.rb | 2 +- lib/{steem => hive}/operation/convert.rb | 2 +- .../operation/create_claimed_account.rb | 2 +- lib/{steem => hive}/operation/custom.rb | 2 +- .../operation/custom_binary.rb | 2 +- lib/{steem => hive}/operation/custom_json.rb | 2 +- lib/hive/operation/decline_voting_rights.rb | 4 + .../operation/delegate_vesting_shares.rb | 2 +- .../operation/delete_comment.rb | 2 +- .../operation/escrow_approve.rb | 2 +- .../operation/escrow_dispute.rb | 2 +- .../operation/escrow_release.rb | 2 +- .../operation/escrow_transfer.rb | 2 +- lib/{steem => hive}/operation/feed_publish.rb | 2 +- lib/hive/operation/limit_order_cancel.rb | 4 + .../operation/limit_order_create.rb | 2 +- .../operation/limit_order_create2.rb | 2 +- .../operation/prove_authority.rb | 2 +- .../operation/recover_account.rb | 2 +- .../operation/report_over_production.rb | 2 +- .../operation/request_account_recovery.rb | 2 +- .../operation/reset_account.rb | 2 +- .../operation/set_reset_account.rb | 2 +- .../operation/set_withdraw_vesting_route.rb | 2 +- lib/{steem => hive}/operation/transfer.rb | 2 +- .../operation/transfer_from_savings.rb | 2 +- .../operation/transfer_to_savings.rb | 2 +- .../operation/transfer_to_vesting.rb | 2 +- lib/{steem => hive}/operation/vote.rb | 2 +- .../operation/withdraw_vesting.rb | 2 +- .../operation/witness_set_properties.rb | 2 +- .../operation/witness_update.rb | 2 +- lib/{steem => hive}/rpc/base_client.rb | 8 +- lib/{steem => hive}/rpc/http_client.rb | 8 +- .../rpc/thread_safe_http_client.rb | 4 +- lib/{steem => hive}/stream.rb | 52 ++-- lib/{steem => hive}/transaction.rb | 35 ++- lib/{steem => hive}/transaction_builder.rb | 49 +-- lib/{steem => hive}/type/amount.rb | 61 ++-- lib/{steem => hive}/type/base_type.rb | 2 +- lib/{steem => hive}/utils.rb | 2 +- lib/hive/version.rb | 4 + lib/steem.rb | 85 ------ lib/steem/chain_config.rb | 36 --- lib/steem/operation/account_witness_proxy.rb | 4 - .../operation/cancel_transfer_from_savings.rb | 4 - lib/steem/operation/decline_voting_rights.rb | 4 - lib/steem/operation/limit_order_cancel.rb | 4 - lib/steem/version.rb | 4 - .../account_by_key_api_test.rb | 12 +- .../account_history_api_test.rb | 14 +- test/hive/amount_test.rb | 33 ++ test/{steem => hive}/api_test.rb | 70 +++-- test/{steem => hive}/block_api_test.rb | 8 +- test/hive/bridge_test.rb | 95 ++++++ test/{steem => hive}/broadcast_test.rb | 106 ++++--- test/{steem => hive}/database_api_test.rb | 86 +++--- test/{steem => hive}/follow_api_test.rb | 34 +-- test/{steem => hive}/formatter_test.rb | 4 +- test/{steem => hive}/jsonrpc_test.rb | 128 ++++---- .../market_history_api_test.rb | 12 +- test/{steem => hive}/marshal_test.rb | 44 +-- .../network_broadcast_api_test.rb | 12 +- test/{steem => hive}/rc_api_test.rb | 12 +- test/{steem => hive}/rpc_client_test.rb | 4 +- test/{steem => hive}/stream_test.rb | 14 +- test/{steem => hive}/tags_api_test.rb | 46 +-- test/{steem => hive}/testnet_test.rb | 8 +- .../transaction_builder_test.rb | 31 +- test/steem/amount_test.rb | 33 -- test/test_helper.rb | 14 +- 103 files changed, 1414 insertions(+), 885 deletions(-) rename steem-ruby.gemspec => hive-ruby.gemspec (73%) create mode 100644 lib/hive.rb rename lib/{steem => hive}/api.rb (82%) rename lib/{steem => hive}/base_error.rb (65%) rename lib/{steem => hive}/block_api.rb (93%) create mode 100644 lib/hive/bridge.rb rename lib/{steem => hive}/broadcast.rb (87%) create mode 100644 lib/hive/chain_config.rb create mode 100644 lib/hive/fallback.rb rename lib/{steem => hive}/formatter.rb (95%) rename lib/{steem => hive}/jsonrpc.rb (89%) rename lib/{steem => hive}/marshal.rb (92%) rename lib/{steem => hive}/mixins/jsonable.rb (98%) rename lib/{steem => hive}/mixins/retriable.rb (98%) rename lib/{steem => hive}/mixins/serializable.rb (98%) rename lib/{steem => hive}/operation.rb (95%) rename lib/{steem => hive}/operation/account_create.rb (81%) rename lib/{steem => hive}/operation/account_create_with_delegation.rb (81%) rename lib/{steem => hive}/operation/account_update.rb (79%) create mode 100644 lib/hive/operation/account_witness_proxy.rb rename lib/{steem => hive}/operation/account_witness_vote.rb (58%) create mode 100644 lib/hive/operation/cancel_transfer_from_savings.rb rename lib/{steem => hive}/operation/challenge_authority.rb (61%) rename lib/{steem => hive}/operation/change_recovery_account.rb (64%) rename lib/{steem => hive}/operation/claim_account.rb (62%) rename lib/{steem => hive}/operation/claim_reward_balance.rb (67%) rename lib/{steem => hive}/operation/comment.rb (80%) rename lib/{steem => hive}/operation/comment_options.rb (84%) rename lib/{steem => hive}/operation/convert.rb (63%) rename lib/{steem => hive}/operation/create_claimed_account.rb (80%) rename lib/{steem => hive}/operation/custom.rb (66%) rename lib/{steem => hive}/operation/custom_binary.rb (81%) rename lib/{steem => hive}/operation/custom_json.rb (73%) create mode 100644 lib/hive/operation/decline_voting_rights.rb rename lib/{steem => hive}/operation/delegate_vesting_shares.rb (60%) rename lib/{steem => hive}/operation/delete_comment.rb (51%) rename lib/{steem => hive}/operation/escrow_approve.rb (73%) rename lib/{steem => hive}/operation/escrow_dispute.rb (69%) rename lib/{steem => hive}/operation/escrow_release.rb (79%) rename lib/{steem => hive}/operation/escrow_transfer.rb (84%) rename lib/{steem => hive}/operation/feed_publish.rb (54%) create mode 100644 lib/hive/operation/limit_order_cancel.rb rename lib/{steem => hive}/operation/limit_order_create.rb (76%) rename lib/{steem => hive}/operation/limit_order_create2.rb (76%) rename lib/{steem => hive}/operation/prove_authority.rb (54%) rename lib/{steem => hive}/operation/recover_account.rb (74%) rename lib/{steem => hive}/operation/report_over_production.rb (70%) rename lib/{steem => hive}/operation/request_account_recovery.rb (70%) rename lib/{steem => hive}/operation/reset_account.rb (67%) rename lib/{steem => hive}/operation/set_reset_account.rb (64%) rename lib/{steem => hive}/operation/set_withdraw_vesting_route.rb (62%) rename lib/{steem => hive}/operation/transfer.rb (66%) rename lib/{steem => hive}/operation/transfer_from_savings.rb (68%) rename lib/{steem => hive}/operation/transfer_to_savings.rb (63%) rename lib/{steem => hive}/operation/transfer_to_vesting.rb (56%) rename lib/{steem => hive}/operation/vote.rb (70%) rename lib/{steem => hive}/operation/withdraw_vesting.rb (53%) rename lib/{steem => hive}/operation/witness_set_properties.rb (61%) rename lib/{steem => hive}/operation/witness_update.rb (73%) rename lib/{steem => hive}/rpc/base_client.rb (95%) rename lib/{steem => hive}/rpc/http_client.rb (96%) rename lib/{steem => hive}/rpc/thread_safe_http_client.rb (97%) rename lib/{steem => hive}/stream.rb (90%) rename lib/{steem => hive}/transaction.rb (68%) rename lib/{steem => hive}/transaction_builder.rb (86%) rename lib/{steem => hive}/type/amount.rb (57%) rename lib/{steem => hive}/type/base_type.rb (91%) rename lib/{steem => hive}/utils.rb (95%) create mode 100644 lib/hive/version.rb delete mode 100644 lib/steem.rb delete mode 100644 lib/steem/chain_config.rb delete mode 100644 lib/steem/operation/account_witness_proxy.rb delete mode 100644 lib/steem/operation/cancel_transfer_from_savings.rb delete mode 100644 lib/steem/operation/decline_voting_rights.rb delete mode 100644 lib/steem/operation/limit_order_cancel.rb delete mode 100644 lib/steem/version.rb rename test/{steem => hive}/account_by_key_api_test.rb (72%) rename test/{steem => hive}/account_history_api_test.rb (79%) create mode 100644 test/hive/amount_test.rb rename test/{steem => hive}/api_test.rb (72%) rename test/{steem => hive}/block_api_test.rb (97%) create mode 100644 test/hive/bridge_test.rb rename test/{steem => hive}/broadcast_test.rb (91%) rename test/{steem => hive}/database_api_test.rb (83%) rename test/{steem => hive}/follow_api_test.rb (85%) rename test/{steem => hive}/formatter_test.rb (78%) rename test/{steem => hive}/jsonrpc_test.rb (80%) rename test/{steem => hive}/market_history_api_test.rb (88%) rename test/{steem => hive}/marshal_test.rb (94%) rename test/{steem => hive}/network_broadcast_api_test.rb (82%) rename test/{steem => hive}/rc_api_test.rb (80%) rename test/{steem => hive}/rpc_client_test.rb (96%) rename test/{steem => hive}/stream_test.rb (93%) rename test/{steem => hive}/tags_api_test.rb (90%) rename test/{steem => hive}/testnet_test.rb (89%) rename test/{steem => hive}/transaction_builder_test.rb (91%) delete mode 100644 test/steem/amount_test.rb diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7acf8ac..828749b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Contributing -Everyone is welcome to contribute code to Steemit, Inc. projects. We have a Code of Conduct; +Everyone is welcome to contribute code to Galactica Actual projects. We have a Code of Conduct; we ask that you please follow it in all your interactions with our team and your fellow contributors. @@ -64,7 +64,7 @@ We will clarify standards of acceptable behavior and we will take appropriate and fair corrective action in response to any instances of unacceptable behavior. Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting us at github.abuse@steemit.com. All +reported by contacting us at github.abuse@martin-studio.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. We maintain strict confidentiality with regard to the reporter of an incident. diff --git a/Gemfile.lock b/Gemfile.lock index a00fe85..81a3dae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - steem-ruby (0.9.4) + hive-ruby (1.0.0.pre.1) base58 (~> 0.2, >= 0.2.3) bindata (~> 2.4, >= 2.4.4) bitcoin-ruby (~> 0.0, >= 0.0.18) @@ -13,48 +13,61 @@ PATH GEM remote: https://rubygems.org/ specs: - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) awesome_print (1.8.0) base58 (0.2.3) - bindata (2.4.4) - bitcoin-ruby (0.0.18) + bindata (2.4.7) + bitcoin-ruby (0.0.20) + eventmachine + ffi + scrypt coderay (1.1.2) crack (0.4.3) safe_yaml (~> 1.0.0) - docile (1.3.1) - ffi (1.9.25) - hashdiff (0.3.7) + docile (1.3.2) + eventmachine (1.2.7) + ffi (1.12.2) + ffi-compiler (1.0.1) + ffi (>= 1.0.0) + rake + hashdiff (1.0.1) hashie (3.6.0) - json (2.1.0) + io-console (0.5.6) + irb (1.2.4) + reline (>= 0.0.1) + json (2.3.0) little-plugger (1.1.4) logging (2.2.2) little-plugger (~> 1.1) multi_json (~> 1.10) - method_source (0.9.1) - minitest (5.11.3) + method_source (1.0.0) + minitest (5.14.0) minitest-line (0.6.5) minitest (~> 5.0) minitest-proveit (1.0.0) minitest (> 5, < 7) - multi_json (1.13.1) - pry (0.12.0) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - public_suffix (3.0.3) - rake (12.3.1) - safe_yaml (1.0.4) - simplecov (0.16.1) + multi_json (1.14.1) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (4.0.4) + rake (13.0.1) + reline (0.1.4) + io-console (~> 0.5) + safe_yaml (1.0.5) + scrypt (3.0.7) + ffi-compiler (>= 1.0, < 2.0) + simplecov (0.18.5) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - vcr (4.0.0) - webmock (3.4.2) + simplecov-html (~> 0.11) + simplecov-html (0.12.2) + vcr (5.1.0) + webmock (3.8.3) addressable (>= 2.3.6) crack (>= 0.3.2) - hashdiff - yard (0.9.16) + hashdiff (>= 0.4.0, < 2.0.0) + yard (0.9.25) PLATFORMS ruby @@ -62,16 +75,17 @@ PLATFORMS DEPENDENCIES awesome_print (~> 1.8, >= 1.8.0) bundler (~> 1.16, >= 1.16.1) + hive-ruby! + irb (~> 1.2, >= 1.2.3) minitest (~> 5.10, >= 5.10.3) minitest-line (~> 0.6, >= 0.6.4) minitest-proveit (~> 1.0, >= 1.0.0) pry (~> 0.11, >= 0.11.3) - rake (~> 12.3, >= 12.3.0) + rake (~> 13.0.1, >= 12.3.0) simplecov (~> 0.15, >= 0.15.1) - steem-ruby! - vcr (~> 4.0, >= 4.0.0) + vcr (~> 5.1, >= 4.0.0) webmock (~> 3.3, >= 3.3.0) yard (~> 0.9, >= 0.9.12) BUNDLED WITH - 1.16.5 + 1.16.6 diff --git a/LICENSE b/LICENSE index 2cffac3..1a86d25 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 steem-ruby +Copyright (c) 2020 hive-ruby Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index ec0ba8d..390a6fb 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,19 @@ -[](https://badge.fury.io/rb/steem-ruby) -[](http://inch-ci.org/github/steemit/steem-ruby) +[](https://badge.fury.io/rb/hive-ruby) +<!-- [](http://inch-ci.org/github/GalacticaActual/hive-ruby) --> -# `steem-ruby` +# `hive-ruby` -Steem-ruby the Ruby API for Steem blockchain. +Hive-ruby the Ruby API for Hive blockchain. -Full documentation: http://www.rubydoc.info/gems/steem-ruby +<!-- Full documentation: http://www.rubydoc.info/gems/hive-ruby --> -**Note:** *This library depends on AppBase methods that are a work in progress.* +## `radiator` vs. `hive-ruby` -## `radiator` vs. `steem-ruby` +The `hive-ruby` gem was written from the ground up by `@inertia`, who is also the author of [`radiator`](https://github.com/inertia186/radiator). -The `steem-ruby` gem was written from the ground up by `@inertia`, who is also the author of [`radiator`](https://github.com/inertia186/radiator). +> "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 -> "I intend to continue work on `radiator` indefinitely. But in `radiator-0.5`, I intend to refactor `radiator` so that is uses `steem-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 - -`radiator` | `steem-ruby` +`radiator` | `hive-ruby` ---------- | ------------ Has internal failover logic | Can have failover delegated externally Passes `error` responses to the caller | Handles `error` responses and raises exceptions @@ -27,7 +25,7 @@ Does not (yet) support `json-rpc-batch` requests | Supports `json-rpc-batch` req ## Getting Started -The steem-ruby gem is compatible with Ruby 2.2.5 or later. +The hive-ruby gem is compatible with Ruby 2.2.5 or later. ### Install the gem for your project @@ -36,19 +34,19 @@ The steem-ruby gem is compatible with Ruby 2.2.5 or later. To install the gem on your computer, run in shell: ```bash -gem install steem-ruby +gem install hive-ruby ``` ... then add in your code: ```ruby -require 'steem' +require 'hive' ``` To add the gem as a dependency to your project with [Bundler](http://bundler.io/), you can add this line in your Gemfile: ```ruby -gem 'steem-ruby', require: 'steem' +gem 'hive-ruby', require: 'hive' ``` ## Examples @@ -63,19 +61,19 @@ params = { weight: weight } -Steem::Broadcast.vote(wif: wif, params: params) do |result| +Hive::Broadcast.vote(wif: wif, params: params) do |result| puts result end ``` -*See: [Broadcast](https://www.rubydoc.info/gems/steem-ruby/Steem/Broadcast)* +<!-- *See: [Broadcast](https://www.rubydoc.info/gems/hive-ruby/Hive/Broadcast)* --> ### Streaming The value passed to the block is an object, with the keys: `:type` and `:value`. ```ruby -stream = Steem::Stream.new +stream = Hive::Stream.new stream.operations do |op| puts "#{op.type}: #{op.value}" @@ -85,7 +83,7 @@ end To start a stream from a specific block number, pass it as an argument: ```ruby -stream = Steem::Stream.new +stream = Hive::Stream.new stream.operations(at_block_num: 9001) do |op| puts "#{op.type}: #{op.value}" @@ -95,7 +93,7 @@ end You can also grab the related transaction id and block number for each operation: ```ruby -stream = Steem::Stream.new +stream = Hive::Stream.new stream.operations do |op, trx_id, block_num| puts "#{block_num} :: #{trx_id}" @@ -106,7 +104,7 @@ end To stream only certain operations: ```ruby -stream = Steem::Stream.new +stream = Hive::Stream.new stream.operations(types: :vote_operation) do |op| puts "#{op.type}: #{op.value}" @@ -116,7 +114,7 @@ end Or pass an array of certain operations: ```ruby -stream = Steem::Stream.new +stream = Hive::Stream.new stream.operations(types: [:comment_operation, :vote_operation]) do |op| puts "#{op.type}: #{op.value}" @@ -126,7 +124,7 @@ end 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. ```ruby -stream = Steem::Stream.new +stream = Hive::Stream.new stream.operations(:vote_operation) do |op| puts "#{op.type}: #{op.value}" @@ -136,7 +134,7 @@ end To also include virtual operations: ```ruby -stream = Steem::Stream.new +stream = Hive::Stream.new stream.operations(include_virtual: true) do |op| puts "#{op.type}: #{op.value}" @@ -155,7 +153,7 @@ params = { weight: weight } -Steem::Broadcast.vote(wif: [wif1, wif2], params: params) do |result| +Hive::Broadcast.vote(wif: [wif1, wif2], params: params) do |result| puts result end ``` @@ -163,7 +161,7 @@ end 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. ```ruby -builder = Steem::TransactionBuilder.new(wif: wif1) +builder = Hive::TransactionBuilder.new(wif: wif1) builder.put(vote: { voter: voter, @@ -183,8 +181,8 @@ Then send the contents of `trx.json` to the other signing party so they can priv ```ruby trx = open('trx.json').read -builder = Steem::TransactionBuilder.new(wif: wif2, trx: trx) -api = Steem::CondenserApi.new +builder = Hive::TransactionBuilder.new(wif: wif2, trx: trx) +api = Hive::CondenserApi.new trx = builder.transaction api.broadcast_transaction_synchronous(trx) ``` @@ -192,28 +190,28 @@ api.broadcast_transaction_synchronous(trx) ### Get Accounts ```ruby -api = Steem::DatabaseApi.new +api = Hive::DatabaseApi.new -api.find_accounts(accounts: ['steemit', 'alice']) do |result| +api.find_accounts(accounts: ['hiveio', 'alice']) do |result| puts result.accounts end ``` -*See: [Api](https://www.rubydoc.info/gems/steem-ruby/Steem/Api)* +<!-- *See: [Api](https://www.rubydoc.info/gems/hive-ruby/Hive/Api)* --> ### Reputation Formatter ```ruby -rep = Steem::Formatter.reputation(account.reputation) +rep = Hive::Formatter.reputation(account.reputation) puts rep ``` ### Tests * Clone the client repository into a directory of your choice: - * `git clone https://github.com/steemit/steem-ruby.git` + * `git clone https://gitlab.syncad.com/hive/hive-ruby.git` * Navigate into the new folder - * `cd steem-ruby` + * `cd hive-ruby` * All tests can be invoked as follows: * `bundle exec rake test` * To run `static` tests: @@ -223,7 +221,7 @@ puts rep * To run `threads` tests (which quickly verifies thread safety): * `bundle exec rake test:threads` * To run `testnet` tests (which does actual broadcasts) - * `TEST_NODE=https://testnet.steemitdev.com bundle exec rake test:testnet` + * `TEST_NODE=https://testnet-api.openhive.network bundle exec rake test:testnet` You can also run other tests that are not part of the above `test` execution: @@ -234,12 +232,12 @@ You can also run other tests that are not part of the above `test` execution: 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.: ```bash -$ TEST_NODE=https://api.steemitdev.com bundle exec rake test +$ TEST_NODE=https://testnet-api.openhive.network bundle exec rake test ``` ## Contributions -Patches are welcome! Contributors are listed in the `steem-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. +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. ## Issues diff --git a/Rakefile b/Rakefile index ecf3f0f..4370002 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ require 'bundler/gem_tasks' require 'rake/testtask' require 'yard' -require 'steem' +require 'hive' Rake::TestTask.new(test: ['clean:vcr', 'test:threads']) do |t| t.libs << 'test' @@ -25,15 +25,15 @@ namespace :test do t.libs << 'test' t.libs << 'lib' t.test_files = [ - 'test/steem/account_by_key_api_test.rb', - 'test/steem/account_history_api_test.rb', - 'test/steem/block_api_test.rb', - 'test/steem/database_api_test.rb', - 'test/steem/follow_api_test.rb', - 'test/steem/jsonrpc_test.rb', - 'test/steem/market_history_api_test.rb', - 'test/steem/tags_api_test.rb', - 'test/steem/witness_api_test.rb' + 'test/hive/account_by_key_api_test.rb', + 'test/hive/account_history_api_test.rb', + 'test/hive/block_api_test.rb', + 'test/hive/database_api_test.rb', + 'test/hive/follow_api_test.rb', + 'test/hive/jsonrpc_test.rb', + 'test/hive/market_history_api_test.rb', + 'test/hive/tags_api_test.rb', + 'test/hive/witness_api_test.rb' ] t.ruby_opts << if ENV['HELL_ENABLED'] '-W2' @@ -50,8 +50,8 @@ namespace :test do t.libs << 'test' t.libs << 'lib' t.test_files = [ - 'test/steem/broadcast_test.rb', - 'test/steem/transaction_builder_test.rb' + 'test/hive/broadcast_test.rb', + 'test/hive/transaction_builder_test.rb' ] t.ruby_opts << if ENV['HELL_ENABLED'] '-W2' @@ -68,7 +68,7 @@ namespace :test do t.libs << 'test' t.libs << 'lib' t.test_files = [ - 'test/steem/testnet_test.rb' + 'test/hive/testnet_test.rb' ] t.ruby_opts << if ENV['HELL_ENABLED'] '-W2' @@ -82,20 +82,30 @@ namespace :test do next if !!ENV['TEST'] threads = [] - api = Steem::Api.new(url: ENV['TEST_NODE']) - database_api = Steem::DatabaseApi.new(url: ENV['TEST_NODE']) + api = Hive::Api.new(url: ENV['TEST_NODE']) + database_api = Hive::DatabaseApi.new(url: ENV['TEST_NODE']) witnesses = {} keys = %i(created url total_missed props running_version hardfork_version_vote hardfork_time_vote) + low_participation_warning_seen = false if defined? Thread.report_on_exception Thread.report_on_exception = true end database_api.get_active_witnesses do |result| + abort 'Bad result from: database_api.get_active_witnesses' if result.nil? + print "Found #{result.witnesses.size} witnesses ..." result.witnesses.each do |witness_name| + if witness_name == '' && !low_participation_warning_seen + warn "\nWarning: low witness participation detected." + low_participation_warning_seen = true + + next + end + threads << Thread.new do api.get_witness_by_account(witness_name) do |witness| witnesses[witness.owner] = witness.map do |k, v| @@ -141,8 +151,8 @@ namespace :stream do task :block_range, [:mode, :at_block_num] do |t, args| mode = (args[:mode] || 'irreversible').to_sym first_block_num = args[:at_block_num].to_i if !!args[:at_block_num] - stream = Steem::Stream.new(url: ENV['TEST_NODE'], mode: mode) - api = Steem::Api.new(url: ENV['TEST_NODE']) + stream = Hive::Stream.new(url: ENV['TEST_NODE'], mode: mode) + api = Hive::Api.new(url: ENV['TEST_NODE']) last_block_num = nil last_timestamp = nil range_complete = false @@ -189,8 +199,8 @@ namespace :stream do task :trx_range, [:mode, :at_block_num] do |t, args| mode = (args[:mode] || 'irreversible').to_sym first_block_num = args[:at_block_num].to_i if !!args[:at_block_num] - stream = Steem::Stream.new(url: ENV['TEST_NODE'], mode: mode) - api = Steem::Api.new(url: ENV['TEST_NODE']) + stream = Hive::Stream.new(url: ENV['TEST_NODE'], mode: mode) + api = Hive::Api.new(url: ENV['TEST_NODE']) api.get_dynamic_global_properties do |properties| current_block_num = if mode == :head @@ -212,8 +222,8 @@ namespace :stream do task :op_range, [:mode, :at_block_num] do |t, args| mode = (args[:mode] || 'irreversible').to_sym first_block_num = args[:at_block_num].to_i if !!args[:at_block_num] - stream = Steem::Stream.new(url: ENV['TEST_NODE'], mode: mode) - api = Steem::Api.new(url: ENV['TEST_NODE']) + stream = Hive::Stream.new(url: ENV['TEST_NODE'], mode: mode) + api = Hive::Api.new(url: ENV['TEST_NODE']) api.get_dynamic_global_properties do |properties| current_block_num = if mode == :head @@ -235,8 +245,8 @@ namespace :stream do task :vop_range, [:mode, :at_block_num] do |t, args| mode = (args[:mode] || 'irreversible').to_sym first_block_num = args[:at_block_num].to_i if !!args[:at_block_num] - stream = Steem::Stream.new(url: ENV['TEST_NODE'], mode: mode) - api = Steem::Api.new(url: ENV['TEST_NODE']) + stream = Hive::Stream.new(url: ENV['TEST_NODE'], mode: mode) + api = Hive::Api.new(url: ENV['TEST_NODE']) api.get_dynamic_global_properties do |properties| current_block_num = if mode == :head @@ -258,8 +268,8 @@ namespace :stream do task :all_op_range, [:mode, :at_block_num] do |t, args| mode = (args[:mode] || 'irreversible').to_sym first_block_num = args[:at_block_num].to_i if !!args[:at_block_num] - stream = Steem::Stream.new(url: ENV['TEST_NODE'], mode: mode) - api = Steem::Api.new(url: ENV['TEST_NODE']) + stream = Hive::Stream.new(url: ENV['TEST_NODE'], mode: mode) + api = Hive::Api.new(url: ENV['TEST_NODE']) api.get_dynamic_global_properties do |properties| current_block_num = if mode == :head @@ -284,9 +294,9 @@ end task default: :test -desc 'Ruby console with steem already required.' +desc 'Ruby console with hive already required.' task :console do - exec 'irb -r steem -I ./lib' + exec 'irb -r hive -I ./lib' end namespace :clean do @@ -301,7 +311,7 @@ namespace :show do desc 'Shows known API names.' task :apis do url = ENV['URL'] - jsonrpc = Steem::Jsonrpc.new(url: url) + jsonrpc = Hive::Jsonrpc.new(url: url) api_methods = jsonrpc.get_api_methods puts api_methods.keys end @@ -309,23 +319,39 @@ namespace :show do desc 'Shows known method names for specified API.' task :methods, [:api] do |t, args| url = ENV['URL'] - jsonrpc = Steem::Jsonrpc.new(url: url) + jsonrpc = Hive::Jsonrpc.new(url: url) api_methods = jsonrpc.get_api_methods - api_methods[args[:api]].each do |method| - jsonrpc.get_signature(method: "#{args[:api]}.#{method}") do |signature| - print "#{method} " - params = signature.args.map do |k, v| - if v =~ /\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])T(2[0-3]|[01]\d):[0-5]\d:[0-5]\d/ - "#{k}: Time" - elsif v.class == Hashie::Array - "#{k}: []" - elsif v.class == Hashie::Mash - "#{k}: {}" - else - "#{k}: #{v.class}" + + api_names = if !!args[:api] + [args[:api]] + else + Hive::Fallback::API_METHODS.keys + end + + api_names.each do |api_name| + unless !!api_methods[api_name.to_s] + puts "Skipped API: #{api_name}" + + next + end + + api_methods[api_name.to_s].each do |method| + jsonrpc.get_signature(method: "#{api_name}.#{method}") do |signature| + print "#{api_name}.#{method} " + + params = signature.args.map do |k, v| + if v =~ /\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])T(2[0-3]|[01]\d):[0-5]\d:[0-5]\d/ + "#{k}: Time" + elsif v.class == Hashie::Array + "#{k}: []" + elsif v.class == Hashie::Mash + "#{k}: {}" + else + "#{k}: #{v.class}" + end end + puts params.join(', ') end - puts params.join(', ') end end end diff --git a/steem-ruby.gemspec b/hive-ruby.gemspec similarity index 73% rename from steem-ruby.gemspec rename to hive-ruby.gemspec index 85de301..9dffb2c 100644 --- a/steem-ruby.gemspec +++ b/hive-ruby.gemspec @@ -1,33 +1,34 @@ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'steem/version' +require 'hive/version' Gem::Specification.new do |spec| - spec.name = 'steem-ruby' - spec.version = Steem::VERSION + spec.name = 'hive-ruby' + spec.version = Hive::VERSION spec.authors = ['Anthony Martin'] - spec.email = ['anthony@steem.com'] + spec.email = ['hive-ruby@martin-studio.com'] - spec.summary = %q{Steem Ruby Client} - spec.description = %q{Client for accessing the Steem blockchain.} - spec.homepage = 'https://github.com/steem/steem-ruby' + spec.summary = %q{Hive Ruby Client} + spec.description = %q{Client for accessing the Hive blockchain.} + spec.homepage = 'https://gitlab.syncad.com/hive/hive-ruby' spec.license = 'MIT' spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) } spec.require_paths = ['lib'] spec.add_development_dependency 'bundler', '~> 1.16', '>= 1.16.1' - spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.0' + spec.add_development_dependency 'rake', '~> 13.0.1', '>= 12.3.0' spec.add_development_dependency 'minitest', '~> 5.10', '>= 5.10.3' spec.add_development_dependency 'minitest-line', '~> 0.6', '>= 0.6.4' spec.add_development_dependency 'minitest-proveit', '~> 1.0', '>= 1.0.0' spec.add_development_dependency 'webmock', '~> 3.3', '>= 3.3.0' spec.add_development_dependency 'simplecov', '~> 0.15', '>= 0.15.1' - spec.add_development_dependency 'vcr', '~> 4.0', '>= 4.0.0' + spec.add_development_dependency 'vcr', '~> 5.1', '>= 4.0.0' spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.12' spec.add_development_dependency 'pry', '~> 0.11', '>= 0.11.3' spec.add_development_dependency 'awesome_print', '~> 1.8', '>= 1.8.0' + spec.add_development_dependency 'irb', '~> 1.2', '>= 1.2.3' spec.add_dependency 'json', '~> 2.1', '>= 2.1.0' spec.add_dependency 'logging', '~> 2.2', '>= 2.2.0' diff --git a/lib/hive.rb b/lib/hive.rb new file mode 100644 index 0000000..ccae1be --- /dev/null +++ b/lib/hive.rb @@ -0,0 +1,89 @@ +# encoding: UTF-8 +require 'json' unless defined?(JSON) +require 'net/https' + +require 'hashie' +require 'hive/version' +require 'hive/utils' +require 'hive/base_error' +require 'hive/mixins/serializable' +require 'hive/mixins/jsonable' +require 'hive/mixins/retriable' +require 'hive/chain_config' +require 'hive/type/base_type' +require 'hive/type/amount' +require 'hive/operation' +require 'hive/operation/account_create.rb' +require 'hive/operation/account_create_with_delegation.rb' +require 'hive/operation/account_update.rb' +require 'hive/operation/account_witness_proxy.rb' +require 'hive/operation/account_witness_vote.rb' +require 'hive/operation/cancel_transfer_from_savings.rb' +require 'hive/operation/challenge_authority.rb' +require 'hive/operation/change_recovery_account.rb' +require 'hive/operation/claim_account.rb' +require 'hive/operation/claim_reward_balance.rb' +require 'hive/operation/comment.rb' +require 'hive/operation/comment_options.rb' +require 'hive/operation/convert.rb' +require 'hive/operation/create_claimed_account.rb' +require 'hive/operation/custom.rb' +require 'hive/operation/custom_binary.rb' +require 'hive/operation/custom_json.rb' +require 'hive/operation/decline_voting_rights.rb' +require 'hive/operation/delegate_vesting_shares.rb' +require 'hive/operation/delete_comment.rb' +require 'hive/operation/escrow_approve.rb' +require 'hive/operation/escrow_dispute.rb' +require 'hive/operation/escrow_release.rb' +require 'hive/operation/escrow_transfer.rb' +require 'hive/operation/feed_publish.rb' +require 'hive/operation/limit_order_cancel.rb' +require 'hive/operation/limit_order_create.rb' +require 'hive/operation/limit_order_create2.rb' +require 'hive/operation/prove_authority.rb' +require 'hive/operation/recover_account.rb' +require 'hive/operation/report_over_production.rb' +require 'hive/operation/request_account_recovery.rb' +require 'hive/operation/reset_account.rb' +require 'hive/operation/set_reset_account.rb' +require 'hive/operation/set_withdraw_vesting_route.rb' +require 'hive/operation/transfer.rb' +require 'hive/operation/transfer_from_savings.rb' +require 'hive/operation/transfer_to_savings.rb' +require 'hive/operation/transfer_to_vesting.rb' +require 'hive/operation/vote.rb' +require 'hive/operation/withdraw_vesting.rb' +require 'hive/operation/witness_update.rb' +require 'hive/operation/witness_set_properties.rb' +require 'hive/marshal' +require 'hive/transaction' +require 'hive/transaction_builder' +require 'hive/rpc/base_client' +require 'hive/rpc/http_client' +require 'hive/rpc/thread_safe_http_client' +require 'hive/api' +require 'hive/jsonrpc' +require 'hive/block_api' +require 'hive/formatter' +require 'hive/broadcast' +require 'hive/stream' +require 'hive/fallback' +require 'hive/bridge' + +module Hive + def self.api_classes + @api_classes ||= {} + end + + def self.const_missing(const) + super unless const.to_s.end_with? 'Api' + + api = api_classes[const] + api ||= Api.clone(freeze: true) rescue Api.clone + api.api_name = const + api_classes[const] = api + end +end + +Hashie.logger = Logger.new(ENV['HASHIE_LOGGER']) diff --git a/lib/steem/api.rb b/lib/hive/api.rb similarity index 82% rename from lib/steem/api.rb rename to lib/hive/api.rb index 2a72a31..9dd7d8c 100644 --- a/lib/steem/api.rb +++ b/lib/hive/api.rb @@ -1,24 +1,24 @@ -module Steem +module Hive # This ruby API works with - # {https://github.com/steemit/steem/releases steemd-0.19.10} and other AppBase + # {https://github.com/openhive-network/hive/releases hived-0.23.00} and other AppBase # compatible upstreams. To access different API namespaces, use the # following: # - # api = Steem::Api.new + # api = Hive::Api.new # api.get_dynamic_global_properties # # The above example will make an instance that can access the - # {https://developers.steem.io/apidefinitions/condenser-api condenser_api} + # {https://developers.hive.io/apidefinitions/condenser-api.html condenser_api} # namespace. Alternatively, you may also create a direct instances with its # full name, if you prefer: # - # api = Steem::CondenserApi.new + # api = Hive::CondenserApi.new # api.get_dynamic_global_properties # # If you know the name of another API that is supported by the remote node, # you can create an instance to that instead, for example: # - # api = Steem::MarketHistoryApi.new + # api = Hive::MarketHistoryApi.new # api.get_volume # # All known API by namespace: @@ -34,7 +34,7 @@ module Steem # * {TagsApi} # * {WitnessApi} # - # Also see: {https://developers.steem.io/apidefinitions/ Complete API Definitions} + # Also see: {https://developers.hive.io/apidefinitions/ Complete API Definitions} class Api attr_accessor :chain, :methods, :rpc_client @@ -73,7 +73,7 @@ module Steem # Override this if you want to just use your own client. Otherwise, inject # the default using: # - # Steem::Api.register default_rpc_client_class: MyClient + # Hive::Api.register default_rpc_client_class: MyClient def self.default_rpc_client_class if !!@injected_dependencies && !!@injected_dependencies[:default_rpc_client_class] @injected_dependencies[:default_rpc_client_class] @@ -91,7 +91,7 @@ module Steem end def initialize(options = {}) - @chain = options[:chain] || :steem + @chain = options[:chain] || :hive @error_pipe = options[:error_pipe] || STDERR @api_name = self.class.api_name ||= :condenser_api @@ -109,7 +109,17 @@ module Steem # have access to instance options until now. Api::jsonrpc = Jsonrpc.new(options) - @methods = Api::jsonrpc(rpc_client.uri.to_s).get_api_methods + + @methods = begin + Api::jsonrpc(rpc_client.uri.to_s).get_api_methods + rescue => e + Fallback::API_METHODS + end + + if Jsonrpc::UNLISTED_APIS.include? @api_name + @methods ||= {} + @methods[@api_name] ||= Fallback::API_METHODS[@api_name] + end unless !!@methods[@api_name] raise UnknownApiError, "#{@api_name} (known APIs: #{@methods.keys.join(' ')})" @@ -146,7 +156,12 @@ module Steem @@signatures ||= {} @@signatures[url] ||= {} - @@signatures[url][rpc_method_name] ||= Api::jsonrpc(url).get_signature(method: rpc_method_name).result + + @@signatures[url][rpc_method_name] ||= begin + Api::jsonrpc(url).get_signature(method: rpc_method_name).result + rescue => e + Hashie::Mash.new({args: Fallback::API_METHOD_SIGNATURES[@api_name][rpc_method_name.split('.').last.to_sym]}) + end end # @private @@ -179,7 +194,7 @@ module Steem @error_pipe.puts "Warning #{rpc_method_name} expects arguments: #{expected_args_size}, got: #{args_size}" end rescue NoMethodError => e - error = Steem::ArgumentError.new("#{rpc_method_name} expects arguments: #{expected_args_size}", e) + error = Hive::ArgumentError.new("#{rpc_method_name} expects arguments: #{expected_args_size}", e) raise error rescue => e raise UnknownError.new("#{rpc_method_name} unknown error.", e) diff --git a/lib/steem/base_error.rb b/lib/hive/base_error.rb similarity index 65% rename from lib/steem/base_error.rb rename to lib/hive/base_error.rb index 400c847..6042802 100644 --- a/lib/steem/base_error.rb +++ b/lib/hive/base_error.rb @@ -1,4 +1,4 @@ -module Steem +module Hive class BaseError < StandardError def initialize(error = nil, cause = nil) @error = error @@ -15,155 +15,155 @@ module Steem def self.build_error(error, context) if error.message == 'Unable to acquire database lock' - raise Steem::RemoteDatabaseLockError, error.message, build_backtrace(error) + raise Hive::RemoteDatabaseLockError, error.message, build_backtrace(error) end if error.message.include? 'Internal Error' - raise Steem::RemoteNodeError, error.message, build_backtrace(error) + raise Hive::RemoteNodeError, error.message, build_backtrace(error) end if error.message.include? 'Server error' - raise Steem::RemoteNodeError, error.message, build_backtrace(error) + raise Hive::RemoteNodeError, error.message, build_backtrace(error) end if error.message.include? 'plugin not enabled' - raise Steem::PluginNotEnabledError, error.message, build_backtrace(error) + raise Hive::PluginNotEnabledError, error.message, build_backtrace(error) end if error.message.include? 'argument' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Invalid params' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.start_with? 'Bad Cast:' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'prefix_len' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Parse Error' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'unknown key' - raise Steem::ArgumentError, "#{context}: #{error.message} (or content has been deleted)", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message} (or content has been deleted)", build_backtrace(error) end if error.message.include? 'Comment is not in account\'s comments' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Could not find comment' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'unable to convert ISO-formatted string to fc::time_point_sec' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Input data have to treated as object.' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'base.amount > share_type(0)' - raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'blk->transactions.size() > itr->trx_in_block' - raise Steem::VirtualOperationsNotAllowedError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::VirtualOperationsNotAllowedError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'A transaction must have at least one operation' - raise Steem::EmptyTransactionError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::EmptyTransactionError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'transaction expiration exception' - raise Steem::TransactionExpiredError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::TransactionExpiredError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Duplicate transaction check failed' - raise Steem::DuplicateTransactionError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::DuplicateTransactionError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'signature is not canonical' - raise Steem::NonCanonicalSignatureError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::NonCanonicalSignatureError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'attempting to push a block that is too old' - raise Steem::BlockTooOldError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::BlockTooOldError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'irrelevant signature' - raise Steem::IrrelevantSignatureError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::IrrelevantSignatureError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'missing required posting authority' - raise Steem::MissingPostingAuthorityError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::MissingPostingAuthorityError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'missing required active authority' - raise Steem::MissingActiveAuthorityError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::MissingActiveAuthorityError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'missing required owner authority' - raise Steem::MissingOwnerAuthorityError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::MissingOwnerAuthorityError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'missing required other authority' - raise Steem::MissingOtherAuthorityError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::MissingOtherAuthorityError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Upstream response error' - raise Steem::UpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::UpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Bad or missing upstream response' - raise Steem::BadOrMissingUpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::BadOrMissingUpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'operator has disabled operation indexing by transaction_id' - raise Steem::TransactionIndexDisabledError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::TransactionIndexDisabledError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'is_valid_account_name' - raise Steem::InvalidAccountError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::InvalidAccountError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include?('Method') && error.message.include?(' does not exist.') - raise Steem::UnknownMethodError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::UnknownMethodError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Invalid operation name' - raise Steem::UnknownOperationError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::UnknownOperationError, "#{context}: #{error.message}", build_backtrace(error) end if error.message =~ /Invalid object name: .+_operation/ - raise Steem::UnknownOperationError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::UnknownOperationError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Author not found' - raise Steem::AuthorNotFoundError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::AuthorNotFoundError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? ' != fc::time_point_sec::maximum()' - raise Steem::ReachedMaximumTimeError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::ReachedMaximumTimeError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Cannot transfer a negative amount (aka: stealing)' - raise Steem::TheftError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::TheftError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'Must transfer a nonzero amount' - raise Steem::NonZeroRequiredError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::NonZeroRequiredError, "#{context}: #{error.message}", build_backtrace(error) end if error.message.include? 'is_asset_type' - raise Steem::UnexpectedAssetError, "#{context}: #{error.message}", build_backtrace(error) + raise Hive::UnexpectedAssetError, "#{context}: #{error.message}", build_backtrace(error) end puts JSON.pretty_generate(error) if ENV['DEBUG'] diff --git a/lib/steem/block_api.rb b/lib/hive/block_api.rb similarity index 93% rename from lib/steem/block_api.rb rename to lib/hive/block_api.rb index aae0725..b77e2b6 100644 --- a/lib/steem/block_api.rb +++ b/lib/hive/block_api.rb @@ -1,9 +1,9 @@ -module Steem +module Hive # {BlockApi} is used to query values related to the block plugin. It can also # be used to access a range of multiple blocks by using # {http://www.jsonrpc.org/specification#batch JSON-RPC 2.0 batch} requests. # - # Also see: {https://developers.steem.io/apidefinitions/block-api Block API Definitions} + # Also see: {https://developers.hive.io/apidefinitions/block-api.html Block API Definitions} class BlockApi < Api MAX_RANGE_SIZE = 50 @@ -34,7 +34,7 @@ module Steem block_range = options[:block_range] || (0..0) if (start = block_range.first) < 1 - raise Steem::ArgumentError, "Invalid starting block: #{start}" + raise Hive::ArgumentError, "Invalid starting block: #{start}" end chunks = if block_range.size > MAX_RANGE_SIZE diff --git a/lib/hive/bridge.rb b/lib/hive/bridge.rb new file mode 100644 index 0000000..6ce7a5a --- /dev/null +++ b/lib/hive/bridge.rb @@ -0,0 +1,12 @@ +module Hive + # {Bridge} is used to query values related to the communities. + # + # Also see: {https://developers.hive.io/apidefinitions/bridge.html Bridge Definitions} + class Bridge < Api + def initialize(options = {}) + self.class.api_name = :bridge + + super + end + end +end diff --git a/lib/steem/broadcast.rb b/lib/hive/broadcast.rb similarity index 87% rename from lib/steem/broadcast.rb rename to lib/hive/broadcast.rb index 3b809bd..0adcfbf 100644 --- a/lib/steem/broadcast.rb +++ b/lib/hive/broadcast.rb @@ -2,7 +2,7 @@ require 'bitcoin' require 'digest' require 'time' -module Steem +module Hive # These class methods make it simple to do things like broacast a {Broadcast#vote} # or {Broadcast#comment} operation. They accept all of the fields expected by @@ -19,7 +19,7 @@ module Steem # posting, active, and owner. # # Setting `url` will allow you to specify a different node instead of taking - # the default: ({ChainConfig::NETWORKS_STEEM_DEFAULT_NODE}). + # the default: ({ChainConfig::NETWORKS_HIVE_DEFAULT_NODE}). # # Setting `database_api`, `block_api`, and `network_broadcast_api` is # optional, doing so will allow you to override the default node and/or the @@ -28,7 +28,7 @@ module Steem # When passing the `pretend` field, if it is set to {::True}, nothing is # broadcasted, but the `wif` is checked for the proper authority. # - # For details on what to pass to these methods, check out the {https://developers.steem.io/apidefinitions/broadcast-ops Steem Developer Portal Broadcast Operations} page. + # For details on what to pass to these methods, check out the {https://developers.hive.io/apidefinitions/broadcast-ops.html Steem Developer Portal Broadcast Operations} page. class Broadcast extend Retriable extend Utils @@ -47,7 +47,7 @@ module Steem # } # } # - # Steem::Broadcast.vote(options) do |result| + # Hive::Broadcast.vote(options) do |result| # puts result # end # @@ -59,7 +59,7 @@ module Steem # * :permlink (String) # * :weight (Number) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_vote + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_vote def self.vote(options, &block) required_fields = %i(voter author permlink weight) params = options[:params] @@ -85,7 +85,7 @@ module Steem # } # } # - # Steem::Broadcast.comment(options) + # Hive::Broadcast.comment(options) # # options = { # wif: wif, @@ -105,7 +105,7 @@ module Steem # } # } # - # Steem::Broadcast.comment(options) + # Hive::Broadcast.comment(options) # # In addition to the above denormalized `comment_options` fields, the author # can also vote for the content in the same transaction by setting `author_vote_weight`: @@ -123,7 +123,7 @@ module Steem # } # } # - # Steem::Broadcast.comment(options) + # Hive::Broadcast.comment(options) # # @param options [Hash] options # @option options [String] :wif Posting wif @@ -136,25 +136,25 @@ module Steem # * :permlink (String) (automatic) Permlink of the content, defaults to formatted title. # * :parent_permlink (String) (automatic) Parent permlink of the content, defaults to first tag. # * :parent_author (String) (optional) Parent author of the content (only used if reply). - # * :max_accepted_payout (String) (1000000.000 SBD) Maximum accepted payout, set to '0.000 SBD' to deline payout - # * :percent_steem_dollars (Numeric) (5000) Percent STEEM Dollars is used to set 50/50 or 100% STEEM Power + # * :max_accepted_payout (String) (1000000.000 HBD) Maximum accepted payout, set to '0.000 HBD' to deline payout + # * :percent_steem_dollars (Numeric) (5000) Percent HIVE Dollars is used to set 50/50 or 100% HIVE Power # * :allow_votes (Numeric) (true) Allow votes for this content. # * :allow_curation_rewards (Numeric) (true) Allow curation rewards for this content. # * :beneficiaries (Array<Hash>) Sets the beneficiaries of this content. # * :author_vote_weight (Number) (optional) Cast a vote by the author in the same transaction. # * :pretend (Boolean) Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_comment + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_comment def self.comment(options, &block) required_fields = %i(author body permlink parent_permlink) params = options[:params] if !!params[:metadata] && !!params[:json_metadata] - raise Steem::ArgumentError, 'Assign either metadata or json_metadata, not both.' + raise Hive::ArgumentError, 'Assign either metadata or json_metadata, not both.' end metadata = params[:metadata] || {} metadata ||= (JSON[params[:json_metadata]] || nil) || {} - metadata['app'] ||= Steem::AGENT_ID + metadata['app'] ||= Hive::AGENT_ID tags = metadata['tags'] || [] params[:parent_permlink] ||= tags.first @@ -228,7 +228,7 @@ module Steem # Deletes a post/comment. # - # Steem::Broadcast.delete_comment(wif: wif, params: {author: author, permlink: permlink}) do |result| + # Hive::Broadcast.delete_comment(wif: wif, params: {author: author, permlink: permlink}) do |result| # puts result # end # @@ -238,7 +238,7 @@ module Steem # * :author (String) # * :permlink (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_delete_comment + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_delete_comment def self.delete_comment(options, &block) required_fields = %i(author permlink) params = options[:params] @@ -261,7 +261,7 @@ module Steem # } # } # - # Steem::Broadcast.transfer(options) do |result| + # Hive::Broadcast.transfer(options) do |result| # puts result # end # @@ -273,7 +273,7 @@ module Steem # * :amount (String) # * :memo (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_transfer + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_transfer def self.transfer(options, &block) required_fields = %i(from to amount memo) params = options[:params] @@ -286,7 +286,7 @@ module Steem process(options.merge(ops: ops), &block) end - # This operation converts STEEM into VFS (Vesting Fund Shares) at the + # This operation converts HIVE into VFS (Vesting Fund Shares) at the # current exchange rate. # # options = { @@ -298,7 +298,7 @@ module Steem # } # } # - # Steem::Broadcast.transfer_to_vesting(options) do |result| + # Hive::Broadcast.transfer_to_vesting(options) do |result| # puts result # end # @@ -309,7 +309,7 @@ module Steem # * :to (String) # * :amount (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_transfer_to_vesting + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_transfer_to_vesting def self.transfer_to_vesting(options, &block) required_fields = %i(from to amount) params = options[:params] @@ -325,7 +325,7 @@ module Steem # At any given point in time an account can be withdrawing from their # vesting shares. # - # Steem::Broadcast.withdraw_vesting(wif: wif, params: {account: account, vesting_shares: vesting_shares}) do |result| + # Hive::Broadcast.withdraw_vesting(wif: wif, params: {account: account, vesting_shares: vesting_shares}) do |result| # puts result # end # @@ -335,7 +335,7 @@ module Steem # * :account (String) # * :vesting_shares (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_withdraw_vesting + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_withdraw_vesting def self.withdraw_vesting(options, &block) required_fields = %i(account vesting_shares) params = options[:params] @@ -361,7 +361,7 @@ module Steem # * :fill_or_kill (Boolean) # * :expiration (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_limit_order_create + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_limit_order_create def self.limit_order_create(options, &block) required_fields = %i(owner orderid amount_to_sell min_to_receive fill_or_kill) @@ -389,7 +389,7 @@ module Steem # * :owner (String) # * :orderid (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_limit_order_cancel + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_limit_order_cancel def self.limit_order_cancel(options, &block) required_fields = %i(owner orderid) params = options[:params] @@ -401,7 +401,7 @@ module Steem end # Feeds can only be published by the top N witnesses which are included in - # every round and are used to define the exchange rate between steem and the + # every round and are used to define the exchange rate between hive and the # dollar. # # @param options [Hash] options @@ -410,7 +410,7 @@ module Steem # * :publisher (String) # * :exchange_rate (Hash) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_feed_publish + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_feed_publish def self.feed_publish(options, &block) required_fields = %i(publisher exchange_rate) params = options[:params] @@ -428,7 +428,7 @@ module Steem end # This operation instructs the blockchain to start a conversion between - # STEEM and SBD, the funds are deposited after 3.5 days. + # HIVE and HBD, the funds are deposited after 3.5 days. # # @param options [Hash] options # @option options [String] :wif Active wif @@ -437,7 +437,7 @@ module Steem # * :requestid (String) # * :amount (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_convert + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_convert def self.convert(options, &block) required_fields = %i(owner requestid amount) params = options[:params] @@ -454,7 +454,7 @@ module Steem # options = { # wif: wif, # params: { - # fee: '1.000 STEEM', + # fee: '1.000 HIVE', # creator: creator_account_name, # new_account_name: new_account_name, # owner: { @@ -477,7 +477,7 @@ module Steem # } # } # - # Steem::Broadcast.account_create(options) + # Hive::Broadcast.account_create(options) # # @param options [Hash] options # @option options [String] :wif Active wif @@ -492,13 +492,13 @@ module Steem # * :metadata (Hash) Metadata of the account, becomes `json_metadata`. # * :json_metadata (String) String version of `metadata` (use one or the other). # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_account_create + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_account_create def self.account_create(options, &block) required_fields = %i(fee creator new_account_name owner active posting memo_key json_metadata) params = options[:params] if !!params[:metadata] && !!params[:json_metadata] - raise Steem::ArgumentError, 'Assign either metadata or json_metadata, not both.' + raise Hive::ArgumentError, 'Assign either metadata or json_metadata, not both.' end metadata = params.delete(:metadata) || {} @@ -540,7 +540,7 @@ module Steem # } # } # - # Steem::Broadcast.create_claimed_account(options) + # Hive::Broadcast.create_claimed_account(options) # # @param options [Hash] options # @option options [String] :wif Active wif @@ -555,13 +555,13 @@ module Steem # * :json_metadata (String) String version of `metadata` (use one or the other). # * :extensions (Array) (optional) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_create_claimed_account + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_create_claimed_account def self.create_claimed_account(options, &block) required_fields = %i(creator new_account_name owner active posting memo_key json_metadata) params = options[:params] if !!params[:metadata] && !!params[:json_metadata] - raise Steem::ArgumentError, 'Assign either metadata or json_metadata, not both.' + raise Hive::ArgumentError, 'Assign either metadata or json_metadata, not both.' end metadata = params.delete(:metadata) || {} @@ -601,7 +601,7 @@ module Steem # } # } # - # Steem::Broadcast.account_update(options) + # Hive::Broadcast.account_update(options) # # @param options [Hash] options # @option options [String] :wif Active wif @@ -614,13 +614,13 @@ module Steem # * :metadata (Hash) Metadata of the account, becomes `json_metadata`. # * :json_metadata (String) String version of `metadata` (use one or the other). # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_account_update + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_account_update def self.account_update(options, &block) required_fields = %i(account) params = options[:params] if !!params[:metadata] && !!params[:json_metadata] - raise Steem::ArgumentError, 'Assign either metadata or json_metadata, not both.' + raise Hive::ArgumentError, 'Assign either metadata or json_metadata, not both.' end metadata = params.delete(:metadata) || {} @@ -644,15 +644,15 @@ module Steem # url: '', # block_signing_key: 'STM8ZSyzjPm48GmUuMSRufkVYkwYbZzbxeMysAVp7KFQwbTf98TcG', # props: { - # account_creation_fee: '0.000 STEEM', + # account_creation_fee: '0.000 HIVE', # maximum_block_size: 131072, # sbd_interest_rate:1000 # }, - # fee: '0.000 STEEM', + # fee: '0.000 HIVE', # } # } # - # Steem::Broadcast.witness_update(options) + # Hive::Broadcast.witness_update(options) # # @param options [Hash] options # @option options [String] :wif Active wif @@ -663,7 +663,7 @@ module Steem # * :props (String) # * :fee (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_witness_update + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_witness_update def self.witness_update(options, &block) required_fields = %i(owner block_signing_key props fee) params = options[:params] @@ -686,19 +686,19 @@ module Steem # params: { # owner: witness_account_name, # props: { - # account_creation_fee: '0.000 STEEM', + # account_creation_fee: '0.000 HIVE', # maximum_block_size: 131072, # sbd_interest_rate: 1000, # account_subsidy_budget: 50000, # account_subsidy_decay: 330782, - # sbd_exchange_rate: '1.000 STEEM', - # url: "https://steemit.com", + # sbd_exchange_rate: '1.000 HIVE', + # url: "https://hive.blog", # new_signing_key: 'STM8LoQjQqJHvotqBo7HjnqmUbFW9oJ2theyqonzUd9DdJ7YYHsvD' # } # } # } # - # Steem::Broadcast.witness_set_properties(options) + # Hive::Broadcast.witness_set_properties(options) # # @param options [Hash] options # @option options [String] :wif Active wif @@ -706,8 +706,8 @@ module Steem # * :owner (String) # * :props (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_witness_set_properties - # @see https://github.com/steemit/steem/blob/master/doc/witness_parameters.md + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_witness_set_properties + # @see https://github.com/openhive-network/hive/blob/master/doc/witness_parameters.md def self.witness_set_properties(options, &block) required_fields = %i(owner props) params = options[:params] @@ -755,7 +755,7 @@ module Steem # * :witness (String) # * :approve (Boolean) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_account_witness_vote + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_account_witness_vote def self.account_witness_vote(options, &block) required_fields = %i(account witness approve) params = options[:params] @@ -772,7 +772,7 @@ module Steem # * :account (String) # * :proxy (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_account_witness_proxy + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_account_witness_proxy def self.account_witness_proxy(options, &block) required_fields = %i(account proxy) params = options[:params] @@ -793,7 +793,7 @@ module Steem # * :id (String) # * :data (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_custom + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_custom def self.custom(options, &block) required_fields = %i(required_auths id data) params = options[:params] @@ -813,7 +813,7 @@ module Steem # * :id (String) # * :data (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_custom_binary + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_custom_binary def self.custom_binary(options, &block) required_fields = %i(id data) params = options[:params] @@ -836,13 +836,13 @@ module Steem # * :data (Hash) Data of the custom json, becomes `json`. # * :json (String) String version of `data` (use one or the other). # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_custom_json + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_custom_json def self.custom_json(options, &block) required_fields = %i(id) params = options[:params] if !!params[:data] && !!params[:json] - raise Steem::ArgumentError, 'Assign either data or json, not both.' + raise Hive::ArgumentError, 'Assign either data or json, not both.' end data = params.delete(:data) || {} @@ -870,7 +870,7 @@ module Steem # * :percent (Numeric) # * :auto_vest (Boolean) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_set_withdraw_vesting_route + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_set_withdraw_vesting_route def self.set_withdraw_vesting_route(options, &block) required_fields = %i(from_account to_account percent auto_vest) params = options[:params] @@ -891,7 +891,7 @@ module Steem # * :new_owner_authority (Hash) # * :extensions (Array) (optional) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_request_account_recovery + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_request_account_recovery def self.request_account_recovery(options, &block) required_fields = %i(recovery_account account_to_recover new_owner_authority) params = options[:params] @@ -911,7 +911,7 @@ module Steem # * :recent_owner_authority (Hash) # * :extensions (Array) (optional) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_recover_account + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_recover_account def self.recover_account(options, &block) required_fields = %i(account_to_recover new_owner_authority recent_owner_authority) params = options[:params] @@ -932,7 +932,7 @@ module Steem # * :new_recovery_account (String) # * :extensions (Array) (optional) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_change_recovery_account + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_change_recovery_account def self.change_recovery_account(options, &block) required_fields = %i(account_to_recover) params = options[:params] @@ -963,13 +963,13 @@ module Steem # * :meta (Hash) Meta of the escrow transfer, becomes `json_meta`. # * :json_meta (String) String version of `metadata` (use one or the other). # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_escrow_transfer + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_escrow_transfer def self.escrow_transfer(options, &block) required_fields = %i(from to agent escrow_id fee ratification_deadline) params = options[:params] if !!params[:meta] && !!params[:json_meta] - raise Steem::ArgumentError, 'Assign either meta or json_meta, not both.' + raise Hive::ArgumentError, 'Assign either meta or json_meta, not both.' end meta = params.delete(:meta) || {} @@ -1007,7 +1007,7 @@ module Steem # * :who (String) # * :escrow_id (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_escrow_dispute + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_escrow_dispute def self.escrow_dispute(options, &block) required_fields = %i(from to agent who escrow_id) params = options[:params] @@ -1033,7 +1033,7 @@ module Steem # * :sbd_amount (String) # * :steem_amount (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_escrow_release + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_escrow_release def self.escrow_release(options, &block) required_fields = %i(from to agent who receiver escrow_id) params = options[:params] @@ -1060,7 +1060,7 @@ module Steem # * :escrow_id (String) # * :approve (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_escrow_approve + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_escrow_approve def self.escrow_approve(options, &block) required_fields = %i(from to agent who escrow_id approve) params = options[:params] @@ -1081,7 +1081,7 @@ module Steem # * :amount (String) # * :memo (String) (optional) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_transfer_to_savings + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_transfer_to_savings def self.transfer_to_savings(options, &block) required_fields = %i(from to amount) params = options[:params] @@ -1104,7 +1104,7 @@ module Steem # * :amount (String) # * :memo (String) (optional) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_transfer_from_savings + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_transfer_from_savings def self.transfer_from_savings(options, &block) required_fields = %i(from request_id to amount) params = options[:params] @@ -1124,7 +1124,7 @@ module Steem # * :from (String) # * :request_id (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_cancel_transfer_from_savings + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_cancel_transfer_from_savings def self.cancel_transfer_from_savings(options, &block) required_fields = %i(from request_id) params = options[:params] @@ -1147,7 +1147,7 @@ module Steem # * :account (String) # * :decline (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_decline_voting_rights + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_decline_voting_rights def self.decline_voting_rights(options, &block) required_fields = %i(account decline) params = options[:params] @@ -1167,7 +1167,7 @@ module Steem # * :delegatee (String) # * :vesting_shares (String) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_delegate_vesting_shares + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_delegate_vesting_shares def self.delegate_vesting_shares(options, &block) required_fields = %i(delegator delegatee vesting_shares) params = options[:params] @@ -1194,13 +1194,13 @@ module Steem # * :json_metadata (String) String version of `metadata` (use one or the other). # * :extensions (Array) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_account_create_with_delegation + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_account_create_with_delegation def self.account_create_with_delegation(options, &block) required_fields = %i(fee delegation creator new_account_name owner active posting memo_key) params = options[:params] if !!params[:metadata] && !!params[:json_metadata] - raise Steem::ArgumentError, 'Assign either metadata or json_metadata, not both.' + raise Hive::ArgumentError, 'Assign either metadata or json_metadata, not both.' end metadata = params.delete(:metadata) || {} @@ -1225,7 +1225,7 @@ module Steem # * :fee (String) # * :extensions (Array) # @option options [Boolean] :pretend Just validate, do not broadcast. - # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_claim_account + # @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_claim_account def self.claim_account(options, &block) required_fields = %i(creator fee) params = options[:params] @@ -1302,18 +1302,18 @@ module Steem # @private def self.database_api(options) options[:database_api] ||= if !!options[:app_base] - Steem::DatabaseApi.new(options) + Hive::DatabaseApi.new(options) else - Steem::CondenserApi.new(options) + Hive::CondenserApi.new(options) end end # @private def self.network_broadcast_api(options) options[:network_broadcast_api] ||= if !!options[:app_base] - Steem::NetworkBroadcaseApi.new(options) + Hive::NetworkBroadcaseApi.new(options) else - Steem::CondenserApi.new(options) + Hive::CondenserApi.new(options) end end @@ -1322,11 +1322,11 @@ module Steem fields.each do |field| value = hash[field] - raise Steem::ArgumentError, "#{field}: required" if value.nil? + raise Hive::ArgumentError, "#{field}: required" if value.nil? case value when String, Array, Hash - raise Steem::ArgumentError, "#{field}: required" if value.empty? + raise Hive::ArgumentError, "#{field}: required" if value.empty? end end end diff --git a/lib/hive/chain_config.rb b/lib/hive/chain_config.rb new file mode 100644 index 0000000..a3b2f4a --- /dev/null +++ b/lib/hive/chain_config.rb @@ -0,0 +1,34 @@ +module Hive + module ChainConfig + EXPIRE_IN_SECS = 600 + EXPIRE_IN_SECS_PROPOSAL = 24 * 60 * 60 + + NETWORKS_HIVE_LEGACY_CHAIN_ID = '0000000000000000000000000000000000000000000000000000000000000000' + NETWORKS_HIVE_CHAIN_ID = 'beeab0de00000000000000000000000000000000000000000000000000000000' + NETWORKS_HIVE_ADDRESS_PREFIX = 'STM' + NETWORKS_HIVE_CORE_ASSET = ["0", 3, "@@000000021"] # HIVE + NETWORKS_HIVE_DEBT_ASSET = ["0", 3, "@@000000013"] # HBD + NETWORKS_HIVE_VEST_ASSET = ["0", 6, "@@000000037"] # VESTS + NETWORKS_HIVE_DEFAULT_NODE = 'https://api.openhive.network' + # NETWORKS_HIVE_DEFAULT_NODE = 'https://anyx.io' + # NETWORKS_HIVE_DEFAULT_NODE = 'http://anyx.io' + # NETWORKS_HIVE_DEFAULT_NODE = 'https://api.hivekings.com' + # NETWORKS_HIVE_DEFAULT_NODE = 'https://api.hive.blog' + # NETWORKS_HIVE_DEFAULT_NODE = 'https://api.openhive.network' + # NETWORKS_HIVE_DEFAULT_NODE = 'https://techcoderx.com' + # NETWORKS_HIVE_DEFAULT_NODE = 'https://rpc.esteem.app' + # NETWORKS_HIVE_DEFAULT_NODE = 'https://hived.privex.io' + # NETWORKS_HIVE_DEFAULT_NODE = 'https://api.pharesim.me' + # NETWORKS_HIVE_DEFAULT_NODE = 'https://rpc.ausbit.dev' + + NETWORKS_TEST_CHAIN_ID = '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32' + NETWORKS_TEST_ADDRESS_PREFIX = 'TST' + NETWORKS_TEST_CORE_ASSET = ["0", 3, "@@000000021"] # TESTS + NETWORKS_TEST_DEBT_ASSET = ["0", 3, "@@000000013"] # TBD + NETWORKS_TEST_VEST_ASSET = ["0", 6, "@@000000037"] # VESTS + NETWORKS_TEST_DEFAULT_NODE = 'https://testnet-api.openhive.network' + # NETWORKS_TEST_DEFAULT_NODE = 'https://hive-test-beeabode.roelandp.nl' + + NETWORK_CHAIN_IDS = [NETWORKS_HIVE_CHAIN_ID, NETWORKS_TEST_CHAIN_ID] + end +end diff --git a/lib/hive/fallback.rb b/lib/hive/fallback.rb new file mode 100644 index 0000000..e17ff11 --- /dev/null +++ b/lib/hive/fallback.rb @@ -0,0 +1,287 @@ +module Hive::Fallback + API_METHODS = { + account_by_key_api: [ + :get_key_references + ], + block_api: [ + :get_block, + :get_block_header + ], + condenser_api: [ + :broadcast_block, + :broadcast_transaction, + :broadcast_transaction_synchronous, + :get_account_count, + :get_account_history, + :get_account_references, + :get_account_reputations, + :get_account_votes, + :get_accounts, + :get_active_votes, + :get_active_witnesses, + :get_block, + :get_block_header, + :get_blog, + :get_blog_authors, + :get_blog_entries, + :get_chain_properties, + :get_comment_discussions_by_payout, + :get_config, + :get_content, + :get_content_replies, + :get_conversion_requests, + :get_current_median_history_price, + :get_discussions_by_active, + :get_discussions_by_author_before_date, + :get_discussions_by_blog, + :get_discussions_by_cashout, + :get_discussions_by_children, + :get_discussions_by_comments, + :get_discussions_by_created, + :get_discussions_by_feed, + :get_discussions_by_hot, + :get_discussions_by_promoted, + :get_discussions_by_trending, + :get_discussions_by_votes, + :get_dynamic_global_properties, + :get_escrow, + :get_expiring_vesting_delegations, + :get_feed, + :get_feed_entries, + :get_feed_history, + :get_follow_count, + :get_followers, + :get_following, + :get_hardfork_version, + :get_key_references, + :get_market_history, + :get_market_history_buckets, + :get_next_scheduled_hardfork, + :get_open_orders, + :get_ops_in_block, + :get_order_book, + :get_owner_history, + :get_post_discussions_by_payout, + :get_potential_signatures, + :get_reblogged_by, + :get_recent_trades, + :get_recovery_request, + :get_replies_by_last_update, + :get_required_signatures, + :get_reward_fund, + :get_savings_withdraw_from, + :get_savings_withdraw_to, + :get_state, + :get_tags_used_by_author, + :get_ticker, + :get_trade_history, + :get_transaction, + :get_transaction_hex, + :get_trending_tags, + :get_version, + :get_vesting_delegations, + :get_volume, + :get_withdraw_routes, + :get_witness_by_account, + :get_witness_count, + :get_witness_schedule, + :get_witnesses, + :get_witnesses_by_vote, + :lookup_account_names, + :lookup_accounts, + :lookup_witness_accounts, + :verify_account_authority, + :verify_authority, + :find_proposals, + :list_proposal_votes, + :list_proposals + ], + database_api: [ + :find_account_recovery_requests, + :find_accounts, + :find_change_recovery_account_requests, + :find_comments, + :find_decline_voting_rights_requests, + :find_escrows, + :find_limit_orders, + :find_owner_histories, + :find_savings_withdrawals, + :find_sbd_conversion_requests, + :find_vesting_delegation_expirations, + :find_vesting_delegations, + :find_votes, + :find_withdraw_vesting_routes, + :find_witnesses, + :get_active_witnesses, + :get_config, + :get_current_price_feed, + :get_dynamic_global_properties, + :get_feed_history, + :get_hardfork_properties, + :get_order_book, + :get_potential_signatures, + :get_required_signatures, + :get_reward_funds, + :get_transaction_hex, + :get_version, + :get_witness_schedule, + :list_account_recovery_requests, + :list_accounts, + :list_change_recovery_account_requests, + :list_comments, + :list_decline_voting_rights_requests, + :list_escrows, + :list_limit_orders, + :list_owner_histories, + :list_savings_withdrawals, + :list_sbd_conversion_requests, + :list_vesting_delegation_expirations, + :list_vesting_delegations, + :list_votes, + :list_withdraw_vesting_routes, + :list_witness_votes, + :list_witnesses, + :verify_account_authority, + :verify_authority, + :verify_signatures, + :find_proposals, + :list_proposal_votes, + :list_proposals + ], + follow_api: [ + :get_account_reputations, + :get_blog, + :get_blog_authors, + :get_blog_entries, + :get_feed, + :get_feed_entries, + :get_follow_count, + :get_followers, + :get_following, + :get_reblogged_by + ], + jsonrpc: [ + :get_methods, + :get_signature + ], + market_history_api: [ + :get_market_history, + :get_market_history_buckets, + :get_order_book, + :get_recent_trades, + :get_ticker, + :get_trade_history, + :get_volume + ], + network_broadcast_api: [ + :broadcast_block, + :broadcast_transaction + ], + rc_api: [ + :find_rc_accounts, + :get_resource_params, + :get_resource_pool + ], + tags_api: [ + :get_active_votes, + :get_comment_discussions_by_payout, + :get_content_replies, + :get_discussion, + :get_discussions_by_active, + :get_discussions_by_author_before_date, + :get_discussions_by_blog, + :get_discussions_by_cashout, + :get_discussions_by_children, + :get_discussions_by_comments, + :get_discussions_by_created, + :get_discussions_by_feed, + :get_discussions_by_hot, + :get_discussions_by_promoted, + :get_discussions_by_trending, + :get_discussions_by_votes, + :get_post_discussions_by_payout, + :get_replies_by_last_update, + :get_tags_used_by_author, + :get_trending_tags + ], + reputation_api: [ + :get_account_reputations + ], + bridge: [ + :account_notifications, + :get_community, + :get_ranked_posts, + :list_all_subscriptions, + :list_community_roles, + ] + } + + API_METHOD_SIGNATURES = { + database_api: { + find_account_recovery_requests: {accounts: []}, + find_accounts: {accounts: []}, + find_change_recovery_account_requests: {accounts: []}, + find_comments: {comments: []}, + find_decline_voting_rights_requests: {accounts: []}, + find_escrows: {from: String}, + find_limit_orders: {account: String}, + find_owner_histories: {owner: String}, + find_proposals: {proposal_ids: []}, + find_savings_withdrawals: {account: String}, + find_sbd_conversion_requests: {account: String}, + find_vesting_delegation_expirations: {account: String}, + find_vesting_delegations: {account: String}, + find_votes: {author: String, permlink: String}, + find_withdraw_vesting_routes: {account: String, order: String}, + find_witnesses: {owners: []}, + get_active_witnesses: {}, + get_config: {}, + get_current_price_feed: {}, + get_dynamic_global_properties: {}, + get_feed_history: {}, + get_hardfork_properties: {}, + get_order_book: {limit: Integer}, + get_potential_signatures: {trx: {}}, + get_required_signatures: {trx: {}, available_keys: []}, + get_reward_funds: {}, + get_transaction_hex: {trx: {}}, + get_version: {}, + get_witness_schedule: {}, + list_account_recovery_requests: {start: NilClass, limit: Integer, order: String}, + list_accounts: {start: NilClass, limit: Integer, order: String}, + list_change_recovery_account_requests: {start: NilClass, limit: Integer, order: String}, + list_comments: {start: NilClass, limit: Integer, order: String}, + list_decline_voting_rights_requests: {start: NilClass, limit: Integer, order: String}, + list_escrows: {start: NilClass, limit: Integer, order: String}, + list_limit_orders: {start: NilClass, limit: Integer, order: String}, + list_owner_histories: {start: NilClass, limit: Integer}, + list_proposal_votes: {start: NilClass, limit: Integer, order: String, order_direction: String, status: String}, + list_proposals: {start: NilClass, limit: Integer, order: String, order_direction: String, status: String}, + list_savings_withdrawals: {start: NilClass, limit: Integer, order: String}, + list_sbd_conversion_requests: {start: NilClass, limit: Integer, order: String}, + list_vesting_delegation_expirations: {start: NilClass, limit: Integer, order: String}, + list_vesting_delegations: {start: NilClass, limit: Integer, order: String}, + list_votes: {start: NilClass, limit: Integer, order: String}, + list_withdraw_vesting_routes: {start: NilClass, limit: Integer, order: String}, + list_witness_votes: {start: NilClass, limit: Integer, order: String}, + list_witnesses: {start: NilClass, limit: Integer, order: String}, + verify_account_authority: {account: String, signers: []}, + verify_authority: {trx: {}}, + verify_signatures: {hash: String, signatures: [], required_owner: [], required_active: [], required_posting: [], required_other: []} + }, + jsonrpc: { + get_methods: {}, + get_signature: {method: String} + }, + reputation_api: { + get_account_reputations: {account_lower_bound: String, limit: Integer} + }, + bridge: { + account_notifications: {account: String, limit: Integer}, + get_community: {name: String, observer: String}, + get_ranked_posts: {sort: String, tag: String, observer: String, limit: Integer}, + list_all_subscriptions: {account: String}, + list_community_roles: {community: String} + } + } +end diff --git a/lib/steem/formatter.rb b/lib/hive/formatter.rb similarity index 95% rename from lib/steem/formatter.rb rename to lib/hive/formatter.rb index 5af3eb2..c83b52c 100644 --- a/lib/steem/formatter.rb +++ b/lib/hive/formatter.rb @@ -1,4 +1,4 @@ -module Steem +module Hive class Formatter def self.reputation(raw) raw = raw.to_i diff --git a/lib/steem/jsonrpc.rb b/lib/hive/jsonrpc.rb similarity index 89% rename from lib/steem/jsonrpc.rb rename to lib/hive/jsonrpc.rb index 8db0a28..f35c014 100644 --- a/lib/steem/jsonrpc.rb +++ b/lib/hive/jsonrpc.rb @@ -1,4 +1,4 @@ -module Steem +module Hive # {Jsonrpc} allows you to inspect the available methods offered by a node. # If a node runs a plugin you want, then all of the API methods it can exposes # will automatically be available. This API is used internally to determine @@ -9,6 +9,10 @@ module Steem class Jsonrpc < Api API_METHODS = %i(get_signature get_methods) + # APIs that the RPC server will (or likely will) respond to that is + # maintained outside the view of jsonrpc. + UNLISTED_APIS = %i(bridge) + def self.api_methods @api_methods ||= {} end @@ -79,8 +83,8 @@ module Steem end end - chunks = if request_object.size > Steem::RPC::HttpClient::JSON_RPC_BATCH_SIZE_MAXIMUM - request_object.each_slice(Steem::RPC::HttpClient::JSON_RPC_BATCH_SIZE_MAXIMUM) + chunks = if request_object.size > Hive::RPC::HttpClient::JSON_RPC_BATCH_SIZE_MAXIMUM + request_object.each_slice(Hive::RPC::HttpClient::JSON_RPC_BATCH_SIZE_MAXIMUM) else request_object end diff --git a/lib/steem/marshal.rb b/lib/hive/marshal.rb similarity index 92% rename from lib/steem/marshal.rb rename to lib/hive/marshal.rb index 93e4b58..b130eb0 100644 --- a/lib/steem/marshal.rb +++ b/lib/hive/marshal.rb @@ -1,7 +1,7 @@ require 'bindata' require 'base58' -module Steem +module Hive class Marshal include Utils include ChainConfig @@ -17,9 +17,9 @@ module Steem options[:bytes] end - @chain = options[:chain] || :steem + @chain = options[:chain] || :hive @prefix ||= case @chain - when :steem then NETWORKS_STEEM_ADDRESS_PREFIX + when :hive then NETWORKS_HIVE_ADDRESS_PREFIX when :test then NETWORKS_TEST_ADDRESS_PREFIX else; raise UnsupportedChainError, "Unsupported chain: #{@chain}" end @@ -105,7 +105,7 @@ module Steem amount = "%.#{precision}f #{asset}" % (amount / 10 ** precision) - Steem::Type::Amount.new(amount) + Hive::Type::Amount.new(amount) end def price @@ -158,14 +158,14 @@ module Steem varint.times do key = string.to_sym properties[key] = case key - when :account_creation_fee then Steem::Type::Amount.new(string) + when :account_creation_fee then Hive::Type::Amount.new(string) when :account_subsidy_budget then scan(3) when :account_subsidy_decay, :maximum_block_size then uint32 when :url then string when :sbd_exchange_rate JSON[string].tap do |rate| - rate["base"] = Steem::Type::Amount.new(rate["base"]) - rate["quote"] = Steem::Type::Amount.new(rate["quote"]) + rate["base"] = Hive::Type::Amount.new(rate["base"]) + rate["quote"] = Hive::Type::Amount.new(rate["quote"]) end when :sbd_interest_rate then uint16 when :key, :new_signing_key then @prefix + scan(50) @@ -204,7 +204,7 @@ module Steem break if type.nil? op_class_name = type.to_s.sub!(/_operation$/, '') - op_class_name = "Steem::Operation::" + op_class_name.split('_').map(&:capitalize).join + op_class_name = "Hive::Operation::" + op_class_name.split('_').map(&:capitalize).join op_class = Object::const_get(op_class_name) op = op_class.new diff --git a/lib/steem/mixins/jsonable.rb b/lib/hive/mixins/jsonable.rb similarity index 98% rename from lib/steem/mixins/jsonable.rb rename to lib/hive/mixins/jsonable.rb index 5c8f6a7..fb7cb5f 100644 --- a/lib/steem/mixins/jsonable.rb +++ b/lib/hive/mixins/jsonable.rb @@ -1,4 +1,4 @@ -module Steem +module Hive module JSONable module ClassMethods attr_accessor :attributes diff --git a/lib/steem/mixins/retriable.rb b/lib/hive/mixins/retriable.rb similarity index 98% rename from lib/steem/mixins/retriable.rb rename to lib/hive/mixins/retriable.rb index b918488..5983c07 100644 --- a/lib/steem/mixins/retriable.rb +++ b/lib/hive/mixins/retriable.rb @@ -1,4 +1,4 @@ -module Steem +module Hive module Retriable # @private MAX_RETRY_COUNT = 30 diff --git a/lib/steem/mixins/serializable.rb b/lib/hive/mixins/serializable.rb similarity index 98% rename from lib/steem/mixins/serializable.rb rename to lib/hive/mixins/serializable.rb index 4bb256a..035314e 100644 --- a/lib/steem/mixins/serializable.rb +++ b/lib/hive/mixins/serializable.rb @@ -1,4 +1,4 @@ -module Steem +module Hive module Serializable NUMERIC_TYPES = %i(unsigned_char uint16 uint32 uint64 signed_char int16 int32 int64 varint) diff --git a/lib/steem/operation.rb b/lib/hive/operation.rb similarity index 95% rename from lib/steem/operation.rb rename to lib/hive/operation.rb index 575c613..4f7b851 100644 --- a/lib/steem/operation.rb +++ b/lib/hive/operation.rb @@ -1,11 +1,11 @@ -module Steem +module Hive class Operation include JSONable include Serializable include Utils # IDs derrived from: - # https://github.com/steemit/steem/blob/127a441fbac2f06804359968bda83b66e602c891/libraries/protocol/include/steem/protocol/operations.hpp + # https://github.com/openhive-network/hive/blob/127a441fbac2f06804359968bda83b66e602c891/libraries/protocol/include/steem/protocol/operations.hpp IDS = [ :vote_operation, diff --git a/lib/steem/operation/account_create.rb b/lib/hive/operation/account_create.rb similarity index 81% rename from lib/steem/operation/account_create.rb rename to lib/hive/operation/account_create.rb index d69a8eb..02d8be8 100644 --- a/lib/steem/operation/account_create.rb +++ b/lib/hive/operation/account_create.rb @@ -1,4 +1,4 @@ -class Steem::Operation::AccountCreate < Steem::Operation +class Hive::Operation::AccountCreate < Hive::Operation def_attr fee: :amount def_attr creator: :string def_attr new_account_name: :string diff --git a/lib/steem/operation/account_create_with_delegation.rb b/lib/hive/operation/account_create_with_delegation.rb similarity index 81% rename from lib/steem/operation/account_create_with_delegation.rb rename to lib/hive/operation/account_create_with_delegation.rb index 995c54c..ff6586d 100644 --- a/lib/steem/operation/account_create_with_delegation.rb +++ b/lib/hive/operation/account_create_with_delegation.rb @@ -1,4 +1,4 @@ -class Steem::Operation::AccountCreateWithDelegation < Steem::Operation +class Hive::Operation::AccountCreateWithDelegation < Hive::Operation def_attr fee: :amount def_attr delegation: :amount def_attr creator: :string diff --git a/lib/steem/operation/account_update.rb b/lib/hive/operation/account_update.rb similarity index 79% rename from lib/steem/operation/account_update.rb rename to lib/hive/operation/account_update.rb index fe6ab87..b82f6d2 100644 --- a/lib/steem/operation/account_update.rb +++ b/lib/hive/operation/account_update.rb @@ -1,4 +1,4 @@ -class Steem::Operation::AccountUpdate < Steem::Operation +class Hive::Operation::AccountUpdate < Hive::Operation def_attr account: :string def_attr owner: :optional_authority def_attr active: :optional_authority diff --git a/lib/hive/operation/account_witness_proxy.rb b/lib/hive/operation/account_witness_proxy.rb new file mode 100644 index 0000000..7771319 --- /dev/null +++ b/lib/hive/operation/account_witness_proxy.rb @@ -0,0 +1,4 @@ +class Hive::Operation::AccountWitnessProxy < Hive::Operation + def_attr account: :string + def_attr proxy: :string +end diff --git a/lib/steem/operation/account_witness_vote.rb b/lib/hive/operation/account_witness_vote.rb similarity index 58% rename from lib/steem/operation/account_witness_vote.rb rename to lib/hive/operation/account_witness_vote.rb index 799ef58..bc0e27c 100644 --- a/lib/steem/operation/account_witness_vote.rb +++ b/lib/hive/operation/account_witness_vote.rb @@ -1,4 +1,4 @@ -class Steem::Operation::AccountWitnessVote < Steem::Operation +class Hive::Operation::AccountWitnessVote < Hive::Operation def_attr account: :string def_attr witness: :string def_attr approve: :boolean diff --git a/lib/hive/operation/cancel_transfer_from_savings.rb b/lib/hive/operation/cancel_transfer_from_savings.rb new file mode 100644 index 0000000..1388bf3 --- /dev/null +++ b/lib/hive/operation/cancel_transfer_from_savings.rb @@ -0,0 +1,4 @@ +class Hive::Operation::CancelTransferFromSavings < Hive::Operation + def_attr from: :string + def_attr request_id: :uint32 +end diff --git a/lib/steem/operation/challenge_authority.rb b/lib/hive/operation/challenge_authority.rb similarity index 61% rename from lib/steem/operation/challenge_authority.rb rename to lib/hive/operation/challenge_authority.rb index 53f685e..929b531 100644 --- a/lib/steem/operation/challenge_authority.rb +++ b/lib/hive/operation/challenge_authority.rb @@ -1,4 +1,4 @@ -class Steem::Operation::ChallengeAuthority < Steem::Operation +class Hive::Operation::ChallengeAuthority < Hive::Operation def_attr challenger: :string def_attr challenged: :string def_attr require_owner: :boolean diff --git a/lib/steem/operation/change_recovery_account.rb b/lib/hive/operation/change_recovery_account.rb similarity index 64% rename from lib/steem/operation/change_recovery_account.rb rename to lib/hive/operation/change_recovery_account.rb index 1d9f924..eb80cb6 100644 --- a/lib/steem/operation/change_recovery_account.rb +++ b/lib/hive/operation/change_recovery_account.rb @@ -1,4 +1,4 @@ -class Steem::Operation::ChangeRecoveryAccount < Steem::Operation +class Hive::Operation::ChangeRecoveryAccount < Hive::Operation def_attr account_to_recover: :string def_attr new_recovery_account: :string def_attr extensions: :empty_array diff --git a/lib/steem/operation/claim_account.rb b/lib/hive/operation/claim_account.rb similarity index 62% rename from lib/steem/operation/claim_account.rb rename to lib/hive/operation/claim_account.rb index f36032b..5ee6848 100644 --- a/lib/steem/operation/claim_account.rb +++ b/lib/hive/operation/claim_account.rb @@ -1,4 +1,4 @@ -class Steem::Operation::ClaimAccount < Steem::Operation +class Hive::Operation::ClaimAccount < Hive::Operation def_attr creator: :string def_attr fee: :amount def_attr extensions: :empty_array diff --git a/lib/steem/operation/claim_reward_balance.rb b/lib/hive/operation/claim_reward_balance.rb similarity index 67% rename from lib/steem/operation/claim_reward_balance.rb rename to lib/hive/operation/claim_reward_balance.rb index 55a1e88..393a38c 100644 --- a/lib/steem/operation/claim_reward_balance.rb +++ b/lib/hive/operation/claim_reward_balance.rb @@ -1,4 +1,4 @@ -class Steem::Operation::ClaimRewardBalance < Steem::Operation +class Hive::Operation::ClaimRewardBalance < Hive::Operation def_attr account: :string def_attr reward_steem: :amount def_attr reward_sbd: :amount diff --git a/lib/steem/operation/comment.rb b/lib/hive/operation/comment.rb similarity index 80% rename from lib/steem/operation/comment.rb rename to lib/hive/operation/comment.rb index fdb203f..7b3ea67 100644 --- a/lib/steem/operation/comment.rb +++ b/lib/hive/operation/comment.rb @@ -1,4 +1,4 @@ -class Steem::Operation::Comment < Steem::Operation +class Hive::Operation::Comment < Hive::Operation def_attr parent_author: :string def_attr parent_permlink: :string def_attr author: :string diff --git a/lib/steem/operation/comment_options.rb b/lib/hive/operation/comment_options.rb similarity index 84% rename from lib/steem/operation/comment_options.rb rename to lib/hive/operation/comment_options.rb index 4864113..855ad63 100644 --- a/lib/steem/operation/comment_options.rb +++ b/lib/hive/operation/comment_options.rb @@ -1,4 +1,4 @@ -class Steem::Operation::CommentOptions < Steem::Operation +class Hive::Operation::CommentOptions < Hive::Operation def_attr author: :string def_attr permlink: :string def_attr max_accepted_payout: :amount diff --git a/lib/steem/operation/convert.rb b/lib/hive/operation/convert.rb similarity index 63% rename from lib/steem/operation/convert.rb rename to lib/hive/operation/convert.rb index 80d971a..143c0b7 100644 --- a/lib/steem/operation/convert.rb +++ b/lib/hive/operation/convert.rb @@ -1,4 +1,4 @@ -class Steem::Operation::Convert < Steem::Operation +class Hive::Operation::Convert < Hive::Operation def_attr owner: :string def_attr requestid: :uint32 def_attr amount: :amount diff --git a/lib/steem/operation/create_claimed_account.rb b/lib/hive/operation/create_claimed_account.rb similarity index 80% rename from lib/steem/operation/create_claimed_account.rb rename to lib/hive/operation/create_claimed_account.rb index 5f5b956..46739a1 100644 --- a/lib/steem/operation/create_claimed_account.rb +++ b/lib/hive/operation/create_claimed_account.rb @@ -1,4 +1,4 @@ -class Steem::Operation::CreateClaimedAccount < Steem::Operation +class Hive::Operation::CreateClaimedAccount < Hive::Operation def_attr creator: :string def_attr new_account_name: :string def_attr owner: :authority diff --git a/lib/steem/operation/custom.rb b/lib/hive/operation/custom.rb similarity index 66% rename from lib/steem/operation/custom.rb rename to lib/hive/operation/custom.rb index ed6ede4..f345ae5 100644 --- a/lib/steem/operation/custom.rb +++ b/lib/hive/operation/custom.rb @@ -1,4 +1,4 @@ -class Steem::Operation::Custom < Steem::Operation +class Hive::Operation::Custom < Hive::Operation def_attr required_auths: :required_auths def_attr id: :uint32 def_attr data: :raw_bytes diff --git a/lib/steem/operation/custom_binary.rb b/lib/hive/operation/custom_binary.rb similarity index 81% rename from lib/steem/operation/custom_binary.rb rename to lib/hive/operation/custom_binary.rb index 1b19edd..eef124b 100644 --- a/lib/steem/operation/custom_binary.rb +++ b/lib/hive/operation/custom_binary.rb @@ -1,4 +1,4 @@ -class Steem::Operation::CustomBinary < Steem::Operation +class Hive::Operation::CustomBinary < Hive::Operation def_attr required_owner_auths: :required_auths def_attr required_active_auths: :required_auths def_attr required_posting_auths: :required_auths diff --git a/lib/steem/operation/custom_json.rb b/lib/hive/operation/custom_json.rb similarity index 73% rename from lib/steem/operation/custom_json.rb rename to lib/hive/operation/custom_json.rb index c564e7d..e960074 100644 --- a/lib/steem/operation/custom_json.rb +++ b/lib/hive/operation/custom_json.rb @@ -1,4 +1,4 @@ -class Steem::Operation::CustomJson < Steem::Operation +class Hive::Operation::CustomJson < Hive::Operation def_attr required_auths: :required_auths def_attr required_posting_auths: :required_auths def_attr id: :string diff --git a/lib/hive/operation/decline_voting_rights.rb b/lib/hive/operation/decline_voting_rights.rb new file mode 100644 index 0000000..c607ab6 --- /dev/null +++ b/lib/hive/operation/decline_voting_rights.rb @@ -0,0 +1,4 @@ +class Hive::Operation::DeclineVotingRights < Hive::Operation + def_attr account: :string + def_attr decline: :boolean +end diff --git a/lib/steem/operation/delegate_vesting_shares.rb b/lib/hive/operation/delegate_vesting_shares.rb similarity index 60% rename from lib/steem/operation/delegate_vesting_shares.rb rename to lib/hive/operation/delegate_vesting_shares.rb index 73b9740..49471f2 100644 --- a/lib/steem/operation/delegate_vesting_shares.rb +++ b/lib/hive/operation/delegate_vesting_shares.rb @@ -1,4 +1,4 @@ -class Steem::Operation::DelegateVestingShares < Steem::Operation +class Hive::Operation::DelegateVestingShares < Hive::Operation def_attr delegator: :string def_attr delegatee: :string def_attr vesting_shares: :amount diff --git a/lib/steem/operation/delete_comment.rb b/lib/hive/operation/delete_comment.rb similarity index 51% rename from lib/steem/operation/delete_comment.rb rename to lib/hive/operation/delete_comment.rb index 638bc58..9ccb104 100644 --- a/lib/steem/operation/delete_comment.rb +++ b/lib/hive/operation/delete_comment.rb @@ -1,4 +1,4 @@ -class Steem::Operation::DeleteComment < Steem::Operation +class Hive::Operation::DeleteComment < Hive::Operation def_attr author: :string def_attr permlink: :string end diff --git a/lib/steem/operation/escrow_approve.rb b/lib/hive/operation/escrow_approve.rb similarity index 73% rename from lib/steem/operation/escrow_approve.rb rename to lib/hive/operation/escrow_approve.rb index 9922a9b..d8995c0 100644 --- a/lib/steem/operation/escrow_approve.rb +++ b/lib/hive/operation/escrow_approve.rb @@ -1,4 +1,4 @@ -class Steem::Operation::EscrowApprove < Steem::Operation +class Hive::Operation::EscrowApprove < Hive::Operation def_attr from: :string def_attr to: :string def_attr agent: :string diff --git a/lib/steem/operation/escrow_dispute.rb b/lib/hive/operation/escrow_dispute.rb similarity index 69% rename from lib/steem/operation/escrow_dispute.rb rename to lib/hive/operation/escrow_dispute.rb index e4b748f..8827da7 100644 --- a/lib/steem/operation/escrow_dispute.rb +++ b/lib/hive/operation/escrow_dispute.rb @@ -1,4 +1,4 @@ -class Steem::Operation::EscrowDispute < Steem::Operation +class Hive::Operation::EscrowDispute < Hive::Operation def_attr from: :string def_attr to: :string def_attr agent: :string diff --git a/lib/steem/operation/escrow_release.rb b/lib/hive/operation/escrow_release.rb similarity index 79% rename from lib/steem/operation/escrow_release.rb rename to lib/hive/operation/escrow_release.rb index 4fb4769..631de8e 100644 --- a/lib/steem/operation/escrow_release.rb +++ b/lib/hive/operation/escrow_release.rb @@ -1,4 +1,4 @@ -class Steem::Operation::EscrowRelease < Steem::Operation +class Hive::Operation::EscrowRelease < Hive::Operation def_attr from: :string def_attr to: :string def_attr agent: :string diff --git a/lib/steem/operation/escrow_transfer.rb b/lib/hive/operation/escrow_transfer.rb similarity index 84% rename from lib/steem/operation/escrow_transfer.rb rename to lib/hive/operation/escrow_transfer.rb index e715550..2feb3d3 100644 --- a/lib/steem/operation/escrow_transfer.rb +++ b/lib/hive/operation/escrow_transfer.rb @@ -1,4 +1,4 @@ -class Steem::Operation::EscrowTransfer < Steem::Operation +class Hive::Operation::EscrowTransfer < Hive::Operation def_attr from: :string def_attr to: :string def_attr sbd_amount: :amount diff --git a/lib/steem/operation/feed_publish.rb b/lib/hive/operation/feed_publish.rb similarity index 54% rename from lib/steem/operation/feed_publish.rb rename to lib/hive/operation/feed_publish.rb index c6680e6..d4baeae 100644 --- a/lib/steem/operation/feed_publish.rb +++ b/lib/hive/operation/feed_publish.rb @@ -1,4 +1,4 @@ -class Steem::Operation::FeedPublish < Steem::Operation +class Hive::Operation::FeedPublish < Hive::Operation def_attr publisher: :string def_attr exchange_rate: :price end diff --git a/lib/hive/operation/limit_order_cancel.rb b/lib/hive/operation/limit_order_cancel.rb new file mode 100644 index 0000000..06a84c6 --- /dev/null +++ b/lib/hive/operation/limit_order_cancel.rb @@ -0,0 +1,4 @@ +class Hive::Operation::LimitOrderCancel < Hive::Operation + def_attr owner: :string + def_attr orderid: :uint32 +end diff --git a/lib/steem/operation/limit_order_create.rb b/lib/hive/operation/limit_order_create.rb similarity index 76% rename from lib/steem/operation/limit_order_create.rb rename to lib/hive/operation/limit_order_create.rb index 1041b53..95333e5 100644 --- a/lib/steem/operation/limit_order_create.rb +++ b/lib/hive/operation/limit_order_create.rb @@ -1,4 +1,4 @@ -class Steem::Operation::LimitOrderCreate < Steem::Operation +class Hive::Operation::LimitOrderCreate < Hive::Operation def_attr owner: :string def_attr orderid: :uint32 def_attr amount_to_sell: :amount diff --git a/lib/steem/operation/limit_order_create2.rb b/lib/hive/operation/limit_order_create2.rb similarity index 76% rename from lib/steem/operation/limit_order_create2.rb rename to lib/hive/operation/limit_order_create2.rb index 7801f18..3d84aed 100644 --- a/lib/steem/operation/limit_order_create2.rb +++ b/lib/hive/operation/limit_order_create2.rb @@ -1,4 +1,4 @@ -class Steem::Operation::LimitOrderCreate2 < Steem::Operation +class Hive::Operation::LimitOrderCreate2 < Hive::Operation def_attr owner: :string def_attr orderid: :uint32 def_attr amount_to_sell: :amount diff --git a/lib/steem/operation/prove_authority.rb b/lib/hive/operation/prove_authority.rb similarity index 54% rename from lib/steem/operation/prove_authority.rb rename to lib/hive/operation/prove_authority.rb index 1b5e18e..b7a18f8 100644 --- a/lib/steem/operation/prove_authority.rb +++ b/lib/hive/operation/prove_authority.rb @@ -1,4 +1,4 @@ -class Steem::Operation::ProveAuthority < Steem::Operation +class Hive::Operation::ProveAuthority < Hive::Operation def_attr challenged: :string def_attr require_owner: :boolean end diff --git a/lib/steem/operation/recover_account.rb b/lib/hive/operation/recover_account.rb similarity index 74% rename from lib/steem/operation/recover_account.rb rename to lib/hive/operation/recover_account.rb index 6da4218..f87ff86 100644 --- a/lib/steem/operation/recover_account.rb +++ b/lib/hive/operation/recover_account.rb @@ -1,4 +1,4 @@ -class Steem::Operation::RecoverAccount < Steem::Operation +class Hive::Operation::RecoverAccount < Hive::Operation def_attr account_to_recover: :string def_attr new_owner_authority: :authority def_attr recent_owner_authority: :authority diff --git a/lib/steem/operation/report_over_production.rb b/lib/hive/operation/report_over_production.rb similarity index 70% rename from lib/steem/operation/report_over_production.rb rename to lib/hive/operation/report_over_production.rb index 33e0f1d..d836750 100644 --- a/lib/steem/operation/report_over_production.rb +++ b/lib/hive/operation/report_over_production.rb @@ -1,4 +1,4 @@ -class Steem::Operation::ReportOverProduction < Steem::Operation +class Hive::Operation::ReportOverProduction < Hive::Operation def_attr reporter: :string def_attr first_block: :string # FIXME signed_block_header def_attr second_block: :string # FIXME signed_block_header diff --git a/lib/steem/operation/request_account_recovery.rb b/lib/hive/operation/request_account_recovery.rb similarity index 70% rename from lib/steem/operation/request_account_recovery.rb rename to lib/hive/operation/request_account_recovery.rb index dc82849..30e16f2 100644 --- a/lib/steem/operation/request_account_recovery.rb +++ b/lib/hive/operation/request_account_recovery.rb @@ -1,4 +1,4 @@ -class Steem::Operation::RequestAccountRecovery < Steem::Operation +class Hive::Operation::RequestAccountRecovery < Hive::Operation def_attr recovery_account: :string def_attr account_to_recover: :string def_attr new_owner_authority: :authority diff --git a/lib/steem/operation/reset_account.rb b/lib/hive/operation/reset_account.rb similarity index 67% rename from lib/steem/operation/reset_account.rb rename to lib/hive/operation/reset_account.rb index 8e288df..1f6ab82 100644 --- a/lib/steem/operation/reset_account.rb +++ b/lib/hive/operation/reset_account.rb @@ -1,4 +1,4 @@ -class Steem::Operation::ResetAccount < Steem::Operation +class Hive::Operation::ResetAccount < Hive::Operation def_attr reset_account: :string def_attr account_to_reset: :string def_attr new_owner_authority: :authority diff --git a/lib/steem/operation/set_reset_account.rb b/lib/hive/operation/set_reset_account.rb similarity index 64% rename from lib/steem/operation/set_reset_account.rb rename to lib/hive/operation/set_reset_account.rb index bebb6e6..b368106 100644 --- a/lib/steem/operation/set_reset_account.rb +++ b/lib/hive/operation/set_reset_account.rb @@ -1,4 +1,4 @@ -class Steem::Operation::SetResetAccount < Steem::Operation +class Hive::Operation::SetResetAccount < Hive::Operation def_attr account: :string def_attr current_reset_account: :string def_attr reset_account: :string diff --git a/lib/steem/operation/set_withdraw_vesting_route.rb b/lib/hive/operation/set_withdraw_vesting_route.rb similarity index 62% rename from lib/steem/operation/set_withdraw_vesting_route.rb rename to lib/hive/operation/set_withdraw_vesting_route.rb index 5338b39..98d374c 100644 --- a/lib/steem/operation/set_withdraw_vesting_route.rb +++ b/lib/hive/operation/set_withdraw_vesting_route.rb @@ -1,4 +1,4 @@ -class Steem::Operation::SetWithdrawVestingRoute < Steem::Operation +class Hive::Operation::SetWithdrawVestingRoute < Hive::Operation def_attr from: :string def_attr to: :string def_attr percent: :uint16 diff --git a/lib/steem/operation/transfer.rb b/lib/hive/operation/transfer.rb similarity index 66% rename from lib/steem/operation/transfer.rb rename to lib/hive/operation/transfer.rb index 55cd58d..a9c4d0f 100644 --- a/lib/steem/operation/transfer.rb +++ b/lib/hive/operation/transfer.rb @@ -1,4 +1,4 @@ -class Steem::Operation::Transfer < Steem::Operation +class Hive::Operation::Transfer < Hive::Operation def_attr from: :string def_attr to: :string def_attr amount: :amount diff --git a/lib/steem/operation/transfer_from_savings.rb b/lib/hive/operation/transfer_from_savings.rb similarity index 68% rename from lib/steem/operation/transfer_from_savings.rb rename to lib/hive/operation/transfer_from_savings.rb index d49ea5c..f70b1df 100644 --- a/lib/steem/operation/transfer_from_savings.rb +++ b/lib/hive/operation/transfer_from_savings.rb @@ -1,4 +1,4 @@ -class Steem::Operation::TransferFromSavings < Steem::Operation +class Hive::Operation::TransferFromSavings < Hive::Operation def_attr from: :string def_attr request_id: :uint32 def_attr to: :string diff --git a/lib/steem/operation/transfer_to_savings.rb b/lib/hive/operation/transfer_to_savings.rb similarity index 63% rename from lib/steem/operation/transfer_to_savings.rb rename to lib/hive/operation/transfer_to_savings.rb index 42bb20c..a11f715 100644 --- a/lib/steem/operation/transfer_to_savings.rb +++ b/lib/hive/operation/transfer_to_savings.rb @@ -1,4 +1,4 @@ -class Steem::Operation::TransferToSavings < Steem::Operation +class Hive::Operation::TransferToSavings < Hive::Operation def_attr from: :string def_attr to: :string def_attr amount: :amount diff --git a/lib/steem/operation/transfer_to_vesting.rb b/lib/hive/operation/transfer_to_vesting.rb similarity index 56% rename from lib/steem/operation/transfer_to_vesting.rb rename to lib/hive/operation/transfer_to_vesting.rb index 0b84bdd..0a78768 100644 --- a/lib/steem/operation/transfer_to_vesting.rb +++ b/lib/hive/operation/transfer_to_vesting.rb @@ -1,4 +1,4 @@ -class Steem::Operation::TransferToVesting < Steem::Operation +class Hive::Operation::TransferToVesting < Hive::Operation def_attr from: :string def_attr to: :string def_attr amount: :amount diff --git a/lib/steem/operation/vote.rb b/lib/hive/operation/vote.rb similarity index 70% rename from lib/steem/operation/vote.rb rename to lib/hive/operation/vote.rb index 837d96a..d649239 100644 --- a/lib/steem/operation/vote.rb +++ b/lib/hive/operation/vote.rb @@ -1,4 +1,4 @@ -class Steem::Operation::Vote < Steem::Operation +class Hive::Operation::Vote < Hive::Operation def_attr voter: :string def_attr author: :string def_attr permlink: :string diff --git a/lib/steem/operation/withdraw_vesting.rb b/lib/hive/operation/withdraw_vesting.rb similarity index 53% rename from lib/steem/operation/withdraw_vesting.rb rename to lib/hive/operation/withdraw_vesting.rb index 7b1a0f5..ad2eca8 100644 --- a/lib/steem/operation/withdraw_vesting.rb +++ b/lib/hive/operation/withdraw_vesting.rb @@ -1,4 +1,4 @@ -class Steem::Operation::WithdrawVesting < Steem::Operation +class Hive::Operation::WithdrawVesting < Hive::Operation def_attr account: :string def_attr vesting_shares: :amount end diff --git a/lib/steem/operation/witness_set_properties.rb b/lib/hive/operation/witness_set_properties.rb similarity index 61% rename from lib/steem/operation/witness_set_properties.rb rename to lib/hive/operation/witness_set_properties.rb index e92a19b..60b67a4 100644 --- a/lib/steem/operation/witness_set_properties.rb +++ b/lib/hive/operation/witness_set_properties.rb @@ -1,4 +1,4 @@ -class Steem::Operation::WitnessSetProperties < Steem::Operation +class Hive::Operation::WitnessSetProperties < Hive::Operation def_attr owner: :string def_attr props: :witness_properties def_attr extensions: :empty_array diff --git a/lib/steem/operation/witness_update.rb b/lib/hive/operation/witness_update.rb similarity index 73% rename from lib/steem/operation/witness_update.rb rename to lib/hive/operation/witness_update.rb index f34e7ce..5b604ed 100644 --- a/lib/steem/operation/witness_update.rb +++ b/lib/hive/operation/witness_update.rb @@ -1,4 +1,4 @@ -class Steem::Operation::WitnessUpdate < Steem::Operation +class Hive::Operation::WitnessUpdate < Hive::Operation def_attr owner: :string def_attr url: :string def_attr block_signing_key: :public_key diff --git a/lib/steem/rpc/base_client.rb b/lib/hive/rpc/base_client.rb similarity index 95% rename from lib/steem/rpc/base_client.rb rename to lib/hive/rpc/base_client.rb index d5ae9fd..c08d68c 100644 --- a/lib/steem/rpc/base_client.rb +++ b/lib/hive/rpc/base_client.rb @@ -1,4 +1,4 @@ -module Steem +module Hive module RPC class BaseClient include ChainConfig @@ -15,11 +15,11 @@ module Steem TIMEOUT_ERRORS = [Net::ReadTimeout, Errno::EBADF, IOError] def initialize(options = {}) - @chain = options[:chain] || :steem + @chain = options[:chain] || :hive @error_pipe = options[:error_pipe] || STDERR @api_name = options[:api_name] @url = case @chain - when :steem then options[:url] || NETWORKS_STEEM_DEFAULT_NODE + when :hive then options[:url] || NETWORKS_HIVE_DEFAULT_NODE when :test then options[:url] || NETWORKS_TEST_DEFAULT_NODE else; raise UnsupportedChainError, "Unsupported chain: #{@chain}" end @@ -169,7 +169,7 @@ module Steem error = response.error if error.message == 'Invalid Request' - raise Steem::ArgumentError, "Unexpected arguments: #{rpc_args.inspect}. Expected: #{rpc_method_name} (#{args_keys_to_s(rpc_method_name)})" + raise Hive::ArgumentError, "Unexpected arguments: #{rpc_args.inspect}. Expected: #{rpc_method_name} (#{args_keys_to_s(rpc_method_name)})" end BaseError.build_error(error, rpc_method_name) diff --git a/lib/steem/rpc/http_client.rb b/lib/hive/rpc/http_client.rb similarity index 96% rename from lib/steem/rpc/http_client.rb rename to lib/hive/rpc/http_client.rb index 1d153b5..e875adc 100644 --- a/lib/steem/rpc/http_client.rb +++ b/lib/hive/rpc/http_client.rb @@ -1,4 +1,4 @@ -module Steem +module Hive module RPC # {HttpClient} is intended for single-threaded applications. For # multi-threaded apps, use {ThreadSafeHttpClient}. @@ -17,12 +17,12 @@ module Steem # # @private TIMEOUT_ERRORS = [Net::OpenTimeout, JSON::ParserError, Net::ReadTimeout, - Errno::EBADF, IOError, Errno::ENETDOWN, Steem::RemoteDatabaseLockError] + Errno::EBADF, IOError, Errno::ENETDOWN, Hive::RemoteDatabaseLockError] # @private POST_HEADERS = { 'Content-Type' => 'application/json; charset=utf-8', - 'User-Agent' => Steem::AGENT_ID + 'User-Agent' => Hive::AGENT_ID } JSON_RPC_BATCH_SIZE_MAXIMUM = 50 @@ -119,7 +119,7 @@ module Steem throw retry_timeout(:tota_cera_pila, e) end else - raise Steem::ArgumentError, r.error.inspect + raise Hive::ArgumentError, r.error.inspect end end end diff --git a/lib/steem/rpc/thread_safe_http_client.rb b/lib/hive/rpc/thread_safe_http_client.rb similarity index 97% rename from lib/steem/rpc/thread_safe_http_client.rb rename to lib/hive/rpc/thread_safe_http_client.rb index 5b104f4..789fb2c 100644 --- a/lib/steem/rpc/thread_safe_http_client.rb +++ b/lib/hive/rpc/thread_safe_http_client.rb @@ -1,6 +1,6 @@ -module Steem +module Hive module RPC - # {ThreadSafeHttpClient} is the default RPC Client used by `steem-ruby.` + # {ThreadSafeHttpClient} is the default RPC Client used by `hive-ruby.` # It's perfect for simple requests. But for higher performance, it's better # to override {HttpClient} and implement something other than {Net::HTTP}. # diff --git a/lib/steem/stream.rb b/lib/hive/stream.rb similarity index 90% rename from lib/steem/stream.rb rename to lib/hive/stream.rb index 1e9b25c..c0bba12 100644 --- a/lib/steem/stream.rb +++ b/lib/hive/stream.rb @@ -1,9 +1,9 @@ -module Steem - # Steem::Stream allows a live view of the STEEM blockchain. +module Hive + # Hive::Stream allows a live view of the HIVE blockchain. # # Example streaming blocks: # - # stream = Steem::Stream.new + # stream = Hive::Stream.new # # stream.blocks do |block, block_num| # puts "#{block_num} :: #{block.witness}" @@ -11,7 +11,7 @@ module Steem # # Example streaming transactions: # - # stream = Steem::Stream.new + # stream = Hive::Stream.new # # stream.transactions do |trx, trx_id, block_num| # puts "#{block_num} :: #{trx_id} :: operations: #{trx.operations.size}" @@ -19,7 +19,7 @@ module Steem # # Example streaming operations: # - # stream = Steem::Stream.new + # stream = Hive::Stream.new # # stream.operations do |op, trx_id, block_num| # puts "#{block_num} :: #{trx_id} :: #{op.type}: #{op.value.to_json}" @@ -37,17 +37,17 @@ module Steem VOP_TRX_ID = ('0' * 40).freeze # @param options [Hash] additional options - # @option options [Steem::DatabaseApi] :database_api - # @option options [Steem::BlockApi] :block_api - # @option options [Steem::AccountHistoryApi || Steem::CondenserApi] :account_history_api + # @option options [Hive::DatabaseApi] :database_api + # @option options [Hive::BlockApi] :block_api + # @option options [Hive::AccountHistoryApi || Hive::CondenserApi] :account_history_api # @option options [Symbol] :mode we have the choice between # * :head the last block # * :irreversible the block that is confirmed by 2/3 of all block producers and is thus irreversible! # @option options [Boolean] :no_warn do not generate warnings def initialize(options = {mode: :irreversible}) @instance_options = options - @database_api = options[:database_api] || Steem::DatabaseApi.new(options) - @block_api = options[:block_api] || Steem::BlockApi.new(options) + @database_api = options[:database_api] || Hive::DatabaseApi.new(options) + @block_api = options[:block_api] || Hive::BlockApi.new(options) @account_history_api = options[:account_history_api] @mode = options[:mode] || :irreversible @no_warn = !!options[:no_warn] @@ -55,7 +55,7 @@ module Steem # Use this method to stream block numbers. This is significantly faster # than requesting full blocks and even block headers. Basically, the only - # thing this method does is call {Steem::Database#get_dynamic_global_properties} at 3 second + # thing this method does is call {Hive::Database#get_dynamic_global_properties} at 3 second # intervals. # # @param options [Hash] additional options @@ -109,7 +109,7 @@ module Steem # Returns the latest operations from the blockchain. # - # stream = Steem::Stream.new + # stream = Hive::Stream.new # stream.operations do |op| # puts op.to_json # end @@ -156,21 +156,21 @@ module Steem # # For example, to stream only votes: # - # stream = Steem::Stream.new + # stream = Hive::Stream.new # stream.operations(types: :vote_operation) do |vote| # puts vote.to_json # end # # ... Or ... # - # stream = Steem::Stream.new + # stream = Hive::Stream.new # stream.operations(:vote_operation) do |vote| # puts vote.to_json # end # # You can also stream virtual operations: # - # stream = Steem::Stream.new + # stream = Hive::Stream.new # stream.operations(types: :author_reward_operation, only_virtual: true) do |vop| # v = vop.value # puts "#{v.author} got paid for #{v.permlink}: #{[v.sbd_payout, v.steem_payout, v.vesting_payout]}" @@ -178,14 +178,14 @@ module Steem # # ... or multiple virtual operation types; # - # stream = Steem::Stream.new + # stream = Hive::Stream.new # stream.operations(types: [:producer_reward_operation, :author_reward_operation], only_virtual: true) do |vop| # puts vop.to_json # end # # ... or all types, including virtual operation types from the head block number: # - # stream = Steem::Stream.new(mode: :head) + # stream = Hive::Stream.new(mode: :head) # stream.operations(include_virtual: true) do |op| # puts op.to_json # end @@ -245,10 +245,10 @@ module Steem def account_history_api @account_history_api ||= begin - Steem::AccountHistoryApi.new(@instance_options) - rescue Steem::UnknownApiError => e - warn "#{e.inspect}, falling back to Steem::CondenserApi." unless @no_warn - Steem::CondenserApi.new(@instance_options) + Hive::AccountHistoryApi.new(@instance_options) + rescue Hive::UnknownApiError => e + warn "#{e.inspect}, falling back to Hive::CondenserApi." unless @no_warn + Hive::CondenserApi.new(@instance_options) end end private @@ -304,7 +304,7 @@ module Steem block_num = case mode when :head then properties.head_block_number when :irreversible then properties.last_irreversible_block_num - else; raise Steem::ArgumentError, "Unknown mode: #{mode}" + else; raise Hive::ArgumentError, "Unknown mode: #{mode}" end block_num @@ -330,9 +330,9 @@ module Steem loop do get_ops_in_block_options = case account_history_api - when Steem::CondenserApi + when Hive::CondenserApi [block_num, true] - when Steem::AccountHistoryApi + when Hive::AccountHistoryApi { block_num: block_num, only_virtual: true @@ -353,12 +353,12 @@ module Steem end ops = case account_history_api - when Steem::CondenserApi + when Hive::CondenserApi result.map do |trx| op = {type: trx.op[0] + '_operation', value: trx.op[1]} op = Hashie::Mash.new(op) end - when Steem::AccountHistoryApi then result.ops.map { |trx| trx.op } + when Hive::AccountHistoryApi then result.ops.map { |trx| trx.op } end if ops.empty? diff --git a/lib/steem/transaction.rb b/lib/hive/transaction.rb similarity index 68% rename from lib/steem/transaction.rb rename to lib/hive/transaction.rb index 46896e8..51aa167 100644 --- a/lib/steem/transaction.rb +++ b/lib/hive/transaction.rb @@ -1,4 +1,4 @@ -module Steem +module Hive class Transaction include JSONable include Utils @@ -15,7 +15,7 @@ module Steem end options.each do |k, v| - raise Steem::ArgumentError, "Invalid option specified: #{k}" unless ATTRIBUTES.include?(k.to_sym) + raise Hive::ArgumentError, "Invalid option specified: #{k}" unless ATTRIBUTES.include?(k.to_sym) send("#{k}=", v) end @@ -73,24 +73,43 @@ module Steem return false unless self.class == other_trx.class begin - return false if self[:ref_block_num].to_i != other_trx[:ref_block_num].to_i - return false if self[:ref_block_prefix].to_i != other_trx[:ref_block_prefix].to_i + return false if self[:ref_block_num].to_i != transform_value(other_trx[:ref_block_num]).to_i + return false if self[:ref_block_prefix].to_i != transform_value(other_trx[:ref_block_prefix]).to_i return false if self[:expiration].to_i != other_trx[:expiration].to_i return false if self[:operations].size != other_trx[:operations].size op_values = self[:operations].map do |type, value| - [type.to_s, value.values.map{|v| v.to_s.gsub(/[^a-zA-Z0-9-]/, '')}] + [type.to_s, value.values.map{|v| transform_value(v).gsub(/[^a-zA-Z0-9-]/, '')}] end.flatten.sort other_op_values = other_trx[:operations].map do |type, value| - [type.to_s, value.values.map{|v| v.to_s.gsub(/[^a-zA-Z0-9-]/, '')}] + [type.to_s, value.values.map{|v| transform_value(v).gsub(/[^a-zA-Z0-9-]/, '')}] end.flatten.sort - # binding.pry unless op_values == other_op_values + + # unless op_values == other_op_values + # require 'pry'; binding.pry + # end + op_values == other_op_values rescue => e - # binding.pry + # require 'pry'; binding.pry + false end end + private + def transform_value(v) + case v + when Array then v.map{|e| transform_value(e)}.to_s + when Hash + if !v['tl_in_read'] && !!v['value'] + v['value'].to_s + else + v.values.map{|e| transform_value(e)}.to_s + end + else + v.to_s + end + end end end diff --git a/lib/steem/transaction_builder.rb b/lib/hive/transaction_builder.rb similarity index 86% rename from lib/steem/transaction_builder.rb rename to lib/hive/transaction_builder.rb index ec441e4..72031e0 100644 --- a/lib/steem/transaction_builder.rb +++ b/lib/hive/transaction_builder.rb @@ -1,4 +1,4 @@ -module Steem +module Hive # {TransactionBuilder} can be used to create a transaction that the # {NetworkBroadcastApi} can broadcast to the rest of the platform. The main # feature of this class is the ability to cryptographically sign the @@ -6,7 +6,7 @@ module Steem # the blockchain. # # wif = '5JrvPrQeBBvCRdjv29iDvkwn3EQYZ9jqfAHzrCyUvfbEbRkrYFC' - # builder = Steem::TransactionBuilder.new(wif: wif) + # builder = Hive::TransactionBuilder.new(wif: wif) # builder.put(vote: { # voter: 'alice', # author: 'bob', @@ -15,7 +15,7 @@ module Steem # }) # # trx = builder.transaction - # network_broadcast_api = Steem::CondenserApi.new + # network_broadcast_api = Hive::CondenserApi.new # network_broadcast_api.broadcast_transaction_synchronous(trx: trx) # # @@ -40,11 +40,11 @@ module Steem @block_api = options[:block_api] if app_base? - @database_api ||= Steem::DatabaseApi.new(options) - @block_api ||= Steem::BlockApi.new(options) + @database_api ||= Hive::DatabaseApi.new(options) + @block_api ||= Hive::BlockApi.new(options) else - @database_api ||= Steem::CondenserApi.new(options) - @block_api ||= Steem::CondenserApi.new(options) + @database_api ||= Hive::CondenserApi.new(options) + @block_api ||= Hive::CondenserApi.new(options) end @wif = [options[:wif]].flatten @@ -62,18 +62,25 @@ module Steem end @trx ||= Transaction.new - @chain = options[:chain] || :steem + @chain = options[:chain] || :hive @error_pipe = options[:error_pipe] || STDERR - @chain_id = options[:chain_id] - @chain_id ||= case @chain - when :steem then NETWORKS_STEEM_CHAIN_ID - when :test then NETWORKS_TEST_CHAIN_ID + @chain_id = options[:chain_id] || ENV['HIVE_CHAIN_ID'] + + @network_chain_id ||= case @chain + when :hive then @database_api.get_config{|config| config['HIVE_CHAIN_ID']} rescue NETWORKS_HIVE_CHAIN_ID + when :test then @database_api.get_config{|config| config['HIVE_CHAIN_ID']} rescue NETWORKS_TEST_CHAIN_ID else; raise UnsupportedChainError, "Unsupported chain: #{@chain}" end - if testnet? && @chain_id == NETWORKS_STEEM_CHAIN_ID + @chain_id ||= @network_chain_id + + if testnet? && (@chain_id == NETWORKS_HIVE_CHAIN_ID || @chain_id == NETWORKS_HIVE_LEGACY_CHAIN_ID) raise UnsupportedChainError, "Unsupported testnet chain id: #{@chain_id}" end + + if @chain_id != @network_chain_id + raise UnsupportedChainError, "Unsupported chain id (expected: #{@chain_id}, network was: #{@network_chain_id})" + end end def inspect @@ -162,7 +169,7 @@ module Steem # # You can also chain multiple operations: # - # builder = Steem::TransactionBuilder.new + # builder = Hive::TransactionBuilder.new # builder.put(vote: vote1).put(vote: vote2) # @return {TransactionBuilder} def put(type, op = nil) @@ -233,7 +240,13 @@ module Steem normalize_operation op_name, JSON[op[:value].to_json] end - raise SerializationMismatchError unless @trx == derrived_trx + unless @trx == derrived_trx + if defined? JsonCompare + raise SerializationMismatchError, JSON.pretty_generate({trx: @trx, derrived_trx: derrived_trx}) + else + raise SerializationMismatchError + end + end end hex = hex[0..-4] # drop empty signature array @@ -350,7 +363,7 @@ module Steem end end private - # See: https://github.com/steemit/steem/pull/2500 + # See: https://github.com/openhive-network/hive/pull/2500 # @private def canonical?(sig) sig = sig.unpack('C*') @@ -376,7 +389,7 @@ module Steem type_value = "#{type[0]}_operation" {type: type_value, value: type[1]} else - raise Steem::ArgumentError, "Don't know what to do with operation type #{type.class}: #{type} (#{op})" + raise Hive::ArgumentError, "Don't know what to do with operation type #{type.class}: #{type} (#{op})" end else case type @@ -385,7 +398,7 @@ module Steem when Hash then [type.keys.first.to_sym, type.values.first] when Array then type else - raise Steem::ArgumentError, "Don't know what to do with operation type #{type.class}: #{type} (#{op})" + raise Hive::ArgumentError, "Don't know what to do with operation type #{type.class}: #{type} (#{op})" end end end diff --git a/lib/steem/type/amount.rb b/lib/hive/type/amount.rb similarity index 57% rename from lib/steem/type/amount.rb rename to lib/hive/type/amount.rb index 69bbf4b..651e921 100644 --- a/lib/steem/type/amount.rb +++ b/lib/hive/type/amount.rb @@ -1,8 +1,15 @@ -module Steem +module Hive module Type # See: https://github.com/xeroc/piston-lib/blob/34a7525cee119ec9b24a99577ede2d54466fca0e/steembase/operations.py class Amount < BaseType + ASSET_HBD = 'HBD'; NAI_HBD = '@@000000013' + ASSET_HIVE = 'HIVE'; NAI_HIVE = '@@000000021' + ASSET_VESTS = 'VESTS'; NAI_VESTS = '@@000000037' + ASSET_TBD = 'TBD'; NAI_TBD = '@@000000013' + ASSET_TESTS = 'TESTS'; NAI_TESTS = '@@000000021' + VALID_ASSETS = [ASSET_HBD, ASSET_HIVE, ASSET_VESTS, ASSET_TBD, ASSET_TESTS] + attr_reader :amount, :precision, :nai, :asset def self.to_h(amount) @@ -24,9 +31,9 @@ module Steem when Array @amount, @precision, @nai = value @asset = case @nai - when '@@000000013' then 'SBD' - when '@@000000021' then 'STEEM' - when '@@000000037' then 'VESTS' + when NAI_HBD then ASSET_HBD + when NAI_HIVE then ASSET_HIVE + when NAI_VESTS then ASSET_VESTS else; raise TypeError, "Asset #{@nai} unknown." end @@ -37,9 +44,9 @@ module Steem end.compact @asset = case @nai - when '@@000000013' then 'SBD' - when '@@000000021' then 'STEEM' - when '@@000000037' then 'VESTS' + when NAI_HBD then ASSET_HBD + when NAI_HIVE then ASSET_HIVE + when NAI_VESTS then ASSET_VESTS else; raise TypeError, "Asset #{@nai} unknown." end @@ -51,12 +58,24 @@ module Steem @amount = value.amount else @amount, @asset = value.strip.split(' ') rescue ['', ''] + + # Usually, we will see unexpected 'STEEM' and 'SBD' from Hive-HF23 + # because deserialization contains them for app compatibility. + @asset = case @asset + when 'STEEM' then ASSET_HIVE + when 'SBD' then ASSET_HBD + else + warn "Got unexpected asset: #{value}" unless VALID_ASSETS.include? @asset + + @asset + end + @precision = case @asset - when 'STEEM' then 3 - when 'VESTS' then 6 - when 'SBD' then 3 - when 'TESTS' then 3 - when 'TBD' then 3 + when ASSET_HIVE then 3 + when ASSET_VESTS then 6 + when ASSET_HBD then 3 + when ASSET_TESTS then 3 + when ASSET_TBD then 3 else; raise TypeError, "Asset #{@asset} unknown." end end @@ -73,28 +92,28 @@ module Steem def to_a case @asset - when 'STEEM' then [(@amount.to_f * 1000).to_i.to_s, 3, '@@000000021'] - when 'VESTS' then [(@amount.to_f * 1000000).to_i.to_s, 6, '@@000000037'] - when 'SBD' then [(@amount.to_f * 1000).to_i.to_s, 3, '@@000000013'] + when ASSET_HIVE then [(@amount.to_f * 1000).to_i.to_s, 3, NAI_HIVE] + when ASSET_VESTS then [(@amount.to_f * 1000000).to_i.to_s, 6, NAI_VESTS] + when ASSET_HBD then [(@amount.to_f * 1000).to_i.to_s, 3, NAI_HBD] end end def to_h case @asset - when 'STEEM' then { + when ASSET_HIVE then { amount: (@amount.to_f * 1000).to_i.to_s, precision: 3, - nai: '@@000000021' + nai: NAI_HIVE } - when 'VESTS' then { + when ASSET_VESTS then { amount: (@amount.to_f * 1000000).to_i.to_s, precision: 6, - nai: '@@000000037' + nai: NAI_VESTS } - when 'SBD' then { + when ASSET_HBD then { amount: (@amount.to_f * 1000).to_i.to_s, precision: 3, - nai: '@@000000013' + nai: NAI_HBD } end end diff --git a/lib/steem/type/base_type.rb b/lib/hive/type/base_type.rb similarity index 91% rename from lib/steem/type/base_type.rb rename to lib/hive/type/base_type.rb index d6f6c60..9a3e84b 100644 --- a/lib/steem/type/base_type.rb +++ b/lib/hive/type/base_type.rb @@ -1,4 +1,4 @@ -module Steem +module Hive module Type class BaseType def initialize(key, value) diff --git a/lib/steem/utils.rb b/lib/hive/utils.rb similarity index 95% rename from lib/steem/utils.rb rename to lib/hive/utils.rb index a7b4fc9..7622ce8 100644 --- a/lib/steem/utils.rb +++ b/lib/hive/utils.rb @@ -1,4 +1,4 @@ -module Steem +module Hive module Utils def hexlify(s) a = [] diff --git a/lib/hive/version.rb b/lib/hive/version.rb new file mode 100644 index 0000000..2260b62 --- /dev/null +++ b/lib/hive/version.rb @@ -0,0 +1,4 @@ +module Hive + VERSION = '1.0.0-1' + AGENT_ID = "hive-ruby/#{VERSION}" +end diff --git a/lib/steem.rb b/lib/steem.rb deleted file mode 100644 index b67bb21..0000000 --- a/lib/steem.rb +++ /dev/null @@ -1,85 +0,0 @@ -# encoding: UTF-8 -require 'json' unless defined?(JSON) -require 'net/https' - -require 'hashie' -require 'steem/version' -require 'steem/utils' -require 'steem/base_error' -require 'steem/mixins/serializable' -require 'steem/mixins/jsonable' -require 'steem/mixins/retriable' -require 'steem/chain_config' -require 'steem/type/base_type' -require 'steem/type/amount' -require 'steem/operation' -require 'steem/operation/account_create.rb' -require 'steem/operation/account_create_with_delegation.rb' -require 'steem/operation/account_update.rb' -require 'steem/operation/account_witness_proxy.rb' -require 'steem/operation/account_witness_vote.rb' -require 'steem/operation/cancel_transfer_from_savings.rb' -require 'steem/operation/challenge_authority.rb' -require 'steem/operation/change_recovery_account.rb' -require 'steem/operation/claim_account.rb' -require 'steem/operation/claim_reward_balance.rb' -require 'steem/operation/comment.rb' -require 'steem/operation/comment_options.rb' -require 'steem/operation/convert.rb' -require 'steem/operation/create_claimed_account.rb' -require 'steem/operation/custom.rb' -require 'steem/operation/custom_binary.rb' -require 'steem/operation/custom_json.rb' -require 'steem/operation/decline_voting_rights.rb' -require 'steem/operation/delegate_vesting_shares.rb' -require 'steem/operation/delete_comment.rb' -require 'steem/operation/escrow_approve.rb' -require 'steem/operation/escrow_dispute.rb' -require 'steem/operation/escrow_release.rb' -require 'steem/operation/escrow_transfer.rb' -require 'steem/operation/feed_publish.rb' -require 'steem/operation/limit_order_cancel.rb' -require 'steem/operation/limit_order_create.rb' -require 'steem/operation/limit_order_create2.rb' -require 'steem/operation/prove_authority.rb' -require 'steem/operation/recover_account.rb' -require 'steem/operation/report_over_production.rb' -require 'steem/operation/request_account_recovery.rb' -require 'steem/operation/reset_account.rb' -require 'steem/operation/set_reset_account.rb' -require 'steem/operation/set_withdraw_vesting_route.rb' -require 'steem/operation/transfer.rb' -require 'steem/operation/transfer_from_savings.rb' -require 'steem/operation/transfer_to_savings.rb' -require 'steem/operation/transfer_to_vesting.rb' -require 'steem/operation/vote.rb' -require 'steem/operation/withdraw_vesting.rb' -require 'steem/operation/witness_update.rb' -require 'steem/operation/witness_set_properties.rb' -require 'steem/marshal' -require 'steem/transaction' -require 'steem/transaction_builder' -require 'steem/rpc/base_client' -require 'steem/rpc/http_client' -require 'steem/rpc/thread_safe_http_client' -require 'steem/api' -require 'steem/jsonrpc' -require 'steem/block_api' -require 'steem/formatter' -require 'steem/broadcast' -require 'steem/stream' - -module Steem - def self.api_classes - @api_classes ||= {} - end - - def self.const_missing(api_name) - api = api_classes[api_name] - api ||= Api.clone(freeze: true) rescue Api.clone - api.api_name = api_name - api_classes[api_name] = api - end -end - -Hashie.logger = Logger.new(ENV['HASHIE_LOGGER']) diff --git a/lib/steem/chain_config.rb b/lib/steem/chain_config.rb deleted file mode 100644 index 4859719..0000000 --- a/lib/steem/chain_config.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Steem - module ChainConfig - EXPIRE_IN_SECS = 600 - EXPIRE_IN_SECS_PROPOSAL = 24 * 60 * 60 - - NETWORKS_STEEM_CHAIN_ID = '0000000000000000000000000000000000000000000000000000000000000000' - NETWORKS_STEEM_ADDRESS_PREFIX = 'STM' - NETWORKS_STEEM_CORE_ASSET = ["0", 3, "@@000000021"] # STEEM - NETWORKS_STEEM_DEBT_ASSET = ["0", 3, "@@000000013"] # SBD - NETWORKS_STEEM_VEST_ASSET = ["0", 6, "@@000000037"] # VESTS - NETWORKS_STEEM_DEFAULT_NODE = 'https://api.steemit.com' # √ - # NETWORKS_STEEM_DEFAULT_NODE = 'https://api.steemitstage.com' # √ - # NETWORKS_STEEM_DEFAULT_NODE = 'https://api.steemitdev.com' # √ - # NETWORKS_STEEM_DEFAULT_NODE = 'https://appbasetest.timcliff.com' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://gtg.steem.house:8090' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://api.steem.house' # √? - # NETWORKS_STEEM_DEFAULT_NODE = 'https://seed.bitcoiner.me' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://steemd.minnowsupportproject.org' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://steemd.privex.io' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://rpc.steemliberator.com' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://rpc.curiesteem.com' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://rpc.buildteam.io' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://steemd.pevo.science' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://rpc.steemviz.com' - # NETWORKS_STEEM_DEFAULT_NODE = 'https://steemd.steemgigs.org' - - NETWORKS_TEST_CHAIN_ID = '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32' - NETWORKS_TEST_ADDRESS_PREFIX = 'TST' - NETWORKS_TEST_CORE_ASSET = ["0", 3, "@@000000021"] # TESTS - NETWORKS_TEST_DEBT_ASSET = ["0", 3, "@@000000013"] # TBD - NETWORKS_TEST_VEST_ASSET = ["0", 6, "@@000000037"] # VESTS - NETWORKS_TEST_DEFAULT_NODE = 'https://testnet.steemitdev.com' - - NETWORK_CHAIN_IDS = [NETWORKS_STEEM_CHAIN_ID, NETWORKS_TEST_CHAIN_ID] - end -end diff --git a/lib/steem/operation/account_witness_proxy.rb b/lib/steem/operation/account_witness_proxy.rb deleted file mode 100644 index 488238e..0000000 --- a/lib/steem/operation/account_witness_proxy.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Steem::Operation::AccountWitnessProxy < Steem::Operation - def_attr account: :string - def_attr proxy: :string -end diff --git a/lib/steem/operation/cancel_transfer_from_savings.rb b/lib/steem/operation/cancel_transfer_from_savings.rb deleted file mode 100644 index ce262de..0000000 --- a/lib/steem/operation/cancel_transfer_from_savings.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Steem::Operation::CancelTransferFromSavings < Steem::Operation - def_attr from: :string - def_attr request_id: :uint32 -end diff --git a/lib/steem/operation/decline_voting_rights.rb b/lib/steem/operation/decline_voting_rights.rb deleted file mode 100644 index 7f5fe38..0000000 --- a/lib/steem/operation/decline_voting_rights.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Steem::Operation::DeclineVotingRights < Steem::Operation - def_attr account: :string - def_attr decline: :boolean -end diff --git a/lib/steem/operation/limit_order_cancel.rb b/lib/steem/operation/limit_order_cancel.rb deleted file mode 100644 index 7d74eb6..0000000 --- a/lib/steem/operation/limit_order_cancel.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Steem::Operation::LimitOrderCancel < Steem::Operation - def_attr owner: :string - def_attr orderid: :uint32 -end diff --git a/lib/steem/version.rb b/lib/steem/version.rb deleted file mode 100644 index d0e114b..0000000 --- a/lib/steem/version.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Steem - VERSION = '0.9.4' - AGENT_ID = "steem-ruby/#{VERSION}" -end diff --git a/test/steem/account_by_key_api_test.rb b/test/hive/account_by_key_api_test.rb similarity index 72% rename from test/steem/account_by_key_api_test.rb rename to test/hive/account_by_key_api_test.rb index 64f5455..c9a5b38 100644 --- a/test/steem/account_by_key_api_test.rb +++ b/test/hive/account_by_key_api_test.rb @@ -1,19 +1,19 @@ require 'test_helper' -module Steem - class AccountByKeyApiTest < Steem::Test +module Hive + class AccountByKeyApiTest < Hive::Test def setup - @api = Steem::AccountByKeyApi.new(url: TEST_NODE) + @api = Hive::AccountByKeyApi.new(url: TEST_NODE) rescue skip('account_by_key_api not supported') @jsonrpc = Jsonrpc.new(url: TEST_NODE) @methods = @jsonrpc.get_api_methods[@api.class.api_name] end def test_api_class_name - assert_equal 'AccountByKeyApi', Steem::AccountByKeyApi::api_class_name + assert_equal 'AccountByKeyApi', Hive::AccountByKeyApi::api_class_name end def test_inspect - assert_equal "#<AccountByKeyApi [@chain=steem, @methods=<1 element>]>", @api.inspect + assert_equal "#<AccountByKeyApi [@chain=hive, @methods=<1 element>]>", @api.inspect end def test_method_missing @@ -40,4 +40,4 @@ module Steem end end end -end \ No newline at end of file +end diff --git a/test/steem/account_history_api_test.rb b/test/hive/account_history_api_test.rb similarity index 79% rename from test/steem/account_history_api_test.rb rename to test/hive/account_history_api_test.rb index 5659f88..1801a3e 100644 --- a/test/steem/account_history_api_test.rb +++ b/test/hive/account_history_api_test.rb @@ -1,22 +1,20 @@ require 'test_helper' -module Steem +module Hive # :nocov: - class AccountHistoryApiTest < Steem::Test + class AccountHistoryApiTest < Hive::Test def setup - @api = Steem::AccountHistoryApi.new(url: TEST_NODE) + @api = Hive::AccountHistoryApi.new(url: TEST_NODE) rescue skip('AccountHistoryApi is disabled.') @jsonrpc = Jsonrpc.new(url: TEST_NODE) @methods = @jsonrpc.get_api_methods[@api.class.api_name] - rescue UnknownApiError => e - skip('AccountHistoryApi is disabled.') end def test_api_class_name - assert_equal 'AccountHistoryApi', Steem::AccountHistoryApi::api_class_name + assert_equal 'AccountHistoryApi', Hive::AccountHistoryApi::api_class_name end def test_inspect - assert_equal "#<AccountHistoryApi [@chain=steem, @methods=<3 elements>]>", @api.inspect + assert_equal "#<AccountHistoryApi [@chain=hive, @methods=<4 elements>]>", @api.inspect end def test_method_missing @@ -34,7 +32,7 @@ module Steem def test_get_account_history vcr_cassette('account_history_api_get_account_history', record: :once) do options = { - account: 'steemit', + account: 'hiveio', start: 0, limit: 0 } diff --git a/test/hive/amount_test.rb b/test/hive/amount_test.rb new file mode 100644 index 0000000..7640288 --- /dev/null +++ b/test/hive/amount_test.rb @@ -0,0 +1,33 @@ +require 'test_helper' + +module Hive + class AmountTest < Hive::Test + def setup + @amount = Hive::Type::Amount.new('0.000 HIVE') + end + + def test_to_s + assert_equal '0.000 HBD', Hive::Type::Amount.to_s(['0', 3, '@@000000013']) + assert_equal '0.000 HIVE', Hive::Type::Amount.to_s(['0', 3, '@@000000021']) + assert_equal '0.000000 VESTS', Hive::Type::Amount.to_s(['0', 6, '@@000000037']) + + assert_raises TypeError do + Hive::Type::Amount.to_s(['0', 3, '@@00000000']) + end + end + + def test_to_h + assert_equal({amount: '0', precision: 3, nai: '@@000000013'}, Hive::Type::Amount.to_h('0.000 HBD')) + assert_equal({amount: '0', precision: 3, nai: '@@000000021'}, Hive::Type::Amount.to_h('0.000 HIVE')) + assert_equal({amount: '0', precision: 6, nai: '@@000000037'}, Hive::Type::Amount.to_h('0.000000 VESTS')) + + assert_raises TypeError do + Hive::Type::Amount.to_h('0.000 BOGUS') + end + end + + def test_to_bytes + assert @amount.to_bytes + end + end +end diff --git a/test/steem/api_test.rb b/test/hive/api_test.rb similarity index 72% rename from test/steem/api_test.rb rename to test/hive/api_test.rb index 7ac2982..67caeda 100644 --- a/test/steem/api_test.rb +++ b/test/hive/api_test.rb @@ -1,40 +1,34 @@ require 'test_helper' -module Steem - class ApiTest < Steem::Test - METHOD_NAMES_1_ARG = %i(get_account_votes get_block get_block_header - get_blog_authors get_comment_discussions_by_payout - get_conversion_requests get_discussions_by_active - get_discussions_by_blog get_discussions_by_cashout - get_discussions_by_children get_discussions_by_comments - get_discussions_by_created get_discussions_by_feed - get_discussions_by_hot get_discussions_by_promoted - get_discussions_by_trending get_discussions_by_votes - get_follow_count get_key_references get_open_orders - get_owner_history get_post_discussions_by_payout +module Hive + class ApiTest < Hive::Test + METHOD_NAMES_1_ARG = %i(get_block get_block_header + get_conversion_requests + get_key_references get_open_orders + get_owner_history get_potential_signatures get_recovery_request get_reward_fund - get_savings_withdraw_from get_savings_withdraw_to get_state - get_tags_used_by_author get_transaction_hex + get_savings_withdraw_from get_savings_withdraw_to + get_transaction_hex get_witness_by_account verify_authority) METHOD_NAMES_2_ARGS = %i(get_account_reputations get_active_votes get_content get_content_replies get_escrow get_expiring_vesting_delegations get_ops_in_block - get_reblogged_by get_required_signatures get_trending_tags + get_required_signatures get_withdraw_routes get_witnesses_by_vote lookup_accounts lookup_witness_accounts verify_account_authority) - METHOD_NAMES_3_ARGS = %i(get_account_history get_blog get_blog_entries - get_feed get_feed_entries get_market_history get_replies_by_last_update - get_trade_history get_vesting_delegations) + METHOD_NAMES_3_ARGS = %i(get_account_history + get_feed get_feed_entries get_market_history + get_trade_history get_vesting_delegations list_proposal_votes + list_proposals) - METHOD_NAMES_4_ARGS = %i(get_discussions_by_author_before_date get_followers - get_following) + METHOD_NAMES_4_ARGS = %i() - METHOD_NAMES_UNIMPLEMENTED = %i(get_account_references) + METHOD_NAMES_UNIMPLEMENTED = %i(get_account_references get_account_votes) METHOD_NAMES_1_ARG_NO_ERROR = %i(get_accounts get_witnesses - lookup_account_names) + lookup_account_names find_proposals) METHOD_NAMES_0_ARGS = %i(get_account_count get_active_witnesses get_chain_properties get_config get_current_median_history_price @@ -43,7 +37,17 @@ module Steem get_recent_trades get_ticker get_trade_history) # Plugins not enabled, or similar. - SKIP_METHOD_NAMES = %i(get_transaction) + SKIP_METHOD_NAMES = %i(get_transaction get_blog get_blog_authors + get_blog_entries get_comment_discussions_by_payout + get_discussions_by_active get_discussions_by_author_before_date + get_discussions_by_blog get_discussions_by_cashout + get_discussions_by_children get_discussions_by_comments + get_discussions_by_created get_discussions_by_feed get_discussions_by_hot + get_discussions_by_promoted get_discussions_by_trending + get_discussions_by_votes get_follow_count get_followers get_following + get_post_discussions_by_payout get_reblogged_by + get_replies_by_last_update get_state get_tags_used_by_author + get_trending_tags) ALL_METHOD_NAMES = METHOD_NAMES_1_ARG + METHOD_NAMES_2_ARGS + METHOD_NAMES_3_ARGS + METHOD_NAMES_4_ARGS + METHOD_NAMES_UNIMPLEMENTED + @@ -61,7 +65,7 @@ module Steem def test_unknown_api_name assert_raises UnknownApiError, 'expect unknown api error' do - Steem::FakeApi.new + Hive::FakeApi.new end end @@ -76,13 +80,13 @@ module Steem end def test_inspect - assert_equal "#<CondenserApi [@chain=steem, @methods=<84 elements>]>", @api.inspect + assert_equal "#<CondenserApi [@chain=hive, @methods=<87 elements>]>", @api.inspect end def test_inspect_testnet vcr_cassette("#{@api.class.api_name}_testnet") do - api = Api.new(chain: :test) - assert_equal "#<CondenserApi [@chain=test, @methods=<84 elements>]>", api.inspect + api = Api.new(chain: :test) rescue skip('testnet currently unavilable') + assert_equal "#<CondenserApi [@chain=test, @methods=<87 elements>]>", api.inspect end end @@ -138,22 +142,22 @@ module Steem end when *METHOD_NAMES_1_ARG then - assert_raises Steem::ArgumentError, "expect 1 argument to raise ArgumentError for: #{key}" do + assert_raises Hive::ArgumentError, "expect 1 argument to raise ArgumentError for: #{key}" do assert @api.send key, [nil] end when *METHOD_NAMES_2_ARGS then - assert_raises Steem::ArgumentError, "expect 2 arguments to raise ArgumentError for: #{key}" do + assert_raises Hive::ArgumentError, "expect 2 arguments to raise ArgumentError for: #{key}" do assert @api.send key, [nil, nil] end when *METHOD_NAMES_3_ARGS then - assert_raises Steem::ArgumentError, "expect 3 arguments to raise ArgumentError for: #{key}" do + assert_raises Hive::ArgumentError, "expect 3 arguments to raise ArgumentError for: #{key}" do assert @api.send key, [nil, nil, nil] end when *METHOD_NAMES_4_ARGS then - assert_raises Steem::ArgumentError, "expect 4 arguments to raise ArgumentError for: #{key}" do + assert_raises Hive::ArgumentError, "expect 4 arguments to raise ArgumentError for: #{key}" do assert @api.send key, [nil, nil, nil, nil] end when *METHOD_NAMES_UNIMPLEMENTED then # skip @@ -177,11 +181,11 @@ module Steem def test_get_content_wrong_arguments vcr_cassette('condenser_api_get_content_wrong_arguments') do - assert_raises Steem::ArgumentError, 'expect argument error' do + assert_raises Hive::ArgumentError, 'expect argument error' do @api.get_content end - assert_raises Steem::ArgumentError, 'expect argument error' do + assert_raises Hive::ArgumentError, 'expect argument error' do @api.get_content(nil) end end diff --git a/test/steem/block_api_test.rb b/test/hive/block_api_test.rb similarity index 97% rename from test/steem/block_api_test.rb rename to test/hive/block_api_test.rb index b901fb2..fa7dcdd 100644 --- a/test/steem/block_api_test.rb +++ b/test/hive/block_api_test.rb @@ -1,7 +1,7 @@ require 'test_helper' -module Steem - class BlockApiTest < Steem::Test +module Hive + class BlockApiTest < Hive::Test def setup @block_api = BlockApi.new(url: TEST_NODE) @jsonrpc = Jsonrpc.new(url: TEST_NODE) @@ -60,7 +60,7 @@ module Steem # :nocov: fail 'please review this test' # :nocov: - rescue Steem::ArgumentError => e + rescue Hive::ArgumentError => e assert e.to_s, 'expect string from argument error' end @@ -79,7 +79,7 @@ module Steem def test_oddballs oddballs = [994240] - api = Steem::Api.new(url: TEST_NODE) + api = Hive::Api.new(url: TEST_NODE) vcr_cassette('block_api_oddballs', record: :once) do oddballs.each do |block_num| diff --git a/test/hive/bridge_test.rb b/test/hive/bridge_test.rb new file mode 100644 index 0000000..d5b30bf --- /dev/null +++ b/test/hive/bridge_test.rb @@ -0,0 +1,95 @@ +require 'test_helper' + +module Hive + class BridgeTest < Hive::Test + def setup + @api = Hive::Bridge.new(url: TEST_NODE) + @jsonrpc = Jsonrpc.new(url: TEST_NODE) + @methods = @jsonrpc.get_api_methods[@api.class.api_name] rescue Fallback::API_METHODS[:bridge] + end + + def test_api_class_name + assert_equal 'Bridge', Hive::Bridge::api_class_name + end + + def test_inspect + assert_equal "#<Bridge [@chain=hive, @methods=<5 elements>]>", @api.inspect + end + + def test_method_missing + assert_raises NoMethodError do + @api.bogus + end + end + + def test_all_respond_to + @methods.each do |key| + assert @api.respond_to?(key), "expect rpc respond to #{key}" + end + end + + def test_account_notifications + vcr_cassette('bridge_account_notifications', record: :once) do + options = { + account: 'alice', + limit: 10 + } + + @api.account_notifications(options) do |result| + assert_equal Hashie::Array, result.class + end + end + end + + def test_get_community + vcr_cassette('bridge_get_community', record: :once) do + options = { + name: 'hive-100525', + observer: 'alice' + } + + @api.get_community(options) do |result| + assert_equal Hashie::Mash, result.class + end + end + end + + def test_get_ranked_posts + vcr_cassette('bridge_get_ranked_posts', record: :once) do + options = { + sort: 'trending', + tag: '', + observer: 'alice' + } + + @api.get_ranked_posts(options) do |result| + assert_equal Hashie::Array, result.class + end + end + end + + def test_list_all_subscriptions + vcr_cassette('bridge_list_all_subscriptions', record: :once) do + options = { + account: 'alice' + } + + @api.list_all_subscriptions(options) do |result| + assert_equal Hashie::Array, result.class + end + end + end + + def test_list_community_roles + vcr_cassette('bridge_list_community_roles', record: :once) do + options = { + community: 'hive-100525' + } + + @api.list_community_roles(options) do |result| + assert_equal Hashie::Array, result.class + end + end + end + end +end diff --git a/test/steem/broadcast_test.rb b/test/hive/broadcast_test.rb similarity index 91% rename from test/steem/broadcast_test.rb rename to test/hive/broadcast_test.rb index f1f5b22..03c30d5 100644 --- a/test/steem/broadcast_test.rb +++ b/test/hive/broadcast_test.rb @@ -1,7 +1,8 @@ require 'test_helper' -module Steem - class BroadcastTest < Steem::Test +module Hive + class BroadcastTest < Hive::Test + WARNINGS_SEEN = {} OPS = %i(account_create account_update account_witness_proxy account_witness_vote change_recovery_account comment convert custom custom_binary custom_json delete_comment escrow_dispute escrow_transfer @@ -11,14 +12,20 @@ module Steem witness_set_properties create_claimed_account claim_account) def setup - app_base = false # TODO: Randomly set true or false to test differences. + app_base = false # todo: randomly set true or false to test differences. if app_base - @database_api = Steem::DatabaseApi.new(url: TEST_NODE) - @block_api = Steem::BlockApi.new(url: TEST_NODE) - @network_broadcast_api = Steem::NetworkBroadcastApi.new(url: TEST_NODE) + @database_api = Hive::DatabaseApi.new(url: TEST_NODE) + @block_api = Hive::BlockApi.new(url: TEST_NODE) + @network_broadcast_api = Hive::NetworkBroadcastApi.new(url: TEST_NODE) else - @database_api = @block_api = @network_broadcast_api = Steem::CondenserApi.new(url: TEST_NODE) + unless !!WARNINGS_SEEN[:app_base] + warn "AppBase disabled." + + WARNINGS_SEEN[:app_base] = true + end + + @database_api = @block_api = @network_broadcast_api = Hive::CondenserApi.new(url: TEST_NODE) end @jsonrpc = Jsonrpc.new(url: TEST_NODE) @@ -35,6 +42,10 @@ module Steem pretend: @pretend } + @core_symbol, @debt_symbol, @vest_symbol = @database_api.get_dynamic_global_properties do |dgpo| + [dgpo.current_supply.split(' ').last, dgpo.current_sbd_supply.split(' ').last, dgpo.total_vesting_shares.split(' ').last] + end + fail 'Are you nuts?' if OPS.include? :decline_voting_rights end @@ -42,7 +53,7 @@ module Steem options = { params: { voter: @account_name, - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 } @@ -60,8 +71,8 @@ module Steem end # Originally tested this without setting `pretend: true` and got this, so - # we know it works: - # https://steemd.com/tx/1ab30d6fef305121ee82e53b04605a641a79459d + # we know it worked (back when it was developed for Steem): + # https://hiveblocks.com/tx/1ab30d6fef305121ee82e53b04605a641a79459d def test_vote_multisig options = { wif: [ @@ -91,7 +102,7 @@ module Steem options = { params: { voter: @account_name, - author: 'steemit', + author: 'hiveio', permlink: 'WRONG', weight: 10000 }, @@ -127,7 +138,7 @@ module Steem options = { params: { voter: @account_name, - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 'WRONG' } @@ -144,7 +155,7 @@ module Steem options = { params: { voter: @account_name, - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 } @@ -241,7 +252,7 @@ module Steem } } - assert_raises Steem::ArgumentError do + assert_raises Hive::ArgumentError do Broadcast.comment(@broadcast_options.merge(options)) end end @@ -272,7 +283,7 @@ module Steem parent_permlink: 'parent_permlink', title: 'title', body: 'body', - max_accepted_payout: '0.000 SBD', + max_accepted_payout: "0.000 #{@debt_symbol}", # allow_replies: false, allow_votes: false, allow_curation_rewards: false, @@ -315,7 +326,7 @@ module Steem params: { from: @account_name, to: 'alice', - amount: '0.000 STEEM', + amount: "0.000 #{@core_symbol}", memo: 'memo' } } @@ -332,7 +343,7 @@ module Steem params: { from: @account_name, to: 'null', - amount: '0.000 STEEM' + amount: "0.000 #{@core_symbol}" } } @@ -363,8 +374,8 @@ module Steem params: { owner: @account_name, orderid: '1234', - amount_to_sell: '0.000 STEEM', - min_to_receive: '0.000 SBD', + amount_to_sell: "0.000 #{@core_symbol}", + min_to_receive: "0.000 #{@debt_symbol}", fill_or_kill: false, expiration: (Time.now.utc + 300) } @@ -397,14 +408,14 @@ module Steem params: { publisher: @account_name, exchange_rate: { - base: '0.000 SBD', - quote: '0.000 STEEM', + base: "0.000 #{@debt_symbol}", + quote: "0.000 #{@core_symbol}", } } } vcr_cassette('broadcast_feed_publish') do - assert_raises Steem::ArgumentError do + assert_raises Hive::ArgumentError do Broadcast.feed_publish(@broadcast_options.merge(options)) end end @@ -415,7 +426,7 @@ module Steem params: { owner: @account_name, requestid: '1234', - amount: '0.000 SBD' + amount: "0.000 #{@debt_symbol}" } } @@ -429,7 +440,7 @@ module Steem def test_account_create options = { params: { - fee: '0.000 STEEM', + fee: "0.000 #{@core_symbol}", creator: @account_name, new_account_name: 'alice', owner: { @@ -467,7 +478,7 @@ module Steem } } - assert_raises Steem::ArgumentError do + assert_raises Hive::ArgumentError do Broadcast.account_create(@broadcast_options.merge(options)) end end @@ -543,7 +554,7 @@ module Steem } } - assert_raises Steem::ArgumentError do + assert_raises Hive::ArgumentError do Broadcast.account_update(@broadcast_options.merge(options)) end end @@ -614,7 +625,8 @@ module Steem def test_account_update_empty options = { params: { - account: @account_name + account: @account_name, + json_metadata: '{}' } } @@ -632,11 +644,11 @@ module Steem url: '', block_signing_key: 'STM8ZSyzjPm48GmUuMSRufkVYkwYbZzbxeMysAVp7KFQwbTf98TcG', props: { - account_creation_fee: '0.000 STEEM', + account_creation_fee: "0.000 #{@core_symbol}", maximum_block_size: 131072, sbd_interest_rate:1000 }, - fee: '0.000 STEEM' + fee: "0.000 #{@core_symbol}" } } @@ -652,12 +664,12 @@ module Steem params: { owner: @account_name, props: { - account_creation_fee: '0.000 STEEM', + account_creation_fee: "0.000 #{@core_symbol}", maximum_block_size: 131072, sbd_interest_rate: 1000, account_subsidy_budget: 50000, account_subsidy_decay: 330782, - sbd_exchange_rate: {base: '1.000 SBD', quote: '1.000 STEEM'}, + sbd_exchange_rate: {base: '1.000 HBD', quote: '1.000 HIVE'}, url: 'https://steemit.com', new_signing_key: 'STM8LoQjQqJHvotqBo7HjnqmUbFW9oJ2theyqonzUd9DdJ7YYHsvD' } @@ -742,7 +754,7 @@ module Steem required_auths: [], required_posting_auths: [@account_name], id: 'follow', - json: '["follow",{"follower":"steemit","following":"alice","what":["blog"]}]' + json: '["follow",{"follower":"hiveio","following":"alice","what":["blog"]}]' } } @@ -763,12 +775,12 @@ module Steem required_auths: [], required_posting_auths: [@account_name], id: 'follow', - data: ["follow",{"follower":"steemit","following":"alice","what":["blog"]}], - json: '["follow",{"follower":"steemit","following":"alice","what":["blog"]}]' + data: ["follow",{"follower":"hiveio","following":"alice","what":["blog"]}], + json: '["follow",{"follower":"hiveio","following":"alice","what":["blog"]}]' } } - assert_raises Steem::ArgumentError do + assert_raises Hive::ArgumentError do Broadcast.custom_json(@broadcast_options.merge(options)) end end @@ -859,9 +871,9 @@ module Steem to: 'alice', agent: 'bob', escrow_id: 1234, - sbd_amount: '0.000 SBD', - steem_amount: '0.000 STEEM', - fee: '0.000 STEEM', + sbd_amount: "0.000 #{@debt_symbol}", + steem_amount: "0.000 #{@core_symbol}", + fee: "0.000 #{@core_symbol}", ratification_deadline: (Time.now.utc + 300), escrow_expiration: (Time.now.utc + 3000), json_meta: '{}' @@ -884,7 +896,7 @@ module Steem } } - assert_raises Steem::ArgumentError do + assert_raises Hive::ArgumentError do Broadcast.escrow_transfer(@broadcast_options.merge(options)) end end @@ -916,8 +928,8 @@ module Steem who: 'alice', receiver: 'alice', escrow_id: '1234', - sbd_amount: '0.000 SBD', - steem_amount: '0.000 STEEM' + sbd_amount: "0.000 #{@debt_symbol}", + steem_amount: "0.000 #{@core_symbol}" } } @@ -952,7 +964,7 @@ module Steem params: { from: @account_name, to: 'alice', - amount: '0.000 SBD', + amount: "0.000 #{@debt_symbol}", memo: 'memo' } } @@ -970,7 +982,7 @@ module Steem from: @account_name, request_id: '1234', to: 'bob', - amount: '0.000 SBD', + amount: "0.000 #{@debt_symbol}", memo: 'memo' } } @@ -1033,7 +1045,7 @@ module Steem def test_account_create_with_delegation options = { params: { - fee: '0.000 STEEM', + fee: "0.000 #{@core_symbol}", delegation: '0.000000 VESTS', creator: @account_name, new_account_name: 'alice', @@ -1073,7 +1085,7 @@ module Steem } } - assert_raises Steem::ArgumentError do + assert_raises Hive::ArgumentError do Broadcast.account_create_with_delegation(@broadcast_options.merge(options)) end end @@ -1082,7 +1094,7 @@ module Steem options = { params: { creator: @account_name, - fee: '0.000 STEEM', + fee: "0.000 #{@core_symbol}", extensions: [] } } @@ -1101,7 +1113,7 @@ module Steem vcr_cassette('broadcast_fake_op') do assert_raises UnknownOperationError do - Steem::Broadcast.process(@broadcast_options.merge(options)) + Hive::Broadcast.process(@broadcast_options.merge(options)) end end end diff --git a/test/steem/database_api_test.rb b/test/hive/database_api_test.rb similarity index 83% rename from test/steem/database_api_test.rb rename to test/hive/database_api_test.rb index 273ca29..01d2012 100644 --- a/test/steem/database_api_test.rb +++ b/test/hive/database_api_test.rb @@ -1,20 +1,20 @@ require 'test_helper' -module Steem - class DatabaseApiTest < Steem::Test +module Hive + class DatabaseApiTest < Hive::Test include Utils def setup - @api = Steem::DatabaseApi.new(url: TEST_NODE) + @api = Hive::DatabaseApi.new(url: TEST_NODE) @jsonrpc = Jsonrpc.new(url: TEST_NODE) @methods = @jsonrpc.get_api_methods[@api.class.api_name] end def test_api_class_name - assert_equal 'DatabaseApi', Steem::DatabaseApi::api_class_name + assert_equal 'DatabaseApi', Hive::DatabaseApi::api_class_name end def test_inspect - assert_equal "#<DatabaseApi [@chain=steem, @methods=<47 elements>]>", @api.inspect + assert_equal "#<DatabaseApi [@chain=hive, @methods=<50 elements>]>", @api.inspect end def test_method_missing @@ -31,7 +31,7 @@ module Steem def test_find_account_recovery_requests vcr_cassette('database_api_find_account_recovery_requests', record: :once) do - @api.find_account_recovery_requests(accounts: ['steemit']) do |result| + @api.find_account_recovery_requests(accounts: ['hiveio']) do |result| assert_equal Hashie::Array, result.requests.class end end @@ -39,7 +39,7 @@ module Steem def test_find_accounts vcr_cassette('database_api_find_accounts', record: :once) do - @api.find_accounts(accounts: ['steemit']) do |result| + @api.find_accounts(accounts: ['hiveio']) do |result| assert_equal Hashie::Array, result.accounts.class end end @@ -47,7 +47,7 @@ module Steem def test_find_change_recovery_account_requests vcr_cassette('database_api_find_change_recovery_account_requests', record: :once) do - @api.find_change_recovery_account_requests(accounts: ['steemit']) do |result| + @api.find_change_recovery_account_requests(accounts: ['hiveio']) do |result| assert_equal Hashie::Array, result.requests.class end end @@ -55,7 +55,7 @@ module Steem def test_find_comments vcr_cassette('database_api_find_comments', record: :once) do - @api.find_comments(comments: [['steemit', 'firstpost']]) do |result| + @api.find_comments(comments: [['hiveio', 'firstpost']]) do |result| assert_equal Hashie::Array, result.comments.class end end @@ -63,7 +63,7 @@ module Steem def test_find_decline_voting_rights_requests vcr_cassette('database_api_find_decline_voting_rights_requests', record: :once) do - @api.find_decline_voting_rights_requests(accounts: ['steemit']) do |result| + @api.find_decline_voting_rights_requests(accounts: ['hiveio']) do |result| assert_equal Hashie::Array, result.requests.class end end @@ -71,7 +71,7 @@ module Steem def test_find_escrows vcr_cassette('database_api_find_escrows', record: :once) do - @api.find_escrows(from: 'steemit') do |result| + @api.find_escrows(from: 'hiveio') do |result| assert_equal Hashie::Array, result.escrows.class end end @@ -79,7 +79,7 @@ module Steem def test_find_limit_orders vcr_cassette('database_api_find_limit_orders', record: :once) do - @api.find_limit_orders(account: 'steemit') do |result| + @api.find_limit_orders(account: 'hiveio') do |result| assert_equal Hashie::Array, result.orders.class end end @@ -87,7 +87,7 @@ module Steem def test_find_owner_histories vcr_cassette('database_api_find_owner_histories', record: :once) do - @api.find_owner_histories(owner: 'steemit') do |result| + @api.find_owner_histories(owner: 'hiveio') do |result| assert_equal Hashie::Array, result.owner_auths.class end end @@ -95,7 +95,7 @@ module Steem def test_find_savings_withdrawals vcr_cassette('database_api_find_savings_withdrawals', record: :once) do - @api.find_savings_withdrawals(account: 'steemit') do |result| + @api.find_savings_withdrawals(account: 'hiveio') do |result| assert_equal Hashie::Array, result.withdrawals.class end end @@ -103,7 +103,7 @@ module Steem def test_find_sbd_conversion_requests vcr_cassette('database_api_find_sbd_conversion_requests', record: :once) do - @api.find_sbd_conversion_requests(account: 'steemit') do |result| + @api.find_sbd_conversion_requests(account: 'hiveio') do |result| assert_equal Hashie::Array, result.requests.class end end @@ -111,7 +111,7 @@ module Steem def test_find_vesting_delegation_expirations vcr_cassette('database_api_find_vesting_delegation_expirations', record: :once) do - @api.find_vesting_delegation_expirations(account: 'steemit') do |result| + @api.find_vesting_delegation_expirations(account: 'hiveio') do |result| assert_equal Hashie::Array, result.delegations.class end end @@ -119,7 +119,7 @@ module Steem def test_find_vesting_delegations vcr_cassette('database_api_find_vesting_delegations', record: :once) do - @api.find_vesting_delegations(account: 'steemit') do |result| + @api.find_vesting_delegations(account: 'hiveio') do |result| assert_equal Hashie::Array, result.delegations.class end end @@ -127,7 +127,7 @@ module Steem def test_find_votes vcr_cassette('database_api_find_votes', record: :once) do - @api.find_votes(author: 'steemit', permlink: 'firstpost') do |result| + @api.find_votes(author: 'hiveio', permlink: 'firstpost') do |result| assert_equal Hashie::Array, result.votes.class end end @@ -136,9 +136,9 @@ module Steem def test_find_withdraw_vesting_routes vcr_cassette('database_api_find_withdraw_vesting_routes', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L607 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L607 options = { - account: 'steemit', + account: 'hiveio', order: 'by_withdraw_route' } @@ -150,7 +150,7 @@ module Steem def test_find_witnesses vcr_cassette('database_api_find_witnesses', record: :once) do - @api.find_witnesses(owners: ['steemit']) do |result| + @api.find_witnesses(owners: ['hiveio']) do |result| assert_equal Hashie::Array, result.witnesses.class end end @@ -284,7 +284,7 @@ module Steem expiration: "2016-03-23T22:41:21", operations: [{ type: :account_create_operation, value: { - fee: {amount: '0', precision: 3, nai: '@@000000021'}, # 0.000 STEEM + fee: {amount: '0', precision: 3, nai: '@@000000021'}, # 0.000 HIVE creator: "initminer", new_account_name: "scott", owner: { @@ -339,7 +339,7 @@ module Steem def test_list_account_recovery_requests vcr_cassette('database_api_list_account_recovery_requests', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L406 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L406 options = { start: nil, limit: 0, @@ -355,7 +355,7 @@ module Steem def test_list_accounts vcr_cassette('database_api_list_accounts', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L307 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L307 options = { start: nil, limit: 0, @@ -371,7 +371,7 @@ module Steem def test_list_change_recovery_account_requests vcr_cassette('database_api_list_change_recovery_account_requests', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L460 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L460 options = { start: nil, limit: 0, @@ -387,9 +387,9 @@ module Steem def test_list_comments vcr_cassette('database_api_list_comments', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L941 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L941 options = { - start: ['2016-03-24T16:00:00', 'steemit', 'firstpost'], + start: ['2016-03-24T16:00:00', 'hiveio', 'firstpost'], limit: 0, order: 'by_cashout_time' } @@ -403,7 +403,7 @@ module Steem def test_list_decline_voting_rights_requests vcr_cassette('database_api_list_decline_voting_rights_requests', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L867 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L867 options = { start: nil, limit: 0, @@ -419,9 +419,9 @@ module Steem def test_list_escrows vcr_cassette('database_api_list_escrows', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L515 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L515 options = { - start: ['steemit'], + start: ['hiveio'], limit: 0, order: 'by_from_id' } @@ -435,7 +435,7 @@ module Steem def test_list_limit_orders vcr_cassette('database_api_list_limit_orders', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L1278 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L1278 options = { start: [], limit: 0, @@ -459,7 +459,7 @@ module Steem def test_list_sbd_conversion_requests vcr_cassette('database_api_list_sbd_conversion_requests', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L814 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L814 options = { start: [], limit: 0, @@ -475,7 +475,7 @@ module Steem def test_list_vesting_delegation_expirations vcr_cassette('database_api_list_vesting_delegation_expirations', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L759 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L759 options = { start: [], limit: 0, @@ -491,7 +491,7 @@ module Steem def test_list_vesting_delegations vcr_cassette('database_api_list_vesting_delegations', record: :once) do # by_delegation is the only known order types: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L705 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L705 options = { start: [], limit: 0, @@ -507,7 +507,7 @@ module Steem def test_list_votes vcr_cassette('database_api_list_votes', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L1125 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L1125 options = { start: [nil, nil, nil], limit: 0, @@ -523,7 +523,7 @@ module Steem def test_list_withdraw_vesting_routes vcr_cassette('database_api_list_withdraw_vesting_routes', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L759 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L759 options = { start: [], limit: 0, @@ -539,7 +539,7 @@ module Steem def test_list_witness_votes vcr_cassette('database_api_list_witness_votes', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L252 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L252 options = { start: [], limit: 0, @@ -555,9 +555,9 @@ module Steem def test_list_witnesses vcr_cassette('database_api_list_witnesses', record: :once) do # Other order types are listed here: - # https://github.com/steemit/steem/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L188 + # https://github.com/openhive-network/hive/blob/1cfdf8101ec415156b155c9ec90b0a4d439a039f/libraries/plugins/apis/database_api/database_api.cpp#L188 options = { - start: 'steemit', + start: 'hiveio', limit: 0, order: 'by_name' } @@ -571,9 +571,9 @@ module Steem def test_verify_account_authority vcr_cassette('database_api_verify_account_authority', record: :once) do @api.get_config do |config| - prefix = config.STEEM_ADDRESS_PREFIX + prefix = config.HIVE_ADDRESS_PREFIX options = { - account: 'steemit', + account: 'hiveio', signers: ["#{prefix}7Q2rLBqzPzFeteQZewv9Lu3NLE69fZoLeL6YK59t7UmssCBNTU"] } @@ -627,7 +627,7 @@ module Steem assert_raises NoMethodError do @api.get_version end - when '0.20.0' + when '0.20.0', '0.23.0' @api.get_version do |version| assert version.chain_id end @@ -658,7 +658,7 @@ module Steem extensions: [] } - api = Steem::DatabaseApi.new(url: 'https://testnet.steemitdev.com') + api = Hive::DatabaseApi.new(url: NETWORKS_TEST_DEFAULT_NODE) rescue skip('unable to test computed trx_id') api.get_transaction_hex(trx: trx) do |result| # Sometimes testnet is unstable. diff --git a/test/steem/follow_api_test.rb b/test/hive/follow_api_test.rb similarity index 85% rename from test/steem/follow_api_test.rb rename to test/hive/follow_api_test.rb index e79355f..3cfceb6 100644 --- a/test/steem/follow_api_test.rb +++ b/test/hive/follow_api_test.rb @@ -1,18 +1,18 @@ require 'test_helper' -module Steem - class FollowApiTest < Steem::Test +module Hive + class FollowApiTest < Hive::Test def setup - @api = Steem::FollowApi.new(url: TEST_NODE) + @api = Hive::FollowApi.new(url: TEST_NODE) rescue skip('follow_api not supported') @jsonrpc = Jsonrpc.new(url: TEST_NODE) @methods = @jsonrpc.get_api_methods[@api.class.api_name] end def test_api_class_name - assert_equal 'FollowApi', Steem::FollowApi::api_class_name + assert_equal 'FollowApi', Hive::FollowApi::api_class_name end def test_inspect - assert_equal "#<FollowApi [@chain=steem, @methods=<10 elements>]>", @api.inspect + assert_equal "#<FollowApi [@chain=hive, @methods=<10 elements>]>", @api.inspect end def test_method_missing @@ -30,7 +30,7 @@ module Steem def test_get_account_reputations vcr_cassette('follow_api_get_account_reputations', record: :once) do options = { - account_lower_bound: 'steemit', + account_lower_bound: 'hiveio', limit: 0 } @@ -43,7 +43,7 @@ module Steem def test_get_blog vcr_cassette('follow_api_get_blog', record: :once) do options = { - account: 'steemit', + account: 'hiveio', start_entry_id: 0, limit: 0 } @@ -57,7 +57,7 @@ module Steem def test_get_blog_authors vcr_cassette('follow_api_get_blog_authors', record: :once) do options = { - blog_account: 'steemit' + blog_account: 'hiveio' } @api.get_blog_authors(options) do |result| @@ -69,7 +69,7 @@ module Steem def test_get_blog_entries vcr_cassette('follow_api_get_blog_entries', record: :once) do options = { - account: 'steemit', + account: 'hiveio', start_entry_id: 0, limit: 0 } @@ -83,7 +83,7 @@ module Steem def test_get_feed vcr_cassette('follow_api_get_feed', record: :once) do options = { - account: 'steemit', + account: 'hiveio', start_entry_id: 0, limit: 0 } @@ -97,7 +97,7 @@ module Steem def test_get_feed_entries vcr_cassette('follow_api_get_feed_entries', record: :once) do options = { - account: 'steemit', + account: 'hiveio', start_entry_id: 0, limit: 0 } @@ -111,12 +111,12 @@ module Steem def test_get_follow_count vcr_cassette('follow_api_get_follow_count', record: :once) do options = { - account: 'steemit' + account: 'hiveio' } @api.get_follow_count(options) do |result| assert_equal Hashie::Mash, result.class - assert_equal 'steemit', result.account + assert_equal 'hiveio', result.account follower_count = result.follower_count following_count = result.following_count skip "Fixnum is deprecated." if follower_count.class.to_s == 'Fixnum' @@ -129,7 +129,7 @@ module Steem def test_get_followers vcr_cassette('follow_api_get_followers', record: :once) do options = { - account: 'steemit', + account: 'hiveio', start: nil, type: 'blog', limit: 0 @@ -144,7 +144,7 @@ module Steem def test_get_following vcr_cassette('follow_api_get_following', record: :once) do options = { - account: 'steemit', + account: 'hiveio', start: nil, type: 'blog', limit: 0 @@ -159,7 +159,7 @@ module Steem def test_get_reblogged_by vcr_cassette('follow_api_get_reblogged_by', record: :once) do options = { - author: 'steemit', + author: 'hiveio', permlink: 'firstpost' } @@ -169,4 +169,4 @@ module Steem end end end -end \ No newline at end of file +end diff --git a/test/steem/formatter_test.rb b/test/hive/formatter_test.rb similarity index 78% rename from test/steem/formatter_test.rb rename to test/hive/formatter_test.rb index b3f6184..c27c726 100644 --- a/test/steem/formatter_test.rb +++ b/test/hive/formatter_test.rb @@ -1,7 +1,7 @@ require 'test_helper' -module Steem - class FormatterTest < Steem::Test +module Hive + class FormatterTest < Hive::Test def test_reputation assert_equal 25.0, Formatter.reputation(0) assert_equal 70.9, Formatter.reputation(124729459033169) diff --git a/test/steem/jsonrpc_test.rb b/test/hive/jsonrpc_test.rb similarity index 80% rename from test/steem/jsonrpc_test.rb rename to test/hive/jsonrpc_test.rb index 7a2bd0f..e934125 100644 --- a/test/steem/jsonrpc_test.rb +++ b/test/hive/jsonrpc_test.rb @@ -1,7 +1,7 @@ require 'test_helper' -module Steem - class JsonrpcTest < Steem::Test +module Hive + class JsonrpcTest < Hive::Test def setup @jsonrpc = Jsonrpc.new(url: TEST_NODE) end @@ -13,12 +13,13 @@ module Steem def test_get_api_methods vcr_cassette('jsonrpc_get_methods', record: :once) do apis = @jsonrpc.get_api_methods + apis.delete(:bridge) assert_equal Hashie::Mash, apis.class expected_apis = { - account_by_key_api: [ - "get_key_references" - ], + # account_by_key_api: [ + # "get_key_references" + # ], block_api: [ "get_block", "get_block_header" @@ -107,7 +108,10 @@ module Steem "lookup_accounts", "lookup_witness_accounts", "verify_account_authority", - "verify_authority" + "verify_authority", + "find_proposals", + "list_proposal_votes", + "list_proposals" ], database_api: [ "find_account_recovery_requests", @@ -156,69 +160,75 @@ module Steem "list_witnesses", "verify_account_authority", "verify_authority", - "verify_signatures" - ], - follow_api: [ - "get_account_reputations", - "get_blog", - "get_blog_authors", - "get_blog_entries", - "get_feed", - "get_feed_entries", - "get_follow_count", - "get_followers", - "get_following", - "get_reblogged_by" + "verify_signatures", + "find_proposals", + "list_proposal_votes", + "list_proposals" ], + # follow_api: [ + # "get_account_reputations", + # "get_blog", + # "get_blog_authors", + # "get_blog_entries", + # "get_feed", + # "get_feed_entries", + # "get_follow_count", + # "get_followers", + # "get_following", + # "get_reblogged_by" + # ], jsonrpc: [ "get_methods", "get_signature" ], - market_history_api: [ - "get_market_history", - "get_market_history_buckets", - "get_order_book", - "get_recent_trades", - "get_ticker", - "get_trade_history", - "get_volume" - ], - network_broadcast_api: [ - "broadcast_block", - "broadcast_transaction" - ], - rc_api: [ - "find_rc_accounts", - "get_resource_params", - "get_resource_pool" - ], - tags_api: [ - "get_active_votes", - "get_comment_discussions_by_payout", - "get_content_replies", - "get_discussion", - "get_discussions_by_active", - "get_discussions_by_author_before_date", - "get_discussions_by_blog", - "get_discussions_by_cashout", - "get_discussions_by_children", - "get_discussions_by_comments", - "get_discussions_by_created", - "get_discussions_by_feed", - "get_discussions_by_hot", - "get_discussions_by_promoted", - "get_discussions_by_trending", - "get_discussions_by_votes", - "get_post_discussions_by_payout", - "get_replies_by_last_update", - "get_tags_used_by_author", - "get_trending_tags" + # market_history_api: [ + # "get_market_history", + # "get_market_history_buckets", + # "get_order_book", + # "get_recent_trades", + # "get_ticker", + # "get_trade_history", + # "get_volume" + # ], + # network_broadcast_api: [ + # "broadcast_block", + # "broadcast_transaction" + # ], + # rc_api: [ + # "find_rc_accounts", + # "get_resource_params", + # "get_resource_pool" + # ], + # tags_api: [ + # "get_active_votes", + # "get_comment_discussions_by_payout", + # "get_content_replies", + # "get_discussion", + # "get_discussions_by_active", + # "get_discussions_by_author_before_date", + # "get_discussions_by_blog", + # "get_discussions_by_cashout", + # "get_discussions_by_children", + # "get_discussions_by_comments", + # "get_discussions_by_created", + # "get_discussions_by_feed", + # "get_discussions_by_hot", + # "get_discussions_by_promoted", + # "get_discussions_by_trending", + # "get_discussions_by_votes", + # "get_post_discussions_by_payout", + # "get_replies_by_last_update", + # "get_tags_used_by_author", + # "get_trending_tags" + # ], + reputation_api: [ + "get_account_reputations" ] } api_names = expected_apis.keys.map(&:to_s) unexpected_apis = (api_names + apis.keys).uniq - api_names - missing_apis = (api_names + apis.keys).uniq - apis.keys + missing_apis = (api_names + apis.keys - ['bridge']).uniq - apis.keys assert_equal [], unexpected_apis, "found unexpected apis" assert_equal [], missing_apis, "missing expected apis" diff --git a/test/steem/market_history_api_test.rb b/test/hive/market_history_api_test.rb similarity index 88% rename from test/steem/market_history_api_test.rb rename to test/hive/market_history_api_test.rb index fc43999..408f782 100644 --- a/test/steem/market_history_api_test.rb +++ b/test/hive/market_history_api_test.rb @@ -1,19 +1,19 @@ require 'test_helper' -module Steem - class MarketHistoryApiTest < Steem::Test +module Hive + class MarketHistoryApiTest < Hive::Test def setup - @api = Steem::MarketHistoryApi.new(url: TEST_NODE) + @api = Hive::MarketHistoryApi.new(url: TEST_NODE) rescue skip('market_history_api not supported') @jsonrpc = Jsonrpc.new(url: TEST_NODE) @methods = @jsonrpc.get_api_methods[@api.class.api_name] end def test_api_class_name - assert_equal 'MarketHistoryApi', Steem::MarketHistoryApi::api_class_name + assert_equal 'MarketHistoryApi', Hive::MarketHistoryApi::api_class_name end def test_inspect - assert_equal "#<MarketHistoryApi [@chain=steem, @methods=<7 elements>]>", @api.inspect + assert_equal "#<MarketHistoryApi [@chain=hive, @methods=<7 elements>]>", @api.inspect end def test_method_missing @@ -96,4 +96,4 @@ module Steem end end end -end \ No newline at end of file +end diff --git a/test/steem/marshal_test.rb b/test/hive/marshal_test.rb similarity index 94% rename from test/steem/marshal_test.rb rename to test/hive/marshal_test.rb index 44d395c..872359a 100644 --- a/test/steem/marshal_test.rb +++ b/test/hive/marshal_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -module Steem - class MarshalTest < Steem::Test +module Hive + class MarshalTest < Hive::Test include Utils def setup - @database_api = Steem::DatabaseApi.new + @database_api = Hive::DatabaseApi.new(url: TEST_NODE) end def test_trx_example_1 @@ -44,8 +44,8 @@ module Steem assert_equal :limit_order_create_operation, marshal.operation_type, 'expect operation type: limit_order_create_operation' assert_equal 'gavvet', marshal.string, 'expect owner: gavvet' assert_equal 1467919074, marshal.uint32, 'expect order_id: 1467919074' - assert_equal Type::Amount.new('19.477 SBD').to_s, marshal.amount.to_s, 'expect amount_to_sell: 19.477 SBD' - assert_equal Type::Amount.new('67.164 STEEM').to_s, marshal.amount.to_s, 'expect min_to_receive: 67.164 STEEM' + assert_equal Type::Amount.new('19.477 HBD').to_s, marshal.amount.to_s, 'expect amount_to_sell: 19.477 HBD' + assert_equal Type::Amount.new('67.164 HIVE').to_s, marshal.amount.to_s, 'expect min_to_receive: 67.164 HIVE' assert_equal false, marshal.boolean, 'expect fill_or_kill: false' assert_equal Time.parse('1969-12-31T23:59:59Z'), marshal.point_in_time, 'expect expiration: 1969-12-31T23:59:59Z' end @@ -90,7 +90,7 @@ module Steem end def test_trx_ad_hoc_1 - builder = Steem::TransactionBuilder.new + builder = Hive::TransactionBuilder.new(url: TEST_NODE) builder.put(account_update_operation: { account: 'social', @@ -115,7 +115,7 @@ module Steem end def test_trx_ad_hoc_2 - builder = Steem::TransactionBuilder.new + builder = Hive::TransactionBuilder.new(url: TEST_NODE) builder.put(comment_operation: { "parent_author": "", @@ -145,7 +145,7 @@ module Steem end def test_trx_ad_hoc_3 - builder = Steem::TransactionBuilder.new + builder = Hive::TransactionBuilder.new(url: TEST_NODE) builder.put(account_update_operation: { account: 'social', @@ -201,16 +201,16 @@ module Steem end def test_trx_ad_hoc_4 - builder = Steem::TransactionBuilder.new + builder = Hive::TransactionBuilder.new(url: TEST_NODE) builder.put(escrow_transfer: { # FIXME Why do we have to use escrow_transfer and not :escrow_transfer_operation here? from: 'social', to: 'alice', agent: 'bob', escrow_id: 1234, - sbd_amount: '0.000 SBD', - steem_amount: '0.000 STEEM', - fee: '0.000 STEEM', + sbd_amount: '0.000 HBD', + steem_amount: '0.000 HIVE', + fee: '0.000 HIVE', ratification_deadline: '2018-10-15T19:52:09', escrow_expiration: '2018-10-15T19:52:09', json_meta: '{}' @@ -226,18 +226,18 @@ module Steem assert_equal :escrow_transfer_operation, marshal.operation_type, 'expect operation type: escrow_transfer_operation' assert_equal 'social', marshal.string, 'expect from: social' assert_equal 'alice', marshal.string, 'expect to: alice' - assert_equal '0.000 SBD', marshal.amount.to_s, 'expect sbd_amount: 0.000 SBD' - assert_equal '0.000 STEEM', marshal.amount.to_s, 'expect steem_amount: 0.000 STEEM' + assert_equal '0.000 HBD', marshal.amount.to_s, 'expect sbd_amount: 0.000 HBD' + assert_equal '0.000 HIVE', marshal.amount.to_s, 'expect steem_amount: 0.000 HIVE' assert_equal 1234, marshal.uint32, 'expect escrow_id: 1234' assert_equal 'bob', marshal.string, 'expect agent: bob' - assert_equal '0.000 STEEM', marshal.amount.to_s, 'expect fee: 0.000 STEEM' + assert_equal '0.000 HIVE', marshal.amount.to_s, 'expect fee: 0.000 HIVE' assert_equal '{}', marshal.string, 'expect json_meta: {}' assert_equal Time.parse('2018-10-15 12:52:09 -0700'), marshal.point_in_time, 'expect escrow_expiration: 2018-10-15 12:52:09 -0700' assert_equal Time.parse('2018-10-15 12:52:09 -0700'), marshal.point_in_time, 'expect escrow_expiration: 2018-10-15 12:52:09 -0700' end def test_trx_ad_hoc_5 - builder = Steem::TransactionBuilder.new + builder = Hive::TransactionBuilder.new(url: TEST_NODE) builder.put(change_recovery_account_operation: { account_to_recover: 'alice', @@ -258,7 +258,7 @@ module Steem end def test_trx_ad_hoc_6 - builder = Steem::TransactionBuilder.new + builder = Hive::TransactionBuilder.new(url: TEST_NODE) builder.put(comment_operation: { author: 'alice', @@ -271,7 +271,7 @@ module Steem builder.put(comment_options: { # FIXME Why do we have to use comment_options and not :comment_options_operation here? author: 'alice', permlink: 'permlink', - max_accepted_payout: '1000000.000 SBD', + max_accepted_payout: '1000000.000 HBD', percent_steem_dollars: 10000, # allow_replies: true, allow_votes: true, @@ -306,7 +306,7 @@ module Steem assert_equal :comment_options_operation, marshal.operation_type, 'expect operation type: comment_options_operation' assert_equal 'alice', marshal.string, 'expect author: alice' assert_equal 'permlink', marshal.string, 'expect permlink: permlink' - assert_equal '1000000.000 SBD', marshal.amount.to_s, 'expect max_accepted_payout: 1000000.000 SBD' + assert_equal '1000000.000 HBD', marshal.amount.to_s, 'expect max_accepted_payout: 1000000.000 HBD' assert_equal 10000, marshal.uint16, 'expect percent_steem_dollars: 10000' # assert_equal true, marshal.boolean, 'expect allow_replies: true' assert_equal true, marshal.boolean, 'expect allow_votes: true' @@ -321,12 +321,12 @@ module Steem end def test_trx_ad_hoc_7 - builder = Steem::TransactionBuilder.new + builder = Hive::TransactionBuilder.new(url: TEST_NODE) builder.put(comment_options: { # FIXME Why do we have to use comment_options and not :comment_options_operation here? author: 'alice', permlink: 'permlink', - max_accepted_payout: '1000000.000 SBD', + max_accepted_payout: '1000000.000 HBD', percent_steem_dollars: 10000, # allow_replies: true, allow_votes: true, @@ -350,7 +350,7 @@ module Steem assert_equal :comment_options_operation, marshal.operation_type, 'expect operation type: comment_options_operation' assert_equal 'alice', marshal.string, 'expect author: alice' assert_equal 'permlink', marshal.string, 'expect permlink: permlink' - assert_equal '1000000.000 SBD', marshal.amount.to_s, 'expect max_accepted_payout: 1000000.000 SBD' + assert_equal '1000000.000 HBD', marshal.amount.to_s, 'expect max_accepted_payout: 1000000.000 HBD' assert_equal 10000, marshal.uint16, 'expect percent_steem_dollars: 10000' # assert_equal true, marshal.boolean, 'expect allow_replies: true' assert_equal true, marshal.boolean, 'expect allow_votes: true' diff --git a/test/steem/network_broadcast_api_test.rb b/test/hive/network_broadcast_api_test.rb similarity index 82% rename from test/steem/network_broadcast_api_test.rb rename to test/hive/network_broadcast_api_test.rb index 3b5883d..7a0b5b5 100644 --- a/test/steem/network_broadcast_api_test.rb +++ b/test/hive/network_broadcast_api_test.rb @@ -1,18 +1,18 @@ require 'test_helper' -module Steem - class NetworkBroadcastApiTest < Steem::Test +module Hive + class NetworkBroadcastApiTest < Hive::Test def setup - @api = Steem::NetworkBroadcastApi.new(url: TEST_NODE) + @api = Hive::NetworkBroadcastApi.new(url: TEST_NODE) rescue skip('network_broadcast_api not supported') @jsonrpc = Jsonrpc.new(url: TEST_NODE) @methods = @jsonrpc.get_api_methods[@api.class.api_name] end def test_api_class_name - assert_equal 'NetworkBroadcastApi', Steem::NetworkBroadcastApi::api_class_name + assert_equal 'NetworkBroadcastApi', Hive::NetworkBroadcastApi::api_class_name end def test_inspect - assert_equal "#<NetworkBroadcastApi [@chain=steem, @methods=<2 elements>]>", @api.inspect + assert_equal "#<NetworkBroadcastApi [@chain=hive, @methods=<2 elements>]>", @api.inspect end def test_method_missing @@ -67,4 +67,4 @@ module Steem end end end -end \ No newline at end of file +end diff --git a/test/steem/rc_api_test.rb b/test/hive/rc_api_test.rb similarity index 80% rename from test/steem/rc_api_test.rb rename to test/hive/rc_api_test.rb index a682596..4baf42d 100644 --- a/test/steem/rc_api_test.rb +++ b/test/hive/rc_api_test.rb @@ -1,19 +1,19 @@ require 'test_helper' -module Steem - class RcApiTest < Steem::Test +module Hive + class RcApiTest < Hive::Test def setup - @api = Steem::RcApi.new(url: TEST_NODE) + @api = Hive::RcApi.new(url: TEST_NODE) rescue skip('rc_api not supported') @jsonrpc = Jsonrpc.new(url: TEST_NODE) @methods = @jsonrpc.get_api_methods[@api.class.api_name] end def test_api_class_name - assert_equal 'RcApi', Steem::RcApi::api_class_name + assert_equal 'RcApi', Hive::RcApi::api_class_name end def test_inspect - assert_equal "#<RcApi [@chain=steem, @methods=<3 elements>]>", @api.inspect + assert_equal "#<RcApi [@chain=hive, @methods=<3 elements>]>", @api.inspect end def test_method_missing @@ -31,7 +31,7 @@ module Steem def test_find_rc_accounts vcr_cassette('rc_api_find_rc_accounts', record: :once) do options = { - accounts: ['steem'] + accounts: ['hive'] } @api.find_rc_accounts(options) do |result| diff --git a/test/steem/rpc_client_test.rb b/test/hive/rpc_client_test.rb similarity index 96% rename from test/steem/rpc_client_test.rb rename to test/hive/rpc_client_test.rb index 382a2f6..080f364 100644 --- a/test/steem/rpc_client_test.rb +++ b/test/hive/rpc_client_test.rb @@ -1,7 +1,7 @@ require 'test_helper' -module Steem - class RpcClientTest < Steem::Test +module Hive + class RpcClientTest < Hive::Test def setup @rpc_client = RPC::HttpClient.new(url: TEST_NODE) end diff --git a/test/steem/stream_test.rb b/test/hive/stream_test.rb similarity index 93% rename from test/steem/stream_test.rb rename to test/hive/stream_test.rb index ff132bd..57959f8 100644 --- a/test/steem/stream_test.rb +++ b/test/hive/stream_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -module Steem - class StreamTest < Steem::Test +module Hive + class StreamTest < Hive::Test def setup - @stream = Steem::Stream.new(url: TEST_NODE, no_warn: true) - @database_api = Steem::DatabaseApi.new(url: TEST_NODE) + @stream = Hive::Stream.new(url: TEST_NODE, no_warn: true) + @database_api = Hive::DatabaseApi.new(url: TEST_NODE) @database_api.get_dynamic_global_properties do |properties| @head_block_num = properties.head_block_number @@ -26,7 +26,7 @@ module Steem end def test_block_headers_mode_head - stream = Steem::Stream.new(url: TEST_NODE, mode: :head) + stream = Hive::Stream.new(url: TEST_NODE, mode: :head) options = { until_block_num: @head_block_num + 1 } @@ -40,13 +40,13 @@ module Steem end def test_block_headers_mode_bogus - stream = Steem::Stream.new(url: TEST_NODE, mode: :WRONG) + stream = Hive::Stream.new(url: TEST_NODE, mode: :WRONG) options = { until_block_num: @head_block_num + 1 } vcr_cassette('block_headers_mode_bogus') do - assert_raises Steem::ArgumentError do + assert_raises Hive::ArgumentError do stream.block_headers(options) do |block_header, block_num| fail 'should be unreachable' end diff --git a/test/steem/tags_api_test.rb b/test/hive/tags_api_test.rb similarity index 90% rename from test/steem/tags_api_test.rb rename to test/hive/tags_api_test.rb index 4360f79..314857f 100644 --- a/test/steem/tags_api_test.rb +++ b/test/hive/tags_api_test.rb @@ -1,18 +1,18 @@ require 'test_helper' -module Steem - class TagsApiTest < Steem::Test +module Hive + class TagsApiTest < Hive::Test def setup - @api = Steem::TagsApi.new(url: TEST_NODE) + @api = Hive::TagsApi.new(url: TEST_NODE) rescue skip('tags_api not supported') @jsonrpc = Jsonrpc.new(url: TEST_NODE) @methods = @jsonrpc.get_api_methods[@api.class.api_name] end def test_api_class_name - assert_equal 'TagsApi', Steem::TagsApi::api_class_name + assert_equal 'TagsApi', Hive::TagsApi::api_class_name end def test_inspect - assert_equal "#<TagsApi [@chain=steem, @methods=<20 elements>]>", @api.inspect + assert_equal "#<TagsApi [@chain=hive, @methods=<20 elements>]>", @api.inspect end def test_method_missing @@ -30,7 +30,7 @@ module Steem def test_get_active_votes vcr_cassette('tags_api_get_active_votes', record: :once) do options = { - author: 'steemit', + author: 'hiveio', permlink: 'firstpost' } @@ -60,7 +60,7 @@ module Steem def test_get_content_replies vcr_cassette('tags_api_get_content_replies', record: :once) do options = { - author: 'steemit', + author: 'hiveio', permlink: 'firstpost' } @@ -73,7 +73,7 @@ module Steem def test_get_discussion vcr_cassette('tags_api_get_discussion', record: :once) do options = { - author: 'steemit', + author: 'hiveio', permlink: 'firstpost' } @@ -103,7 +103,7 @@ module Steem def test_get_discussions_by_author_before_date vcr_cassette('tags_api_get_discussions_by_author_before_date', record: :once) do options = { - author: 'steemit', + author: 'hiveio', permlink: 'firstpost' } @@ -116,7 +116,7 @@ module Steem def test_get_discussions_by_blog vcr_cassette('tags_api_get_discussions_by_blog', record: :once) do options = { - tag: 'steemit', + tag: 'hiveio', limit: 0 } @@ -129,7 +129,7 @@ module Steem def test_get_discussions_by_cashout vcr_cassette('tags_api_get_discussions_by_cashout', record: :once) do options = { - tag: 'steem', + tag: 'hive', limit: 0 } @@ -142,7 +142,7 @@ module Steem def test_get_discussions_by_children vcr_cassette('tags_api_get_discussions_by_children', record: :once) do options = { - tag: 'steem', + tag: 'hive', limit: 0 } @@ -155,7 +155,7 @@ module Steem def test_get_discussions_by_comments vcr_cassette('tags_api_get_discussions_by_comments', record: :once) do options = { - start_author: 'steemit', + start_author: 'hiveio', start_permlink: 'firstpost', limit: 0 } @@ -169,7 +169,7 @@ module Steem def test_get_discussions_by_created vcr_cassette('tags_api_get_discussions_by_created', record: :once) do options = { - tag: 'steem', + tag: 'hive', limit: 0 } @@ -182,7 +182,7 @@ module Steem def test_get_discussions_by_feed vcr_cassette('tags_api_get_discussions_by_feed', record: :once) do options = { - tag: 'steem', + tag: 'hive', limit: 0 } @@ -195,7 +195,7 @@ module Steem def test_get_discussions_by_hot vcr_cassette('tags_api_get_discussions_by_hot', record: :once) do options = { - tag: 'steem', + tag: 'hive', limit: 0 } @@ -208,7 +208,7 @@ module Steem def test_get_discussions_by_promoted vcr_cassette('tags_api_get_discussions_by_promoted', record: :once) do options = { - tag: 'steem', + tag: 'hive', limit: 0 } @@ -221,7 +221,7 @@ module Steem def test_get_discussions_by_trending vcr_cassette('tags_api_get_discussions_by_trending', record: :once) do options = { - tag: 'steem', + tag: 'hive', limit: 0 } @@ -234,7 +234,7 @@ module Steem def test_get_discussions_by_votes vcr_cassette('tags_api_get_discussions_by_votes', record: :once) do options = { - tag: 'steem', + tag: 'hive', limit: 0 } @@ -247,7 +247,7 @@ module Steem def test_get_post_discussions_by_payout vcr_cassette('tags_api_get_post_discussions_by_payout', record: :once) do options = { - tag: 'steem', + tag: 'hive', limit: 0 } @@ -260,7 +260,7 @@ module Steem def test_get_replies_by_last_update vcr_cassette('tags_api_get_replies_by_last_update', record: :once) do options = { - start_parent_author: 'steemit', + start_parent_author: 'hiveio', start_permlink: 'firstpost', limit: 0 } @@ -273,7 +273,7 @@ module Steem def test_get_tags_used_by_author vcr_cassette('tags_api_get_tags_used_by_author', record: :once) do - @api.get_tags_used_by_author(author: 'steemit') do |result| + @api.get_tags_used_by_author(author: 'hiveio') do |result| assert_equal Hashie::Array, result.tags.class end end @@ -295,4 +295,4 @@ module Steem end end end -end \ No newline at end of file +end diff --git a/test/steem/testnet_test.rb b/test/hive/testnet_test.rb similarity index 89% rename from test/steem/testnet_test.rb rename to test/hive/testnet_test.rb index 8a05aaf..a3ac4c2 100644 --- a/test/steem/testnet_test.rb +++ b/test/hive/testnet_test.rb @@ -1,7 +1,7 @@ require 'test_helper' -module Steem - class TestnetTest < Steem::Test +module Hive + class TestnetTest < Hive::Test def setup @api = Api.new(url: TEST_NODE) @jsonrpc = Jsonrpc.new(url: TEST_NODE) @@ -9,7 +9,7 @@ module Steem @api.get_config do |result| unless result['IS_TEST_NET'] - skip "Skipped, because #{TEST_NODE} is not testnet. Instead, found chain id: #{result['STEEM_CHAIN_ID']}" + skip "Skipped, because #{TEST_NODE} is not testnet. Instead, found chain id: #{result['HIVE_CHAIN_ID']}" end end end @@ -25,4 +25,4 @@ module Steem end end end -end \ No newline at end of file +end diff --git a/test/steem/transaction_builder_test.rb b/test/hive/transaction_builder_test.rb similarity index 91% rename from test/steem/transaction_builder_test.rb rename to test/hive/transaction_builder_test.rb index 4bc743c..ce041b9 100644 --- a/test/steem/transaction_builder_test.rb +++ b/test/hive/transaction_builder_test.rb @@ -1,18 +1,19 @@ require 'test_helper' -module Steem - class TransactionBuilderTest < Steem::Test +module Hive + class TransactionBuilderTest < Hive::Test include ChainConfig def setup @wif = '5JrvPrQeBBvCRdjv29iDvkwn3EQYZ9jqfAHzrCyUvfbEbRkrYFC' @options = { - app_base: false + app_base: false, + url: TEST_NODE } end def test_transaction_builder_initialize - assert TransactionBuilder.new + assert TransactionBuilder.new(url: TEST_NODE) end def test_transaction_builder_initialize_testnet @@ -41,7 +42,7 @@ module Steem database_api: :bogus_api, block_api: :bogus_api, testnet: true, - chain_id: NETWORKS_STEEM_CHAIN_ID + chain_id: NETWORKS_HIVE_CHAIN_ID } assert_raises UnsupportedChainError do TransactionBuilder.new(@options.merge options) @@ -63,7 +64,7 @@ module Steem vcr_cassette 'transaction_builder_valid' do builder.put(vote: { voter: 'social', - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 }) @@ -82,7 +83,7 @@ module Steem builder.put(vote: { voter: 'social', - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 }) @@ -99,7 +100,7 @@ module Steem vcr_cassette 'transaction_builder_sign' do builder.put(vote: { voter: 'social', - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 }) @@ -110,7 +111,7 @@ module Steem end end - # Just like: https://github.com/steemit/steem-js/blob/1a0f872b81399cd98c1a86bed2f67e7cf8a279da/examples/multisig.js + # Just like: https://github.com/openhive-network/hive-js/blob/1a0f872b81399cd98c1a86bed2f67e7cf8a279da/examples/multisig.js def test_sign_multisig wifs = [ '5K2LA2ucS8b1GuFvVgZK6itKNE6fFMbDMX4GDtNHiczJESLGRd8', @@ -165,7 +166,7 @@ module Steem vcr_cassette 'transaction_builder_put' do builder.put(vote: { voter: 'social', - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 }) @@ -180,7 +181,7 @@ module Steem vcr_cassette 'transaction_builder_put_array' do builder.put([:vote, { voter: 'social', - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 }]) @@ -195,7 +196,7 @@ module Steem vcr_cassette 'transaction_builder_put_symbol' do builder.put(:vote, { voter: 'social', - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 }) @@ -210,7 +211,7 @@ module Steem vcr_cassette 'transaction_builder_put_string' do builder.put('vote', { voter: 'social', - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 }) @@ -225,7 +226,7 @@ module Steem vcr_cassette 'transaction_builder_sign' do builder.put(vote: { voter: 'social', - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 }) @@ -240,7 +241,7 @@ module Steem vcr_cassette 'transaction_builder_sign' do builder.put(vote: { voter: 'social', - author: 'steemit', + author: 'hiveio', permlink: 'firstpost', weight: 10000 }) diff --git a/test/steem/amount_test.rb b/test/steem/amount_test.rb deleted file mode 100644 index fbda79f..0000000 --- a/test/steem/amount_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'test_helper' - -module Steem - class AmountTest < Steem::Test - def setup - @amount = Steem::Type::Amount.new('0.000 STEEM') - end - - def test_to_s - assert_equal '0.000 SBD', Steem::Type::Amount.to_s(['0', 3, '@@000000013']) - assert_equal '0.000 STEEM', Steem::Type::Amount.to_s(['0', 3, '@@000000021']) - assert_equal '0.000000 VESTS', Steem::Type::Amount.to_s(['0', 6, '@@000000037']) - - assert_raises TypeError do - Steem::Type::Amount.to_s(['0', 3, '@@00000000']) - end - end - - def test_to_h - assert_equal({amount: '0', precision: 3, nai: '@@000000013'}, Steem::Type::Amount.to_h('0.000 SBD')) - assert_equal({amount: '0', precision: 3, nai: '@@000000021'}, Steem::Type::Amount.to_h('0.000 STEEM')) - assert_equal({amount: '0', precision: 6, nai: '@@000000037'}, Steem::Type::Amount.to_h('0.000000 VESTS')) - - assert_raises TypeError do - Steem::Type::Amount.to_h('0.000 BOGUS') - end - end - - def test_to_bytes - assert @amount.to_bytes - end - end -end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb index b7e2241..e5b55c6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -5,7 +5,7 @@ require 'simplecov' SimpleCov.start SimpleCov.merge_timeout 3600 -require 'steem' +require 'hive' require 'minitest/autorun' require 'minitest/line/describe_track' require 'webmock/minitest' @@ -28,14 +28,14 @@ end # before tests, outside test threads VCR.insert_cassette('global_cassette', record: :once, match_requests_on: [:method, :uri, :body]) -@jsonrpc = Steem::Jsonrpc.new +@jsonrpc = Hive::Jsonrpc.new @jsonrpc.get_api_methods # caches up methods -class Steem::Test < MiniTest::Test +class Hive::Test < MiniTest::Test defined? prove_it! and prove_it! - TEST_NODE = ENV.fetch 'TEST_NODE', Steem::ChainConfig::NETWORKS_STEEM_DEFAULT_NODE - # TEST_NODE = Steem::ChainConfig::NETWORKS_TEST_DEFAULT_NODE + TEST_NODE = ENV.fetch 'TEST_NODE', Hive::ChainConfig::NETWORKS_HIVE_DEFAULT_NODE + # TEST_NODE = Hive::ChainConfig::NETWORKS_TEST_DEFAULT_NODE # Most likely modes: 'once' and 'new_episodes' VCR_RECORD_MODE = (ENV['VCR_RECORD_MODE'] || 'new_episodes').to_sym @@ -46,8 +46,8 @@ class Steem::Test < MiniTest::Test VCR.use_cassette(name, options) do begin yield - rescue Steem::BaseError => e - skip "Probably just a node acting up: #{e}" + rescue Hive::BaseError => e + skip "Probably just a node acting up: #{e}\n#{e.backtrace.join("\n")}" rescue Psych::SyntaxError => e skip 'This happens when we try to get fancy and disable thread-safety.' end -- GitLab