radiator 0.4.4 → 0.4.8.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +90 -6
- data/Rakefile +50 -20
- data/lib/radiator.rb +7 -1
- data/lib/radiator/api.rb +105 -14
- data/lib/radiator/bridge.rb +34 -0
- data/lib/radiator/chain_config.rb +9 -2
- data/lib/radiator/database_api.rb +1 -1
- data/lib/radiator/follow_api.rb +1 -1
- data/lib/radiator/market_history_api.rb +1 -1
- data/lib/radiator/operation.rb +3 -2
- data/lib/radiator/operation_types.rb +43 -27
- data/lib/radiator/ssc/base_steem_smart_contract_rpc.rb +147 -0
- data/lib/radiator/ssc/blockchain.rb +57 -0
- data/lib/radiator/ssc/contracts.rb +88 -0
- data/lib/radiator/ssc/stream.rb +62 -0
- data/lib/radiator/stream.rb +15 -6
- data/lib/radiator/transaction.rb +41 -1
- data/lib/radiator/type/amount.rb +26 -50
- data/lib/radiator/type/beneficiaries.rb +8 -1
- data/lib/radiator/type/price.rb +2 -2
- data/lib/radiator/version.rb +1 -1
- data/radiator.gemspec +15 -12
- data/test/fixtures/empty.json +1 -0
- data/test/fixtures/error.json +29 -0
- data/test/fixtures/follow_api_get_followers.json +1 -0
- data/test/fixtures/get_account.json +165 -0
- data/test/fixtures/get_account_count.json +1 -0
- data/test/fixtures/get_account_references.json +1 -0
- data/test/fixtures/get_block.json +193 -0
- data/test/fixtures/get_dynamic_global_properties.json +32 -0
- data/test/fixtures/get_feed_history.json +684 -0
- data/test/fixtures/get_hardfork_version.json +1 -0
- data/test/fixtures/get_key_references.json +14 -0
- data/test/fixtures/get_stats_for_time.json +57 -0
- data/test/fixtures/get_vesting_delegation.json +936 -0
- data/test/fixtures/golos_get_dynamic_global_properties.json +32 -0
- data/test/fixtures/market_history_api_get_market_history_buckets.json +1 -0
- data/test/fixtures/market_history_api_get_order_book.json +109 -0
- data/test/fixtures/market_history_api_get_recent_trades.json +55 -0
- data/test/fixtures/market_history_api_get_ticker.json +11 -0
- data/test/fixtures/market_history_api_get_volume.json +1 -0
- data/test/fixtures/null.json +1 -0
- data/test/fixtures/vcr_cassettes/account_by_key_api_all_methods.yml +525 -0
- data/test/fixtures/vcr_cassettes/account_by_key_api_jsonrpc.yml +52 -0
- data/test/fixtures/vcr_cassettes/all_methods.yml +18155 -0
- data/test/fixtures/vcr_cassettes/api_all_methods.yml +13254 -0
- data/test/fixtures/vcr_cassettes/base_per_debt.yml +4946 -0
- data/test/fixtures/vcr_cassettes/base_per_mvest.yml +3969 -0
- data/test/fixtures/vcr_cassettes/block_time.yml +3322 -0
- data/test/fixtures/vcr_cassettes/broadcast_transaction.yml +1186 -0
- data/test/fixtures/vcr_cassettes/condenser_all_all_methods.yml +13297 -0
- data/test/fixtures/vcr_cassettes/expiration_initialize.yml +3428 -0
- data/test/fixtures/vcr_cassettes/find_account.yml +3681 -0
- data/test/fixtures/vcr_cassettes/find_block.yml +3589 -0
- data/test/fixtures/vcr_cassettes/find_comment.yml +11464 -0
- data/test/fixtures/vcr_cassettes/follow_api_jsonrpc.yml +52 -0
- data/test/fixtures/vcr_cassettes/get_account_count.yml +575 -0
- data/test/fixtures/vcr_cassettes/get_account_references.yml +608 -0
- data/test/fixtures/vcr_cassettes/get_accounts.yml +674 -0
- data/test/fixtures/vcr_cassettes/get_accounts_no_argument.yml +608 -0
- data/test/fixtures/vcr_cassettes/get_dynamic_global_properties.yml +661 -0
- data/test/fixtures/vcr_cassettes/get_feed_history.yml +1106 -0
- data/test/fixtures/vcr_cassettes/get_hardfork_version.yml +577 -0
- data/test/fixtures/vcr_cassettes/get_key_references.yml +987 -0
- data/test/fixtures/vcr_cassettes/get_market_history.yml +1043 -0
- data/test/fixtures/vcr_cassettes/get_market_history_buckets.yml +1043 -0
- data/test/fixtures/vcr_cassettes/get_order_book.yml +1091 -0
- data/test/fixtures/vcr_cassettes/get_recent_trades.yml +1043 -0
- data/test/fixtures/vcr_cassettes/get_ticker.yml +1047 -0
- data/test/fixtures/vcr_cassettes/get_trade_history.yml +1049 -0
- data/test/fixtures/vcr_cassettes/get_vesting_delegations.yml +523 -0
- data/test/fixtures/vcr_cassettes/get_volume.yml +1051 -0
- data/test/fixtures/vcr_cassettes/get_witness_by_account.yml +575 -0
- data/test/fixtures/vcr_cassettes/look_up_witnesses.yml +523 -0
- data/test/fixtures/vcr_cassettes/market_history_api_all_methods.yml +4373 -0
- data/test/fixtures/vcr_cassettes/network_broadcast_api_all_methods.yml +1288 -0
- data/test/fixtures/vcr_cassettes/properties.yml +3627 -0
- data/test/fixtures/vcr_cassettes/recover_transaction.yml +1099 -0
- data/test/fixtures/vcr_cassettes/ssc_blockchain_block_info.yml +92 -0
- data/test/fixtures/vcr_cassettes/ssc_blockchain_block_info_invalid.yml +90 -0
- data/test/fixtures/vcr_cassettes/ssc_blockchain_latest_block_info.yml +91 -0
- data/test/fixtures/vcr_cassettes/ssc_blockchain_transaction_info.yml +92 -0
- data/test/fixtures/vcr_cassettes/ssc_contracts_contract.yml +366 -0
- data/test/fixtures/vcr_cassettes/ssc_contracts_find.yml +91 -0
- data/test/fixtures/vcr_cassettes/ssc_contracts_find_one.yml +89 -0
- data/test/fixtures/vcr_cassettes/stream_jsonrpc.yml +8253 -0
- data/test/fixtures/vcr_cassettes/transaction_expiration_initialize_nil.yml +3176 -0
- data/test/fixtures/vcr_cassettes/transaction_jsonrpc.yml +151 -0
- data/test/fixtures/vcr_cassettes/unknown_chain_id.yml +3343 -0
- data/test/fixtures/vcr_cassettes/valid_chains.yml +3124 -0
- data/test/radiator/account_by_key_api_test.rb +46 -0
- data/test/radiator/api_test.rb +135 -0
- data/test/radiator/chain_stats_api_test.rb +49 -0
- data/test/radiator/chain_test.rb +153 -0
- data/test/radiator/condenser_api_test.rb +48 -0
- data/test/radiator/follow_api_test.rb +48 -0
- data/test/radiator/market_history_api_test.rb +100 -0
- data/test/radiator/network_broadcast_api_test.rb +48 -0
- data/test/radiator/operation_test.rb +117 -0
- data/test/radiator/ssc/blockchain_test.rb +58 -0
- data/test/radiator/ssc/contracts_test.rb +65 -0
- data/test/radiator/stream_test.rb +48 -0
- data/test/radiator/tag_api_test.rb +40 -0
- data/test/radiator/transaction_test.rb +755 -0
- data/test/test_helper.rb +66 -0
- metadata +206 -73
- data/.codeclimate.yml +0 -19
- data/.gitignore +0 -52
- data/.travis.yml +0 -23
- data/gource.sh +0 -8
- data/images/Anthony Martin.png +0 -0
- data/images/Marvin Hofmann.jpg +0 -0
- data/images/Marvin Hofmann.png +0 -0
- data/lib/steem.rb +0 -17
@@ -0,0 +1,88 @@
|
|
1
|
+
module Radiator
|
2
|
+
module SSC
|
3
|
+
# The "contracts" endpoint
|
4
|
+
#
|
5
|
+
# See: https://github.com/harpagon210/steemsmartcontracts/wiki/JSON-RPC-server#3-the-contracts-endpoint-httplocalhost5000contracts
|
6
|
+
class Contracts < BaseSteemSmartContractRPC
|
7
|
+
# @param options [::Hash] The attributes
|
8
|
+
# @option options [String] :url Specify the full node end-point. Default: https://api.steem-engine.com/rpc/contracts
|
9
|
+
def initialize(options = {})
|
10
|
+
super
|
11
|
+
@url = options[:url] || "#{@root_url}/contracts"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Example using the defaults, backed by Steem Engine:
|
15
|
+
#
|
16
|
+
# rpc = Radiator::SSC::Contracts.new
|
17
|
+
# rpc.contract('tokens')
|
18
|
+
#
|
19
|
+
# @param [String] name
|
20
|
+
# @return the contract specified from the database
|
21
|
+
def contract(name)
|
22
|
+
request(method: 'getContract', params: {name: name})
|
23
|
+
end
|
24
|
+
|
25
|
+
# Example using the defaults, backed by Steem Engine:
|
26
|
+
#
|
27
|
+
# rpc = Radiator::SSC::Contracts.new
|
28
|
+
# rpc.find_one(
|
29
|
+
# contract: "tokens",
|
30
|
+
# table: "balances",
|
31
|
+
# query: {
|
32
|
+
# symbol: "STINGY",
|
33
|
+
# account: "inertia"
|
34
|
+
# }
|
35
|
+
# )
|
36
|
+
#
|
37
|
+
# @param options [::Hash] The attributes
|
38
|
+
# @option options [String] :contract
|
39
|
+
# @option options [String] :table
|
40
|
+
# @option options [String] :query
|
41
|
+
# @return the object that matches the query from the table of the specified contract
|
42
|
+
def find_one(options = {})
|
43
|
+
request(method: 'findOne', params: options)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Example using the defaults, backed by Steem Engine:
|
47
|
+
#
|
48
|
+
# rpc = Radiator::SSC::Contracts.new
|
49
|
+
# rpc.find(
|
50
|
+
# contract: "tokens",
|
51
|
+
# table: "balances",
|
52
|
+
# query: {
|
53
|
+
# symbol: "STINGY"
|
54
|
+
# }
|
55
|
+
# )
|
56
|
+
#
|
57
|
+
# @param options [::Hash] The attributes
|
58
|
+
# @option options [String] :contract
|
59
|
+
# @option options [String] :table
|
60
|
+
# @option options [String] :query
|
61
|
+
# @option options [Integer] :limit default: 1000
|
62
|
+
# @option options [Integer] :offset default: 0
|
63
|
+
# @option options [Boolean] :descending
|
64
|
+
# @option options [::Hash] indexes default: empty, an index is an object { index: string, descending: boolean }
|
65
|
+
# @return array of objects that match the query from the table of the specified contract
|
66
|
+
def find(options = {})
|
67
|
+
request(method: 'find', params: options)
|
68
|
+
end
|
69
|
+
protected
|
70
|
+
def healthy?
|
71
|
+
begin
|
72
|
+
request(method: 'find', params: {
|
73
|
+
contract: 'tokens',
|
74
|
+
table: 'transfers',
|
75
|
+
query: {
|
76
|
+
symbol: ''
|
77
|
+
},
|
78
|
+
limit: 0
|
79
|
+
}, skip_health_check: true).nil?
|
80
|
+
rescue => e
|
81
|
+
warn("Health check for #{uri.inspect} failed: #{e.inspect}")
|
82
|
+
|
83
|
+
!!shutdown
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Radiator
|
2
|
+
module SSC
|
3
|
+
# Streams the "blockchain" endpoint.
|
4
|
+
#
|
5
|
+
# See: https://github.com/harpagon210/steemsmartcontracts/wiki/JSON-RPC-server#3-the-contracts-endpoint-httplocalhost5000contracts
|
6
|
+
class Stream < Blockchain
|
7
|
+
# Block production on the sidechain is no faster than 3 seconds, but can
|
8
|
+
# be indefinately longer than 3 seconds if there are no pending
|
9
|
+
# transactions.
|
10
|
+
# @private
|
11
|
+
MIN_BLOCK_PRODUCTION = 3.0
|
12
|
+
|
13
|
+
# @param options [::Hash] The attributes
|
14
|
+
# @option options [String] :url Specify the full node end-point. Default: https://api.steem-engine.com/rpc/blockchain
|
15
|
+
def initialize(options = {})
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
# Stream each block on the side-chain.
|
20
|
+
#
|
21
|
+
# stream = Radiator::SSC::Stream.new
|
22
|
+
# stream.blocks do |block|
|
23
|
+
# puts "Block: #{block}"
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# @param options [::Hash] The attributes
|
27
|
+
# @option options [Integer] :at_block_num start stream at this block number
|
28
|
+
def blocks(options = {}, &block)
|
29
|
+
at_block_num = options[:at_block_num] || latest_block_info.blockNumber
|
30
|
+
|
31
|
+
loop do
|
32
|
+
block = block_info(at_block_num)
|
33
|
+
|
34
|
+
if block.nil?
|
35
|
+
sleep MIN_BLOCK_PRODUCTION and next
|
36
|
+
end
|
37
|
+
|
38
|
+
at_block_num += 1
|
39
|
+
|
40
|
+
yield block, block.blockNumber
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Stream each transaction on the side-chain.
|
45
|
+
#
|
46
|
+
# stream = Radiator::SSC::Stream.new
|
47
|
+
# stream.transactions do |trx|
|
48
|
+
# puts "Transaction: #{trx}"
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# @param options [::Hash] The attributes
|
52
|
+
# @option options [Integer] :at_block_num start stream at this block number
|
53
|
+
def transactions(options = {}, &block)
|
54
|
+
blocks(options) do |block, block_num|
|
55
|
+
block.transactions.each do |transaction|
|
56
|
+
yield transaction, transaction.transactionId, block_num
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/radiator/stream.rb
CHANGED
@@ -258,7 +258,7 @@ module Radiator
|
|
258
258
|
break if stop?
|
259
259
|
|
260
260
|
catch :sequence do; begin
|
261
|
-
head_block =
|
261
|
+
head_block = database_api.get_dynamic_global_properties do |properties, error|
|
262
262
|
if !!error
|
263
263
|
standby "Node responded with: #{error.message || 'unknown error'}, retrying ...", {
|
264
264
|
error: error,
|
@@ -268,7 +268,7 @@ module Radiator
|
|
268
268
|
|
269
269
|
break if stop?
|
270
270
|
|
271
|
-
if properties.head_block_number.nil?
|
271
|
+
if properties.nil? || properties.head_block_number.nil?
|
272
272
|
# This can happen if a reverse proxy is acting up.
|
273
273
|
standby "Bad block sequence after height: #{latest_block_number}", {
|
274
274
|
and: {throw: :sequence}
|
@@ -281,7 +281,7 @@ module Radiator
|
|
281
281
|
else; raise StreamError, '"mode" has to be "head" or "irreversible"'
|
282
282
|
end
|
283
283
|
end
|
284
|
-
|
284
|
+
|
285
285
|
if head_block == latest_block_number
|
286
286
|
# This can happen when there's a delay in block production.
|
287
287
|
|
@@ -390,6 +390,7 @@ module Radiator
|
|
390
390
|
|
391
391
|
@api = nil
|
392
392
|
@block_api = nil
|
393
|
+
@database_api = nil if @api.nil? || @block_api.nil?
|
393
394
|
GC.start
|
394
395
|
end
|
395
396
|
|
@@ -435,6 +436,14 @@ module Radiator
|
|
435
436
|
else; nil
|
436
437
|
end
|
437
438
|
end
|
439
|
+
|
440
|
+
def database_api
|
441
|
+
@database_api ||= case @chain
|
442
|
+
when :steem then Steem::DatabaseApi.new(url: @api.send(:uri).to_s)
|
443
|
+
when :hive then Hive::DatabaseApi.new(url: @api.send(:uri).to_s)
|
444
|
+
else; api
|
445
|
+
end
|
446
|
+
end
|
438
447
|
private
|
439
448
|
def method_missing(m, *args, &block)
|
440
449
|
super unless respond_to_missing?(m)
|
@@ -445,11 +454,11 @@ module Radiator
|
|
445
454
|
break if stop?
|
446
455
|
|
447
456
|
value = if (n = method_params(m)).nil?
|
448
|
-
key_value =
|
457
|
+
key_value = database_api.get_dynamic_global_properties.result[m]
|
449
458
|
else
|
450
459
|
key = n.keys.first
|
451
460
|
if !!n[key]
|
452
|
-
r =
|
461
|
+
r = database_api.get_dynamic_global_properties.result
|
453
462
|
key_value = param = r[n[key]]
|
454
463
|
result = nil
|
455
464
|
loop do
|
@@ -466,7 +475,7 @@ module Radiator
|
|
466
475
|
reset_timeout
|
467
476
|
result
|
468
477
|
else
|
469
|
-
key_value =
|
478
|
+
key_value = database_api.get_dynamic_global_properties.result[key]
|
470
479
|
end
|
471
480
|
end
|
472
481
|
unless @latest_values.include? key_value
|
data/lib/radiator/transaction.rb
CHANGED
@@ -81,6 +81,11 @@ module Radiator
|
|
81
81
|
|
82
82
|
case chain.to_s.downcase.to_sym
|
83
83
|
when :steem then NETWORKS_STEEM_CHAIN_ID
|
84
|
+
when :hive
|
85
|
+
database_api = Hive::DatabaseApi.new(url: @url)
|
86
|
+
database_api.get_config do |config|
|
87
|
+
config['HIVE_CHAIN_ID']
|
88
|
+
end rescue nil || NETWORKS_HIVE_CHAIN_ID
|
84
89
|
when :test then NETWORKS_TEST_CHAIN_ID
|
85
90
|
end
|
86
91
|
end
|
@@ -88,6 +93,7 @@ module Radiator
|
|
88
93
|
def url
|
89
94
|
case chain.to_s.downcase.to_sym
|
90
95
|
when :steem then NETWORKS_STEEM_DEFAULT_NODE
|
96
|
+
when :hive then NETWORKS_HIVE_DEFAULT_NODE
|
91
97
|
when :test then NETWORKS_TEST_DEFAULT_NODE
|
92
98
|
end
|
93
99
|
end
|
@@ -114,6 +120,26 @@ module Radiator
|
|
114
120
|
else
|
115
121
|
self
|
116
122
|
end
|
123
|
+
rescue OperationError => e
|
124
|
+
trx_builder, network_api = case @chain.to_sym
|
125
|
+
when :steem then [
|
126
|
+
Steem::TransactionBuilder.new(wif: @wif),
|
127
|
+
Steem::NetworkBroadcastApi.new(url: @url)
|
128
|
+
]
|
129
|
+
when :hive then [
|
130
|
+
Hive::TransactionBuilder.new(wif: @wif),
|
131
|
+
Hive::NetworkBroadcastApi.new(url: @url)
|
132
|
+
]
|
133
|
+
end
|
134
|
+
|
135
|
+
raise e if trx_builder.nil?
|
136
|
+
|
137
|
+
@operations.each do |op|
|
138
|
+
type = op.delete(:type)
|
139
|
+
trx_builder.put({type => op})
|
140
|
+
end
|
141
|
+
|
142
|
+
network_api.broadcast_transaction_synchronous(trx_builder.transaction)
|
117
143
|
ensure
|
118
144
|
shutdown
|
119
145
|
end
|
@@ -122,7 +148,7 @@ module Radiator
|
|
122
148
|
@operations = @operations.map do |op|
|
123
149
|
case op
|
124
150
|
when Operation then op
|
125
|
-
else; Operation.new(op)
|
151
|
+
else; Operation.new(op.merge(chain: @chain))
|
126
152
|
end
|
127
153
|
end
|
128
154
|
end
|
@@ -147,6 +173,19 @@ module Radiator
|
|
147
173
|
def use_condenser_namespace?
|
148
174
|
!!@use_condenser_namespace
|
149
175
|
end
|
176
|
+
|
177
|
+
def inspect
|
178
|
+
properties = %w(
|
179
|
+
url ref_block_num ref_block_prefix expiration chain
|
180
|
+
use_condenser_namespace immutable_expiration payload
|
181
|
+
).map do |prop|
|
182
|
+
if !!(v = instance_variable_get("@#{prop}"))
|
183
|
+
"@#{prop}=#{v}"
|
184
|
+
end
|
185
|
+
end.compact.join(', ')
|
186
|
+
|
187
|
+
"#<#{self.class.name} [#{properties}]>"
|
188
|
+
end
|
150
189
|
private
|
151
190
|
def broadcast_payload(payload)
|
152
191
|
if use_condenser_namespace?
|
@@ -238,6 +277,7 @@ module Radiator
|
|
238
277
|
bytes << op.to_bytes
|
239
278
|
end
|
240
279
|
|
280
|
+
# FIXME Should pakC(0) instead?
|
241
281
|
bytes << 0x00 # extensions
|
242
282
|
|
243
283
|
bytes
|
data/lib/radiator/type/amount.rb
CHANGED
@@ -1,57 +1,33 @@
|
|
1
|
+
# @deprecated Using Radiator::Type::Amount class provided is deprecated. Please use: Hive::Type::Amount
|
1
2
|
module Radiator
|
2
3
|
module Type
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
when ::Array
|
11
|
-
a, p, t = value
|
12
|
-
@asset = case t
|
13
|
-
when '@@000000013' then 'SBD'
|
14
|
-
when '@@000000021' then 'STEEM'
|
15
|
-
when '@@000000037' then 'VESTS'
|
16
|
-
else; raise TypeError, "Asset #{@asset} unknown."
|
17
|
-
end
|
18
|
-
@precision = p
|
19
|
-
@amount = "%.#{p}f" % (a.to_f / 10 ** p)
|
20
|
-
else
|
21
|
-
@amount, @asset = value.strip.split(' ')
|
22
|
-
@precision = case @asset
|
23
|
-
when 'STEEM' then 3
|
24
|
-
when 'VESTS' then 6
|
25
|
-
when 'SBD' then 3
|
26
|
-
when 'CORE' then 3
|
27
|
-
when 'CESTS' then 6
|
28
|
-
when 'TEST' then 3
|
29
|
-
else; raise TypeError, "Asset #{@asset} unknown."
|
30
|
-
end
|
4
|
+
class Amount < Hive::Type::Amount
|
5
|
+
def initialize(options = {})
|
6
|
+
unless defined? @@deprecated_warning_shown
|
7
|
+
warn "[DEPRECATED] Using Radiator::Type::Amount class provided is deprecated. Please use: Hive::Type::Amount"
|
8
|
+
@@deprecated_warning_shown = true
|
9
|
+
|
10
|
+
super(options.merge(chain: :steem))
|
31
11
|
end
|
32
12
|
end
|
33
|
-
|
34
|
-
def to_bytes
|
35
|
-
asset = @asset.ljust(7, "\x00")
|
36
|
-
amount = (@amount.to_f * 10 ** @precision).round
|
37
|
-
|
38
|
-
[amount].pack('q') +
|
39
|
-
[@precision].pack('c') +
|
40
|
-
asset
|
41
|
-
end
|
42
|
-
|
43
|
-
def to_a
|
44
|
-
case @asset
|
45
|
-
when 'STEEM' then [(@amount.to_f * 1000).to_i.to_s, 3, '@@000000021']
|
46
|
-
when 'VESTS' then [(@amount.to_f * 1000000).to_i.to_s, 6, '@@000000037']
|
47
|
-
when 'SBD' then [(@amount.to_f * 1000).to_i.to_s, 3, '@@000000013']
|
48
|
-
else; raise TypeError, "Asset #{@asset} unknown."
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def to_s
|
53
|
-
"#{@amount} #{@asset}"
|
54
|
-
end
|
55
13
|
end
|
56
14
|
end
|
57
15
|
end
|
16
|
+
|
17
|
+
# Patch for legacy serializer.
|
18
|
+
class Hive::Type::Amount
|
19
|
+
def to_bytes
|
20
|
+
asset = case @asset
|
21
|
+
when 'HBD' then 'SBD'
|
22
|
+
when 'HIVE' then 'STEEM'
|
23
|
+
else; @asset
|
24
|
+
end
|
25
|
+
|
26
|
+
asset = asset.ljust(7, "\x00")
|
27
|
+
amount = (@amount.to_f * 10 ** @precision).round
|
28
|
+
|
29
|
+
[amount].pack('q') +
|
30
|
+
[@precision].pack('c') +
|
31
|
+
asset
|
32
|
+
end
|
33
|
+
end
|
@@ -7,7 +7,14 @@ module Radiator
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def to_bytes
|
10
|
-
|
10
|
+
#set sz 1, op type 0, see
|
11
|
+
#https://github.com/steemit/steem-js/blob/733332d09582e95c0ea868a6ac5b6ee8a1f115ee/src/auth/serializer/src/operations.js#L355
|
12
|
+
varint(1) + varint(0) + varint(@value.size) + @value.map do |b|
|
13
|
+
case b
|
14
|
+
when ::Array then pakStr(b.first.to_s) + pakS(b.last)
|
15
|
+
else; pakStr(b.keys.first.to_s) + pakS(b.values.first)
|
16
|
+
end
|
17
|
+
end.join
|
11
18
|
end
|
12
19
|
|
13
20
|
def to_h
|
data/lib/radiator/type/price.rb
CHANGED
@@ -5,8 +5,8 @@ module Radiator
|
|
5
5
|
def initialize(value)
|
6
6
|
super(:price, value)
|
7
7
|
|
8
|
-
@base = Amount.new(@value[:base])
|
9
|
-
@quote = Amount.new(@value[:quote])
|
8
|
+
@base = Hive::Type::Amount.new(@value[:base])
|
9
|
+
@quote = Hive::Type::Amount.new(@value[:quote])
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_bytes
|
data/lib/radiator/version.rb
CHANGED
data/radiator.gemspec
CHANGED
@@ -9,33 +9,36 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Anthony Martin']
|
10
10
|
spec.email = ['radiator@martin-studio.com']
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{Client for accessing the
|
12
|
+
spec.summary = %q{Hive/Steem RPC Ruby Client}
|
13
|
+
spec.description = %q{Client for accessing the Hive/Steem blockchain.}
|
14
14
|
spec.homepage = 'https://github.com/inertia186/radiator'
|
15
15
|
spec.license = 'CC0-1.0'
|
16
16
|
|
17
|
-
spec.files =
|
17
|
+
spec.files = Dir['lib/**/*', 'test/**/*', 'Gemfile', 'LICENSE', 'Rakefile', 'README.md', 'radiator.gemspec']
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.1'
|
21
|
-
spec.add_development_dependency 'rake', '~>
|
21
|
+
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
|
22
22
|
spec.add_development_dependency 'minitest', '~> 5.10', '>= 5.10.3'
|
23
23
|
spec.add_development_dependency 'minitest-line', '~> 0.6.3'
|
24
24
|
spec.add_development_dependency 'minitest-proveit', '~> 1.0', '>= 1.0.0'
|
25
|
-
spec.add_development_dependency 'webmock', '~> 3.
|
26
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
27
|
-
spec.add_development_dependency 'vcr', '~>
|
28
|
-
spec.add_development_dependency 'yard', '~> 0.9.
|
25
|
+
spec.add_development_dependency 'webmock', '~> 3.6', '>= 3.6.0'
|
26
|
+
spec.add_development_dependency 'simplecov', '~> 0.19.0'
|
27
|
+
spec.add_development_dependency 'vcr', '~> 6.0', '>= 6.0.0'
|
28
|
+
spec.add_development_dependency 'yard', '~> 0.9.20'
|
29
29
|
spec.add_development_dependency 'pry', '~> 0.11', '>= 0.11.3'
|
30
30
|
spec.add_development_dependency 'rb-readline', '~> 0.5', '>= 0.5.5'
|
31
|
+
spec.add_development_dependency 'irb', '~> 1.2', '>= 1.2.1'
|
31
32
|
|
32
33
|
# net-http-persistent has an open-ended dependency because radiator directly
|
33
|
-
# supports net-http-persistent-
|
34
|
+
# supports net-http-persistent-4.0.0 as well as net-http-persistent-2.5.2.
|
34
35
|
spec.add_dependency('net-http-persistent', '>= 2.5.2')
|
36
|
+
spec.add_dependency('steem-ruby', '~> 0.9', '>= 0.9.4')
|
37
|
+
spec.add_dependency('hive-ruby', '~> 1.0', '>= 1.0.1')
|
35
38
|
spec.add_dependency('json', '~> 2.0', '>= 2.0.2')
|
36
39
|
spec.add_dependency('logging', '~> 2.2', '>= 2.2.0')
|
37
|
-
spec.add_dependency('hashie', '~> 3.5', '>= 3.5.
|
38
|
-
spec.add_dependency('bitcoin-ruby', '
|
39
|
-
spec.add_dependency('ffi', '~> 1.9', '>= 1.9.18')
|
40
|
+
spec.add_dependency('hashie', '~> 3.5', '>= 3.5.7') # locked by steem-ruby
|
41
|
+
spec.add_dependency('bitcoin-ruby', '0.0.20') # (was 0.0.19)
|
42
|
+
spec.add_dependency('ffi', '~> 1.9', '>= 1.9.18') # (was 1.11.2)
|
40
43
|
spec.add_dependency('awesome_print', '~> 1.7', '>= 1.7.0')
|
41
44
|
end
|