hive-ruby 1.0.0 → 1.0.1.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +9 -9
- data/hive-ruby.gemspec +1 -1
- data/lib/hive/api.rb +3 -1
- data/lib/hive/base_error.rb +10 -3
- data/lib/hive/broadcast.rb +21 -21
- data/lib/hive/fallback.rb +2 -4
- data/lib/hive/jsonrpc.rb +1 -1
- data/lib/hive/marshal.rb +3 -3
- data/lib/hive/operation/claim_reward_balance.rb +2 -2
- data/lib/hive/operation/comment_options.rb +1 -1
- data/lib/hive/operation/escrow_release.rb +2 -2
- data/lib/hive/operation/escrow_transfer.rb +2 -2
- data/lib/hive/rpc/http_client.rb +2 -1
- data/lib/hive/stream.rb +1 -1
- data/lib/hive/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50723c6903e4538ef92d5a3a4cdfc146fbb9938f4f91295b2b12b249a4b212c8
|
4
|
+
data.tar.gz: daec42664d72059b4cad8a99b6bd9435fa3ea9e165af10b7a3705dee564dbe87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a4222e28deefa7c09ec7bc658b020d9c792dd951095d6919205f3e746846a1ab5bb0bcec791114bb4f520f65a5ebfc1f66132f4e0f4a94573cdea8baf49a7e6
|
7
|
+
data.tar.gz: 223882dca1d68224f45c4b07515776b82bb7785c9a8934ba9cc146ebd4f9599958a7a68a235e76dbc6aa3239a90060c866f1a0fdcd056e8c0ca5177abd793497
|
data/Rakefile
CHANGED
@@ -112,20 +112,20 @@ namespace :test do
|
|
112
112
|
[k, v] if keys.include? k.to_sym
|
113
113
|
end.compact.to_h
|
114
114
|
|
115
|
-
|
116
|
-
base =
|
115
|
+
hbd_exchange_rate = witness[:hbd_exchange_rate] || witness[:hbd_exchange_rate]
|
116
|
+
base = hbd_exchange_rate[:base].to_f
|
117
117
|
|
118
|
-
if (quote =
|
118
|
+
if (quote = hbd_exchange_rate[:quote].to_f) > 0
|
119
119
|
rate = (base / quote).round(3)
|
120
|
-
witnesses[witness.owner][:
|
120
|
+
witnesses[witness.owner][:hbd_exchange_rate] = rate
|
121
121
|
else
|
122
|
-
witnesses[witness.owner][:
|
122
|
+
witnesses[witness.owner][:hbd_exchange_rate] = nil
|
123
123
|
end
|
124
124
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
witnesses[witness.owner][:
|
125
|
+
last_hbd_exchange_update = witness[:last_hbd_exchange_update] || witness[:last_hbd_exchange_update]
|
126
|
+
last_hbd_exchange_update = Time.parse(last_hbd_exchange_update + 'Z')
|
127
|
+
last_hbd_exchange_elapsed = '%.2f hours ago' % ((Time.now.utc - last_hbd_exchange_update) / 60)
|
128
|
+
witnesses[witness.owner][:last_hbd_exchange_elapsed] = last_hbd_exchange_elapsed
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
data/hive-ruby.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency 'json', '~> 2.1', '>= 2.1.0'
|
34
34
|
spec.add_dependency 'logging', '~> 2.2', '>= 2.2.0'
|
35
35
|
spec.add_dependency 'hashie', '~> 3.5', '>= 3.5.7'
|
36
|
-
spec.add_dependency 'bitcoin-ruby', '~> 0.0', '
|
36
|
+
spec.add_dependency 'bitcoin-ruby', '~> 0.0', '0.0.20'
|
37
37
|
spec.add_dependency 'ffi', '~> 1.9', '>= 1.9.23'
|
38
38
|
spec.add_dependency 'bindata', '~> 2.4', '>= 2.4.4'
|
39
39
|
spec.add_dependency 'base58', '~> 0.2', '>= 0.2.3'
|
data/lib/hive/api.rb
CHANGED
@@ -118,7 +118,9 @@ module Hive
|
|
118
118
|
|
119
119
|
if Jsonrpc::UNLISTED_APIS.include? @api_name
|
120
120
|
@methods ||= {}
|
121
|
-
@methods[@api_name] ||=
|
121
|
+
@methods[@api_name] ||= []
|
122
|
+
@methods[@api_name] += Fallback::API_METHODS[@api_name]
|
123
|
+
@methods[@api_name] = @methods[@api_name].uniq
|
122
124
|
end
|
123
125
|
|
124
126
|
unless !!@methods[@api_name]
|
data/lib/hive/base_error.rb
CHANGED
@@ -19,17 +19,21 @@ module Hive
|
|
19
19
|
end
|
20
20
|
|
21
21
|
if error.message.include? 'Internal Error'
|
22
|
-
raise Hive::
|
22
|
+
raise Hive::RemoteInternalError, error.message, build_backtrace(error)
|
23
23
|
end
|
24
24
|
|
25
25
|
if error.message.include? 'Server error'
|
26
|
-
raise Hive::
|
26
|
+
raise Hive::RemoteServerError, error.message, build_backtrace(error)
|
27
27
|
end
|
28
28
|
|
29
|
-
if error.message.include?
|
29
|
+
if error.message.include?('plugin not enabled') || error.message.include?('Could not find API')
|
30
30
|
raise Hive::PluginNotEnabledError, error.message, build_backtrace(error)
|
31
31
|
end
|
32
32
|
|
33
|
+
if error.message.include? 'Supported by hivemind'
|
34
|
+
raise Hive::MethodNotEnabledError, error.message, build_backtrace(error)
|
35
|
+
end
|
36
|
+
|
33
37
|
if error.message.include? 'argument'
|
34
38
|
raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
|
35
39
|
end
|
@@ -210,9 +214,12 @@ module Hive
|
|
210
214
|
class IncorrectRequestIdError < BaseError; end
|
211
215
|
class IncorrectResponseIdError < BaseError; end
|
212
216
|
class RemoteNodeError < BaseError; end
|
217
|
+
class RemoteInternalError < BaseError; end
|
218
|
+
class RemoteServerError < BaseError; end
|
213
219
|
class UpstreamResponseError < RemoteNodeError; end
|
214
220
|
class RemoteDatabaseLockError < UpstreamResponseError; end
|
215
221
|
class PluginNotEnabledError < UpstreamResponseError; end
|
222
|
+
class MethodNotEnabledError < UpstreamResponseError; end
|
216
223
|
class RequestTimeoutUpstreamResponseError < UpstreamResponseError; end
|
217
224
|
class BadOrMissingUpstreamResponseError < UpstreamResponseError; end
|
218
225
|
class TransactionIndexDisabledError < BaseError; end
|
data/lib/hive/broadcast.rb
CHANGED
@@ -137,7 +137,7 @@ module Hive
|
|
137
137
|
# * :parent_permlink (String) (automatic) Parent permlink of the content, defaults to first tag.
|
138
138
|
# * :parent_author (String) (optional) Parent author of the content (only used if reply).
|
139
139
|
# * :max_accepted_payout (String) (1000000.000 HBD) Maximum accepted payout, set to '0.000 HBD' to deline payout
|
140
|
-
# * :
|
140
|
+
# * :percent_hbd (Numeric) (5000) Percent HIVE Dollars is used to set 50/50 or 100% HIVE Power
|
141
141
|
# * :allow_votes (Numeric) (true) Allow votes for this content.
|
142
142
|
# * :allow_curation_rewards (Numeric) (true) Allow curation rewards for this content.
|
143
143
|
# * :beneficiaries (Array<Hash>) Sets the beneficiaries of this content.
|
@@ -196,7 +196,7 @@ module Hive
|
|
196
196
|
author: params[:author],
|
197
197
|
permlink: params[:permlink],
|
198
198
|
max_accepted_payout: max_accepted_payout,
|
199
|
-
|
199
|
+
percent_hbd: params[:percent_hbd] || 10000,
|
200
200
|
# allow_replies: allow_replies,
|
201
201
|
allow_votes: allow_votes,
|
202
202
|
allow_curation_rewards: allow_curation_rewards,
|
@@ -646,7 +646,7 @@ module Hive
|
|
646
646
|
# props: {
|
647
647
|
# account_creation_fee: '0.000 HIVE',
|
648
648
|
# maximum_block_size: 131072,
|
649
|
-
#
|
649
|
+
# hbd_interest_rate:1000
|
650
650
|
# },
|
651
651
|
# fee: '0.000 HIVE',
|
652
652
|
# }
|
@@ -688,10 +688,10 @@ module Hive
|
|
688
688
|
# props: {
|
689
689
|
# account_creation_fee: '0.000 HIVE',
|
690
690
|
# maximum_block_size: 131072,
|
691
|
-
#
|
691
|
+
# hbd_interest_rate: 1000,
|
692
692
|
# account_subsidy_budget: 50000,
|
693
693
|
# account_subsidy_decay: 330782,
|
694
|
-
#
|
694
|
+
# hbd_exchange_rate: '1.000 HIVE',
|
695
695
|
# url: "https://hive.blog",
|
696
696
|
# new_signing_key: 'STM8LoQjQqJHvotqBo7HjnqmUbFW9oJ2theyqonzUd9DdJ7YYHsvD'
|
697
697
|
# }
|
@@ -719,10 +719,10 @@ module Hive
|
|
719
719
|
props[:account_creation_fee] = hexlify normalize_amount(options.merge amount: account_creation_fee, serialize: true)
|
720
720
|
end
|
721
721
|
|
722
|
-
if !!(
|
723
|
-
props[:
|
724
|
-
props[:
|
725
|
-
props[:
|
722
|
+
if !!(hbd_exchange_rate = props[:hbd_exchange_rate] rescue nil)
|
723
|
+
props[:hbd_exchange_rate][:base] = normalize_amount(options.merge amount: hbd_exchange_rate[:base], serialize: true)
|
724
|
+
props[:hbd_exchange_rate][:quote] = normalize_amount(options.merge amount: hbd_exchange_rate[:quote], serialize: true)
|
725
|
+
props[:hbd_exchange_rate] = hexlify props[:hbd_exchange_rate].to_json
|
726
726
|
end
|
727
727
|
|
728
728
|
%i(key new_signing_key).each do |key|
|
@@ -957,8 +957,8 @@ module Hive
|
|
957
957
|
# * :to (String)
|
958
958
|
# * :agent (String)
|
959
959
|
# * :escrow_id (String)
|
960
|
-
# * :
|
961
|
-
# * :
|
960
|
+
# * :hbd_amount (String)
|
961
|
+
# * :hive_amount (String)
|
962
962
|
# * :fee (String)
|
963
963
|
# * :ratification_deadline (String)
|
964
964
|
# * :escrow_expiration (String)
|
@@ -980,8 +980,8 @@ module Hive
|
|
980
980
|
|
981
981
|
check_required_fields(params, *required_fields)
|
982
982
|
|
983
|
-
params[:
|
984
|
-
params[:
|
983
|
+
params[:hbd_amount] = normalize_amount(options.merge amount: params[:hbd_amount])
|
984
|
+
params[:hive_amount] = normalize_amount(options.merge amount: params[:hive_amount])
|
985
985
|
params[:fee] = normalize_amount(options.merge amount: params[:fee])
|
986
986
|
|
987
987
|
params[:ratification_deadline] = Time.parse(params[:ratification_deadline].to_s)
|
@@ -1032,8 +1032,8 @@ module Hive
|
|
1032
1032
|
# * :who (String)
|
1033
1033
|
# * :receiver (String)
|
1034
1034
|
# * :escrow_id (String)
|
1035
|
-
# * :
|
1036
|
-
# * :
|
1035
|
+
# * :hbd_amount (String)
|
1036
|
+
# * :hive_amount (String)
|
1037
1037
|
# @option options [Boolean] :pretend Just validate, do not broadcast.
|
1038
1038
|
# @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_escrow_release
|
1039
1039
|
def self.escrow_release(options, &block)
|
@@ -1041,8 +1041,8 @@ module Hive
|
|
1041
1041
|
params = options[:params]
|
1042
1042
|
check_required_fields(params, *required_fields)
|
1043
1043
|
|
1044
|
-
params[:
|
1045
|
-
params[:
|
1044
|
+
params[:hbd_amount] = normalize_amount(options.merge amount: params[:hbd_amount])
|
1045
|
+
params[:hive_amount] = normalize_amount(options.merge amount: params[:hive_amount])
|
1046
1046
|
|
1047
1047
|
ops = [[:escrow_release, params]]
|
1048
1048
|
|
@@ -1246,8 +1246,8 @@ module Hive
|
|
1246
1246
|
# @option options [String] :wif Posting wif
|
1247
1247
|
# @option options [Hash] :params
|
1248
1248
|
# * :account (String) Account claiming rewards.
|
1249
|
-
# * :
|
1250
|
-
# * :
|
1249
|
+
# * :reward_hive (Amount) Amount of HIVE to claim.
|
1250
|
+
# * :reward_hbd (Amount) Amount of HBD to claim.
|
1251
1251
|
# * :reward_vests (Amount) Amount of VESTS to claim.
|
1252
1252
|
# @option options [Boolean] :pretend Just validate, do not broadcast.
|
1253
1253
|
# @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_claim_reward_balance
|
@@ -1257,8 +1257,8 @@ module Hive
|
|
1257
1257
|
|
1258
1258
|
check_required_fields(params, *required_fields)
|
1259
1259
|
|
1260
|
-
params[:
|
1261
|
-
params[:
|
1260
|
+
params[:reward_hive] = normalize_amount(options.merge amount: params[:reward_hive])
|
1261
|
+
params[:reward_hbd] = normalize_amount(options.merge amount: params[:reward_hbd])
|
1262
1262
|
params[:reward_vests] = normalize_amount(options.merge amount: params[:reward_vests])
|
1263
1263
|
|
1264
1264
|
ops = [[:claim_reward_balance, params]]
|
data/lib/hive/fallback.rb
CHANGED
@@ -106,7 +106,6 @@ module Hive::Fallback
|
|
106
106
|
:find_limit_orders,
|
107
107
|
:find_owner_histories,
|
108
108
|
:find_savings_withdrawals,
|
109
|
-
:find_sbd_conversion_requests,
|
110
109
|
:find_vesting_delegation_expirations,
|
111
110
|
:find_vesting_delegations,
|
112
111
|
:find_votes,
|
@@ -134,7 +133,6 @@ module Hive::Fallback
|
|
134
133
|
:list_limit_orders,
|
135
134
|
:list_owner_histories,
|
136
135
|
:list_savings_withdrawals,
|
137
|
-
:list_sbd_conversion_requests,
|
138
136
|
:list_vesting_delegation_expirations,
|
139
137
|
:list_vesting_delegations,
|
140
138
|
:list_votes,
|
@@ -242,7 +240,7 @@ module Hive::Fallback
|
|
242
240
|
find_owner_histories: {owner: String},
|
243
241
|
find_proposals: {proposal_ids: []},
|
244
242
|
find_savings_withdrawals: {account: String},
|
245
|
-
|
243
|
+
find_hbd_conversion_requests: {account: String},
|
246
244
|
find_vesting_delegation_expirations: {account: String},
|
247
245
|
find_vesting_delegations: {account: String},
|
248
246
|
find_votes: {author: String, permlink: String},
|
@@ -272,7 +270,7 @@ module Hive::Fallback
|
|
272
270
|
list_proposal_votes: {start: NilClass, limit: Integer, order: String, order_direction: String, status: String},
|
273
271
|
list_proposals: {start: NilClass, limit: Integer, order: String, order_direction: String, status: String},
|
274
272
|
list_savings_withdrawals: {start: NilClass, limit: Integer, order: String},
|
275
|
-
|
273
|
+
list_hbd_conversion_requests: {start: NilClass, limit: Integer, order: String},
|
276
274
|
list_vesting_delegation_expirations: {start: NilClass, limit: Integer, order: String},
|
277
275
|
list_vesting_delegations: {start: NilClass, limit: Integer, order: String},
|
278
276
|
list_votes: {start: NilClass, limit: Integer, order: String},
|
data/lib/hive/jsonrpc.rb
CHANGED
data/lib/hive/marshal.rb
CHANGED
@@ -144,7 +144,7 @@ module Hive
|
|
144
144
|
{
|
145
145
|
account_creation_fee: amount,
|
146
146
|
maximum_block_size: uint32,
|
147
|
-
|
147
|
+
hbd_interest_rate: uint16
|
148
148
|
}
|
149
149
|
end
|
150
150
|
|
@@ -161,12 +161,12 @@ module Hive
|
|
161
161
|
when :account_creation_fee then Hive::Type::Amount.new(string)
|
162
162
|
# when :account_subsidy_budget then int32
|
163
163
|
# when :account_subsidy_decay, :maximum_block_size then uint32
|
164
|
-
when :
|
164
|
+
when :hbd_exchange_rate
|
165
165
|
JSON[string].tap do |rate|
|
166
166
|
rate["base"] = Hive::Type::Amount.new(rate["base"])
|
167
167
|
rate["quote"] = Hive::Type::Amount.new(rate["quote"])
|
168
168
|
end
|
169
|
-
# when :
|
169
|
+
# when :hbd_interest_rate then uint16
|
170
170
|
when :url, :key, :new_signing_key then string
|
171
171
|
else; warn "Unsupported witness property: #{key}"
|
172
172
|
end
|
@@ -2,7 +2,7 @@ class Hive::Operation::CommentOptions < Hive::Operation
|
|
2
2
|
def_attr author: :string
|
3
3
|
def_attr permlink: :string
|
4
4
|
def_attr max_accepted_payout: :amount
|
5
|
-
def_attr
|
5
|
+
def_attr percent_hbd: :uint32
|
6
6
|
# def_attr allow_replies: :boolean
|
7
7
|
def_attr allow_votes: :boolean
|
8
8
|
def_attr allow_curation_rewards: :boolean
|
@@ -5,6 +5,6 @@ class Hive::Operation::EscrowRelease < Hive::Operation
|
|
5
5
|
def_attr who: :string
|
6
6
|
def_attr receiver: :string
|
7
7
|
def_attr escrow_id: :uint32
|
8
|
-
def_attr
|
9
|
-
def_attr
|
8
|
+
def_attr hbd_amount: :amount
|
9
|
+
def_attr hive_amount: :amount
|
10
10
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class Hive::Operation::EscrowTransfer < Hive::Operation
|
2
2
|
def_attr from: :string
|
3
3
|
def_attr to: :string
|
4
|
-
def_attr
|
5
|
-
def_attr
|
4
|
+
def_attr hbd_amount: :amount
|
5
|
+
def_attr hive_amount: :amount
|
6
6
|
def_attr escrow_id: :uint32
|
7
7
|
def_attr agent: :string
|
8
8
|
def_attr fee: :amount
|
data/lib/hive/rpc/http_client.rb
CHANGED
@@ -18,7 +18,8 @@ module Hive
|
|
18
18
|
# @private
|
19
19
|
TIMEOUT_ERRORS = [Net::OpenTimeout, JSON::ParserError, Net::ReadTimeout,
|
20
20
|
Errno::EBADF, IOError, Errno::ENETDOWN, Hive::RemoteDatabaseLockError,
|
21
|
-
Hive::RequestTimeoutUpstreamResponseError, Hive::
|
21
|
+
Hive::RequestTimeoutUpstreamResponseError, Hive::RemoteServerError,
|
22
|
+
Hive::RemoteServerError]
|
22
23
|
|
23
24
|
# @private
|
24
25
|
POST_HEADERS = {
|
data/lib/hive/stream.rb
CHANGED
@@ -173,7 +173,7 @@ module Hive
|
|
173
173
|
# stream = Hive::Stream.new
|
174
174
|
# stream.operations(types: :author_reward_operation, only_virtual: true) do |vop|
|
175
175
|
# v = vop.value
|
176
|
-
# puts "#{v.author} got paid for #{v.permlink}: #{[v.
|
176
|
+
# puts "#{v.author} got paid for #{v.permlink}: #{[v.hbd_payout, v.hive_payout, v.vesting_payout]}"
|
177
177
|
# end
|
178
178
|
#
|
179
179
|
# ... or multiple virtual operation types;
|
data/lib/hive/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hive-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -317,9 +317,9 @@ dependencies:
|
|
317
317
|
- - "~>"
|
318
318
|
- !ruby/object:Gem::Version
|
319
319
|
version: '0.0'
|
320
|
-
- -
|
320
|
+
- - '='
|
321
321
|
- !ruby/object:Gem::Version
|
322
|
-
version: 0.0.
|
322
|
+
version: 0.0.20
|
323
323
|
type: :runtime
|
324
324
|
prerelease: false
|
325
325
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -327,9 +327,9 @@ dependencies:
|
|
327
327
|
- - "~>"
|
328
328
|
- !ruby/object:Gem::Version
|
329
329
|
version: '0.0'
|
330
|
-
- -
|
330
|
+
- - '='
|
331
331
|
- !ruby/object:Gem::Version
|
332
|
-
version: 0.0.
|
332
|
+
version: 0.0.20
|
333
333
|
- !ruby/object:Gem::Dependency
|
334
334
|
name: ffi
|
335
335
|
requirement: !ruby/object:Gem::Requirement
|
@@ -497,9 +497,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
497
497
|
version: '0'
|
498
498
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
499
499
|
requirements:
|
500
|
-
- - "
|
500
|
+
- - ">"
|
501
501
|
- !ruby/object:Gem::Version
|
502
|
-
version:
|
502
|
+
version: 1.3.1
|
503
503
|
requirements: []
|
504
504
|
rubygems_version: 3.0.8
|
505
505
|
signing_key:
|