steem-ruby 0.9.0 → 0.9.5

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.
Files changed (68) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -1
  3. data/README.md +88 -15
  4. data/Rakefile +128 -31
  5. data/lib/steem.rb +49 -0
  6. data/lib/steem/api.rb +39 -37
  7. data/lib/steem/base_error.rb +80 -41
  8. data/lib/steem/block_api.rb +23 -3
  9. data/lib/steem/broadcast.rb +465 -29
  10. data/lib/steem/chain_config.rb +3 -3
  11. data/lib/steem/marshal.rb +231 -0
  12. data/lib/steem/mixins/jsonable.rb +37 -0
  13. data/lib/steem/mixins/retriable.rb +30 -24
  14. data/lib/steem/mixins/serializable.rb +45 -0
  15. data/lib/steem/operation.rb +141 -0
  16. data/lib/steem/operation/account_create.rb +10 -0
  17. data/lib/steem/operation/account_create_with_delegation.rb +12 -0
  18. data/lib/steem/operation/account_update.rb +8 -0
  19. data/lib/steem/operation/account_witness_proxy.rb +4 -0
  20. data/lib/steem/operation/account_witness_vote.rb +5 -0
  21. data/lib/steem/operation/cancel_transfer_from_savings.rb +4 -0
  22. data/lib/steem/operation/challenge_authority.rb +5 -0
  23. data/lib/steem/operation/change_recovery_account.rb +5 -0
  24. data/lib/steem/operation/claim_account.rb +5 -0
  25. data/lib/steem/operation/claim_reward_balance.rb +6 -0
  26. data/lib/steem/operation/comment.rb +9 -0
  27. data/lib/steem/operation/comment_options.rb +10 -0
  28. data/lib/steem/operation/convert.rb +5 -0
  29. data/lib/steem/operation/create_claimed_account.rb +10 -0
  30. data/lib/steem/operation/custom.rb +5 -0
  31. data/lib/steem/operation/custom_binary.rb +8 -0
  32. data/lib/steem/operation/custom_json.rb +6 -0
  33. data/lib/steem/operation/decline_voting_rights.rb +4 -0
  34. data/lib/steem/operation/delegate_vesting_shares.rb +5 -0
  35. data/lib/steem/operation/delete_comment.rb +4 -0
  36. data/lib/steem/operation/escrow_approve.rb +8 -0
  37. data/lib/steem/operation/escrow_dispute.rb +7 -0
  38. data/lib/steem/operation/escrow_release.rb +10 -0
  39. data/lib/steem/operation/escrow_transfer.rb +12 -0
  40. data/lib/steem/operation/feed_publish.rb +4 -0
  41. data/lib/steem/operation/limit_order_cancel.rb +4 -0
  42. data/lib/steem/operation/limit_order_create.rb +8 -0
  43. data/lib/steem/operation/limit_order_create2.rb +8 -0
  44. data/lib/steem/operation/prove_authority.rb +4 -0
  45. data/lib/steem/operation/recover_account.rb +6 -0
  46. data/lib/steem/operation/report_over_production.rb +5 -0
  47. data/lib/steem/operation/request_account_recovery.rb +6 -0
  48. data/lib/steem/operation/reset_account.rb +5 -0
  49. data/lib/steem/operation/set_reset_account.rb +5 -0
  50. data/lib/steem/operation/set_withdraw_vesting_route.rb +6 -0
  51. data/lib/steem/operation/transfer.rb +6 -0
  52. data/lib/steem/operation/transfer_from_savings.rb +7 -0
  53. data/lib/steem/operation/transfer_to_savings.rb +6 -0
  54. data/lib/steem/operation/transfer_to_vesting.rb +5 -0
  55. data/lib/steem/operation/vote.rb +6 -0
  56. data/lib/steem/operation/withdraw_vesting.rb +4 -0
  57. data/lib/steem/operation/witness_set_properties.rb +5 -0
  58. data/lib/steem/operation/witness_update.rb +7 -0
  59. data/lib/steem/rpc/base_client.rb +16 -4
  60. data/lib/steem/rpc/http_client.rb +18 -2
  61. data/lib/steem/stream.rb +385 -0
  62. data/lib/steem/transaction.rb +96 -0
  63. data/lib/steem/transaction_builder.rb +176 -103
  64. data/lib/steem/type/amount.rb +61 -9
  65. data/lib/steem/version.rb +1 -1
  66. data/steem-ruby.gemspec +9 -4
  67. metadata +203 -56
  68. data/Gemfile.lock +0 -73
@@ -1,153 +1,185 @@
1
1
  module Steem
2
2
  class BaseError < StandardError
3
- def initialize(error, cause = nil)
3
+ def initialize(error = nil, cause = nil)
4
4
  @error = error
5
5
  @cause = cause
6
6
  end
7
7
 
8
8
  def to_s
9
- if !!@cause
10
- JSON[error: @error, cause: @cause] rescue {error: @error, cause: @cause}.to_s
11
- else
12
- JSON[@error] rescue @error.to_s
13
- end
9
+ detail = {}
10
+ detail[:error] = @error if !!@error
11
+ detail[:cause] = @cause if !!@cause
12
+
13
+ JSON[detail] rescue detail.to_s
14
14
  end
15
15
 
16
16
  def self.build_error(error, context)
17
17
  if error.message == 'Unable to acquire database lock'
18
- raise Steem::RemoteDatabaseLockError, error.message, JSON.pretty_generate(error)
18
+ raise Steem::RemoteDatabaseLockError, error.message, build_backtrace(error)
19
19
  end
20
20
 
21
21
  if error.message.include? 'Internal Error'
22
- raise Steem::RemoteNodeError.new, error.message, JSON.pretty_generate(error)
22
+ raise Steem::RemoteNodeError, error.message, build_backtrace(error)
23
+ end
24
+
25
+ if error.message.include? 'Server error'
26
+ raise Steem::RemoteNodeError, error.message, build_backtrace(error)
23
27
  end
24
28
 
25
29
  if error.message.include? 'plugin not enabled'
26
- raise Steem::PluginNotEnabledError, error.message, JSON.pretty_generate(error)
30
+ raise Steem::PluginNotEnabledError, error.message, build_backtrace(error)
27
31
  end
28
32
 
29
33
  if error.message.include? 'argument'
30
- raise Steem::ArgumentError, "#{context}: #{error.message}", JSON.pretty_generate(error)
34
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
35
+ end
36
+
37
+ if error.message.include? 'Invalid params'
38
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
31
39
  end
32
40
 
33
41
  if error.message.start_with? 'Bad Cast:'
34
- raise Steem::ArgumentError, "#{context}: #{error.message}", JSON.pretty_generate(error)
42
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
35
43
  end
36
44
 
37
45
  if error.message.include? 'prefix_len'
38
- raise Steem::ArgumentError, "#{context}: #{error.message}", JSON.pretty_generate(error)
46
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
39
47
  end
40
48
 
41
49
  if error.message.include? 'Parse Error'
42
- raise Steem::ArgumentError, "#{context}: #{error.message}", JSON.pretty_generate(error)
50
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
43
51
  end
44
52
 
45
53
  if error.message.include? 'unknown key'
46
- raise Steem::ArgumentError, "#{context}: #{error.message} (or content has been deleted)", JSON.pretty_generate(error)
54
+ raise Steem::ArgumentError, "#{context}: #{error.message} (or content has been deleted)", build_backtrace(error)
47
55
  end
48
56
 
49
57
  if error.message.include? 'Comment is not in account\'s comments'
50
- raise Steem::ArgumentError, "#{context}: #{error.message}", JSON.pretty_generate(error)
58
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
51
59
  end
52
60
 
53
61
  if error.message.include? 'Could not find comment'
54
- raise Steem::ArgumentError, "#{context}: #{error.message}", JSON.pretty_generate(error)
62
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
55
63
  end
56
64
 
57
65
  if error.message.include? 'unable to convert ISO-formatted string to fc::time_point_sec'
58
- raise Steem::ArgumentError, "#{context}: #{error.message}", JSON.pretty_generate(error)
66
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
59
67
  end
60
68
 
61
69
  if error.message.include? 'Input data have to treated as object.'
62
- raise Steem::ArgumentError, "#{context}: #{error.message}", JSON.pretty_generate(error)
70
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
71
+ end
72
+
73
+ if error.message.include? 'base.amount > share_type(0)'
74
+ raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
63
75
  end
64
76
 
65
77
  if error.message.include? 'blk->transactions.size() > itr->trx_in_block'
66
- raise Steem::VirtualOperationsNotAllowedError, "#{context}: #{error.message}", JSON.pretty_generate(error)
78
+ raise Steem::VirtualOperationsNotAllowedError, "#{context}: #{error.message}", build_backtrace(error)
67
79
  end
68
80
 
69
81
  if error.message.include? 'A transaction must have at least one operation'
70
- raise Steem::EmptyTransactionError, "#{context}: #{error.message}", JSON.pretty_generate(error)
82
+ raise Steem::EmptyTransactionError, "#{context}: #{error.message}", build_backtrace(error)
71
83
  end
72
84
 
73
85
  if error.message.include? 'transaction expiration exception'
74
- raise Steem::TransactionExpiredError, "#{context}: #{error.message}", JSON.pretty_generate(error)
86
+ raise Steem::TransactionExpiredError, "#{context}: #{error.message}", build_backtrace(error)
75
87
  end
76
88
 
77
89
  if error.message.include? 'Duplicate transaction check failed'
78
- raise Steem::DuplicateTransactionError, "#{context}: #{error.message}", JSON.pretty_generate(error)
90
+ raise Steem::DuplicateTransactionError, "#{context}: #{error.message}", build_backtrace(error)
79
91
  end
80
92
 
81
93
  if error.message.include? 'signature is not canonical'
82
- raise Steem::NonCanonicalSignatureError, "#{context}: #{error.message}", JSON.pretty_generate(error)
94
+ raise Steem::NonCanonicalSignatureError, "#{context}: #{error.message}", build_backtrace(error)
83
95
  end
84
96
 
85
97
  if error.message.include? 'attempting to push a block that is too old'
86
- raise Steem::BlockTooOldError, "#{context}: #{error.message}", JSON.pretty_generate(error)
98
+ raise Steem::BlockTooOldError, "#{context}: #{error.message}", build_backtrace(error)
87
99
  end
88
100
 
89
101
  if error.message.include? 'irrelevant signature'
90
- raise Steem::IrrelevantSignatureError, "#{context}: #{error.message}", JSON.pretty_generate(error)
102
+ raise Steem::IrrelevantSignatureError, "#{context}: #{error.message}", build_backtrace(error)
91
103
  end
92
104
 
93
105
  if error.message.include? 'missing required posting authority'
94
- raise Steem::MissingPostingAuthorityError, "#{context}: #{error.message}", JSON.pretty_generate(error)
106
+ raise Steem::MissingPostingAuthorityError, "#{context}: #{error.message}", build_backtrace(error)
95
107
  end
96
108
 
97
109
  if error.message.include? 'missing required active authority'
98
- raise Steem::MissingActiveAuthorityError, "#{context}: #{error.message}", JSON.pretty_generate(error)
110
+ raise Steem::MissingActiveAuthorityError, "#{context}: #{error.message}", build_backtrace(error)
99
111
  end
100
112
 
101
113
  if error.message.include? 'missing required owner authority'
102
- raise Steem::MissingOwnerAuthorityError, "#{context}: #{error.message}", JSON.pretty_generate(error)
114
+ raise Steem::MissingOwnerAuthorityError, "#{context}: #{error.message}", build_backtrace(error)
103
115
  end
104
116
 
105
117
  if error.message.include? 'missing required other authority'
106
- raise Steem::MissingOtherAuthorityError, "#{context}: #{error.message}", JSON.pretty_generate(error)
118
+ raise Steem::MissingOtherAuthorityError, "#{context}: #{error.message}", build_backtrace(error)
119
+ end
120
+
121
+ if error.message.include? 'Upstream response error'
122
+ raise Steem::UpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error)
123
+ end
124
+
125
+ if error.message.include? 'Bad or missing upstream response'
126
+ raise Steem::BadOrMissingUpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error)
107
127
  end
108
128
 
109
129
  if error.message.include? 'operator has disabled operation indexing by transaction_id'
110
- raise Steem::TransactionIndexDisabledError, "#{context}: #{error.message}", JSON.pretty_generate(error)
130
+ raise Steem::TransactionIndexDisabledError, "#{context}: #{error.message}", build_backtrace(error)
111
131
  end
112
132
 
113
133
  if error.message.include? 'is_valid_account_name'
114
- raise Steem::InvalidAccountError, "#{context}: #{error.message}", JSON.pretty_generate(error)
134
+ raise Steem::InvalidAccountError, "#{context}: #{error.message}", build_backtrace(error)
135
+ end
136
+
137
+ if error.message.include?('Method') && error.message.include?(' does not exist.')
138
+ raise Steem::UnknownMethodError, "#{context}: #{error.message}", build_backtrace(error)
115
139
  end
116
140
 
117
141
  if error.message.include? 'Invalid operation name'
118
- raise Steem::UnknownOperationError, "#{context}: #{error.message}", JSON.pretty_generate(error)
142
+ raise Steem::UnknownOperationError, "#{context}: #{error.message}", build_backtrace(error)
143
+ end
144
+
145
+ if error.message =~ /Invalid object name: .+_operation/
146
+ raise Steem::UnknownOperationError, "#{context}: #{error.message}", build_backtrace(error)
119
147
  end
120
148
 
121
149
  if error.message.include? 'Author not found'
122
- raise Steem::AuthorNotFoundError, "#{context}: #{error.message}", JSON.pretty_generate(error)
150
+ raise Steem::AuthorNotFoundError, "#{context}: #{error.message}", build_backtrace(error)
123
151
  end
124
152
 
125
153
  if error.message.include? ' != fc::time_point_sec::maximum()'
126
- raise Steem::ReachedMaximumTimeError, "#{context}: #{error.message}", JSON.pretty_generate(error)
154
+ raise Steem::ReachedMaximumTimeError, "#{context}: #{error.message}", build_backtrace(error)
127
155
  end
128
156
 
129
157
  if error.message.include? 'Cannot transfer a negative amount (aka: stealing)'
130
- raise Steem::TheftError, "#{context}: #{error.message}", JSON.pretty_generate(error)
158
+ raise Steem::TheftError, "#{context}: #{error.message}", build_backtrace(error)
131
159
  end
132
160
 
133
161
  if error.message.include? 'Must transfer a nonzero amount'
134
- raise Steem::NonZeroRequiredError, "#{context}: #{error.message}", JSON.pretty_generate(error)
162
+ raise Steem::NonZeroRequiredError, "#{context}: #{error.message}", build_backtrace(error)
135
163
  end
136
164
 
137
165
  if error.message.include? 'is_asset_type'
138
- raise Steem::UnexpectedAssetError, "#{context}: #{error.message}", JSON.pretty_generate(error)
166
+ raise Steem::UnexpectedAssetError, "#{context}: #{error.message}", build_backtrace(error)
139
167
  end
140
168
 
141
169
  puts JSON.pretty_generate(error) if ENV['DEBUG']
142
- raise UnknownError, "#{context}: #{error.message}", JSON.pretty_generate(error)
170
+ raise UnknownError, "#{context}: #{error.message}", build_backtrace(error)
171
+ end
172
+ private
173
+ def self.build_backtrace(error)
174
+ backtrace = Thread.current.backtrace.reject{ |line| line =~ /base_error/ }
175
+ JSON.pretty_generate(error) + "\n" + backtrace.join("\n")
143
176
  end
144
177
  end
145
178
 
179
+ class DeserializationError < BaseError; end
180
+ class SerializationMismatchError < BaseError; end
146
181
  class UnsupportedChainError < BaseError; end
147
182
  class ArgumentError < BaseError; end
148
- class RemoteNodeError < BaseError; end
149
- class RemoteDatabaseLockError < RemoteNodeError; end
150
- class PluginNotEnabledError < RemoteNodeError; end
151
183
  class TypeError < BaseError; end
152
184
  class EmptyTransactionError < ArgumentError; end
153
185
  class InvalidAccountError < ArgumentError; end
@@ -169,11 +201,18 @@ module Steem
169
201
  class MissingOtherAuthorityError < MissingAuthorityError; end
170
202
  class IncorrectRequestIdError < BaseError; end
171
203
  class IncorrectResponseIdError < BaseError; end
204
+ class RemoteNodeError < BaseError; end
205
+ class UpstreamResponseError < RemoteNodeError; end
206
+ class RemoteDatabaseLockError < UpstreamResponseError; end
207
+ class PluginNotEnabledError < UpstreamResponseError; end
208
+ class BadOrMissingUpstreamResponseError < UpstreamResponseError; end
172
209
  class TransactionIndexDisabledError < BaseError; end
173
210
  class NotAppBaseError < BaseError; end
174
211
  class UnknownApiError < BaseError; end
212
+ class UnknownMethodError < BaseError; end
175
213
  class UnknownOperationError < BaseError; end
176
214
  class JsonRpcBatchMaximumSizeExceededError < BaseError; end
177
215
  class TooManyTimeoutsError < BaseError; end
216
+ class TooManyRetriesError < BaseError; end
178
217
  class UnknownError < BaseError; end
179
218
  end
@@ -12,11 +12,25 @@ module Steem
12
12
  super
13
13
  end
14
14
 
15
+ # Uses a batched requst on a range of block headers.
16
+ #
17
+ # @param options [Hash] The attributes to get a block range with.
18
+ # @option options [Range] :block_range starting on one block number and ending on an higher block number.
19
+ def get_block_headers(options = {block_range: (0..0)}, &block)
20
+ get_block_objects(options.merge(object: :block_header), block)
21
+ end
22
+
15
23
  # Uses a batched requst on a range of blocks.
16
24
  #
17
25
  # @param options [Hash] The attributes to get a block range with.
18
26
  # @option options [Range] :block_range starting on one block number and ending on an higher block number.
19
27
  def get_blocks(options = {block_range: (0..0)}, &block)
28
+ get_block_objects(options.merge(object: :block), block)
29
+ end
30
+ private
31
+ def get_block_objects(options = {block_range: (0..0)}, block = nil)
32
+ object = options[:object]
33
+ object_method = "get_#{object}".to_sym
20
34
  block_range = options[:block_range] || (0..0)
21
35
 
22
36
  if (start = block_range.first) < 1
@@ -33,15 +47,21 @@ module Steem
33
47
  request_object = []
34
48
 
35
49
  for i in sub_range do
36
- @rpc_client.put(self.class.api_name, :get_block, block_num: i, request_object: request_object)
50
+ @rpc_client.put(self.class.api_name, object_method, block_num: i, request_object: request_object)
37
51
  end
38
52
 
39
53
  if !!block
40
54
  index = 0
41
55
  @rpc_client.rpc_batch_execute(request_object: request_object) do |result, error, id|
42
56
  block_num = sub_range.to_a[index]
43
- index = index += 1
44
- yield(result.nil? ? nil : result.block, block_num)
57
+ index = index + 1
58
+
59
+ case object
60
+ when :block_header
61
+ block.call(result.nil? ? nil : result[:header], block_num)
62
+ else
63
+ block.call(result.nil? ? nil : result[object], block_num)
64
+ end
45
65
  end
46
66
  else
47
67
  blocks = []
@@ -31,8 +31,9 @@ module Steem
31
31
  # 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.
32
32
  class Broadcast
33
33
  extend Retriable
34
+ extend Utils
34
35
 
35
- DEFAULT_MAX_ACCEPTED_PAYOUT = Type::Amount.new(["1000000000", 3, "@@000000013"])
36
+ DEFAULT_MAX_ACCEPTED_PAYOUT = Type::Amount.new(amount: '1000000000', precision: 3, nai: '@@000000013')
36
37
 
37
38
  # This operation is used to cast a vote on a post/comment.
38
39
  #
@@ -69,6 +70,58 @@ module Steem
69
70
  process(options.merge(ops: ops), &block)
70
71
  end
71
72
 
73
+ # This operation is used to cast a vote on a post/comment using multiple votable assets.
74
+ #
75
+ # options = {
76
+ # wif: wif,
77
+ # params: {
78
+ # voter: voter,
79
+ # author: author,
80
+ # permlink: permlink,
81
+ # TODO
82
+ # }
83
+ # }
84
+ #
85
+ # Steem::Broadcast.vote2(options) do |result|
86
+ # puts result
87
+ # end
88
+ #
89
+ # @param options [Hash] options
90
+ # @option options [String] :wif Posting wif
91
+ # @option options [Hash] :params
92
+ # * :voter (String)
93
+ # * :author (String)
94
+ # * :permlink (String)
95
+ # * :rshares (Array)
96
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
97
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_vote
98
+ def self.vote2(options, &block)
99
+ required_fields = %i(voter author permlink rshares)
100
+ params = options[:params]
101
+ check_required_fields(params, *required_fields)
102
+
103
+ ops = [[:vote2, params]]
104
+
105
+ process(options.merge(ops: ops), &block)
106
+ end
107
+
108
+ # @param options [Hash] options
109
+ # @option options [String] :wif Posting wif
110
+ # @option options [Hash] :params
111
+ # * :account (String)
112
+ # * :reward_tokens (Array)
113
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
114
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_vote
115
+ def self.claim_reward_balance2(options, &block)
116
+ required_fields = %i(account reward_tokens)
117
+ params = options[:params]
118
+ check_required_fields(params, *required_fields)
119
+
120
+ ops = [[:claim_reward_balance2, params]]
121
+
122
+ process(options.merge(ops: ops), &block)
123
+ end
124
+
72
125
  # Creates a post/comment. This method simplifies content creation by
73
126
  # combining `comment` and `comment_options` into one transaction.
74
127
  #
@@ -174,9 +227,9 @@ module Steem
174
227
  }]]
175
228
 
176
229
  max_accepted_payout = if params.keys.include? :max_accepted_payout
177
- Type::Amount.to_nia(params[:max_accepted_payout])
230
+ normalize_amount(options.merge amount: params[:max_accepted_payout])
178
231
  else
179
- DEFAULT_MAX_ACCEPTED_PAYOUT.to_nia
232
+ normalize_amount(options.merge amount: DEFAULT_MAX_ACCEPTED_PAYOUT)
180
233
  end
181
234
 
182
235
  allow_votes = if params.keys.include? :allow_votes
@@ -196,13 +249,17 @@ module Steem
196
249
  permlink: params[:permlink],
197
250
  max_accepted_payout: max_accepted_payout,
198
251
  percent_steem_dollars: params[:percent_steem_dollars] || 10000,
252
+ # allow_replies: allow_replies,
199
253
  allow_votes: allow_votes,
200
254
  allow_curation_rewards: allow_curation_rewards,
201
255
  extensions: []
202
256
  }
203
257
 
204
258
  if !!params[:beneficiaries]
205
- comment_options[:extensions] << [0, {beneficiaries: params[:beneficiaries]}]
259
+ comment_options[:extensions] << [
260
+ comment_options[:extensions].size,
261
+ normalize_beneficiaries(options.merge(beneficiaries: params[:beneficiaries]))
262
+ ]
206
263
  end
207
264
 
208
265
  ops << [:comment_options, comment_options]
@@ -274,7 +331,7 @@ module Steem
274
331
  params = options[:params]
275
332
  check_required_fields(params, *required_fields)
276
333
 
277
- params[:amount] = Type::Amount.to_nia(params[:amount])
334
+ params[:amount] = normalize_amount(options.merge amount: params[:amount])
278
335
 
279
336
  ops = [[:transfer, params]]
280
337
 
@@ -310,7 +367,7 @@ module Steem
310
367
  params = options[:params]
311
368
  check_required_fields(params, *required_fields)
312
369
 
313
- params[:amount] = Type::Amount.to_nia(params[:amount])
370
+ params[:amount] = normalize_amount(options.merge amount: params[:amount])
314
371
 
315
372
  ops = [[:transfer_to_vesting, params]]
316
373
 
@@ -336,7 +393,7 @@ module Steem
336
393
  params = options[:params]
337
394
  check_required_fields(params, *required_fields)
338
395
 
339
- params[:vesting_shares] = Type::Amount.to_nia(params[:vesting_shares])
396
+ params[:vesting_shares] = normalize_amount(options.merge amount: params[:vesting_shares])
340
397
 
341
398
  ops = [[:withdraw_vesting, params]]
342
399
 
@@ -363,8 +420,8 @@ module Steem
363
420
  params = options[:params]
364
421
  check_required_fields(params, *required_fields)
365
422
 
366
- params[:amount_to_sell] = Type::Amount.to_nia(params[:amount_to_sell])
367
- params[:min_to_receive] = Type::Amount.to_nia(params[:min_to_receive])
423
+ params[:amount_to_sell] = normalize_amount(options.merge amount: params[:amount_to_sell])
424
+ params[:min_to_receive] = normalize_amount(options.merge amount: params[:min_to_receive])
368
425
 
369
426
  if !!params[:expiration]
370
427
  params[:expiration] = Time.parse(params[:expiration].to_s)
@@ -376,6 +433,42 @@ module Steem
376
433
  process(options.merge(ops: ops), &block)
377
434
  end
378
435
 
436
+ # This operation creates a limit order and matches it against existing open
437
+ # orders.
438
+ #
439
+ # @param options [Hash] options
440
+ # @option options [String] :wif Active wif
441
+ # @option options [Hash] :params
442
+ # * :owner (String)
443
+ # * :orderid (String)
444
+ # * :amount_to_sell (String)
445
+ # * :exchange_rate (Hash)
446
+ # * :fill_or_kill (Boolean)
447
+ # * :expiration (String)
448
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
449
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_limit_order_create2
450
+ def self.limit_order_create2(options, &block)
451
+ required_fields = %i(owner orderid amount_to_sell exchange_rate
452
+ fill_or_kill)
453
+ params = options[:params]
454
+ check_required_fields(params, *required_fields)
455
+
456
+ params[:amount_to_sell] = normalize_amount(options.merge amount: params[:amount_to_sell])
457
+ params[:exchange_rate] = {
458
+ base: normalize_amount(options.merge amount: params[:exchange_rate][:base]),
459
+ quote: normalize_amount(options.merge amount: params[:exchange_rate][:quote])
460
+ }
461
+
462
+ if !!params[:expiration]
463
+ params[:expiration] = Time.parse(params[:expiration].to_s)
464
+ params[:expiration] = params[:expiration].strftime('%Y-%m-%dT%H:%M:%S')
465
+ end
466
+
467
+ ops = [[:limit_order_create2, params]]
468
+
469
+ process(options.merge(ops: ops), &block)
470
+ end
471
+
379
472
  # Cancels an order and returns the balance to owner.
380
473
  #
381
474
  # @param options [Hash] options
@@ -414,8 +507,8 @@ module Steem
414
507
  exchange_rate = params[:exchange_rate] rescue nil || {}
415
508
  base = exchange_rate[:base]
416
509
  quote = exchange_rate[:quote]
417
- params[:exchange_rate][:base] = Type::Amount.to_nia(base)
418
- params[:exchange_rate][:quote] = Type::Amount.to_nia(quote)
510
+ params[:exchange_rate][:base] = normalize_amount(options.merge amount: base)
511
+ params[:exchange_rate][:quote] = normalize_amount(options.merge amount: quote)
419
512
 
420
513
  ops = [[:feed_publish, params]]
421
514
 
@@ -438,7 +531,7 @@ module Steem
438
531
  params = options[:params]
439
532
  check_required_fields(params, *required_fields)
440
533
 
441
- params[:amount] = Type::Amount.to_nia(params[:amount])
534
+ params[:amount] = normalize_amount(options.merge amount: params[:amount])
442
535
 
443
536
  ops = [[:convert, params]]
444
537
 
@@ -502,13 +595,75 @@ module Steem
502
595
 
503
596
  check_required_fields(params, *required_fields)
504
597
 
505
- params[:fee] = Type::Amount.to_nia(params[:fee])
598
+ params[:fee] = normalize_amount(options.merge amount: params[:fee])
506
599
 
507
600
  ops = [[:account_create, params]]
508
601
 
509
602
  process(options.merge(ops: ops), &block)
510
603
  end
511
604
 
605
+ # Create a claimed account.
606
+ # options = {
607
+ # wif: wif,
608
+ # params: {
609
+ # creator: creator_account_name,
610
+ # new_account_name: new_account_name,
611
+ # owner: {
612
+ # weight_threshold: 1,
613
+ # account_auths: [],
614
+ # key_auths: [[owner_public_key, 1]],
615
+ # },
616
+ # active: {
617
+ # weight_threshold: 1,
618
+ # account_auths: [],
619
+ # key_auths: [[active_public_key, 1]],
620
+ # },
621
+ # posting: {
622
+ # weight_threshold: 1,
623
+ # account_auths: [],
624
+ # key_auths: [[posting_public_key, 1]],
625
+ # },
626
+ # memo_key: memo_public_key,
627
+ # json_metadata: '{}'
628
+ # }
629
+ # }
630
+ #
631
+ # Steem::Broadcast.create_claimed_account(options)
632
+ #
633
+ # @param options [Hash] options
634
+ # @option options [String] :wif Active wif
635
+ # @option options [Hash] :params
636
+ # * :creator (String)
637
+ # * :new_account_name (String)
638
+ # * :owner (Hash)
639
+ # * :active (Hash)
640
+ # * :posting (Hash)
641
+ # * :memo_key (String)
642
+ # * :metadata (Hash) Metadata of the account, becomes `json_metadata`.
643
+ # * :json_metadata (String) String version of `metadata` (use one or the other).
644
+ # * :extensions (Array) (optional)
645
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
646
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_create_claimed_account
647
+ def self.create_claimed_account(options, &block)
648
+ required_fields = %i(creator new_account_name owner active posting memo_key json_metadata)
649
+ params = options[:params]
650
+
651
+ if !!params[:metadata] && !!params[:json_metadata]
652
+ raise Steem::ArgumentError, 'Assign either metadata or json_metadata, not both.'
653
+ end
654
+
655
+ metadata = params.delete(:metadata) || {}
656
+ metadata ||= (JSON[params[:json_metadata]] || nil) || {}
657
+ params[:json_metadata] = metadata.to_json
658
+
659
+ check_required_fields(params, *required_fields)
660
+
661
+ params[:extensions] ||= []
662
+ ops = [[:create_claimed_account, params]]
663
+
664
+ process(options.merge(ops: ops), &block)
665
+ end
666
+
512
667
  # Update an account.
513
668
  # options = {
514
669
  # wif: wif,
@@ -603,14 +758,81 @@ module Steem
603
758
  check_required_fields(params, *required_fields)
604
759
 
605
760
  account_creation_fee = params[:props][:account_creation_fee] rescue nil
606
- params[:props][:account_creation_fee] = Type::Amount.to_nia(account_creation_fee)
607
- params[:fee] = Type::Amount.to_nia(params[:fee])
761
+ params[:props][:account_creation_fee] = normalize_amount(options.merge amount: account_creation_fee)
762
+ params[:fee] = normalize_amount(options.merge amount: params[:fee])
608
763
 
609
764
  ops = [[:witness_update, params]]
610
765
 
611
766
  process(options.merge(ops: ops), &block)
612
767
  end
613
768
 
769
+ # Extensible replacement for #witness_update that supports additional
770
+ # properties added since HF20 and beyond.
771
+ #
772
+ # options = {
773
+ # wif: wif,
774
+ # params: {
775
+ # owner: witness_account_name,
776
+ # props: {
777
+ # account_creation_fee: '0.000 STEEM',
778
+ # maximum_block_size: 131072,
779
+ # sbd_interest_rate: 1000,
780
+ # account_subsidy_budget: 50000,
781
+ # account_subsidy_decay: 330782,
782
+ # sbd_exchange_rate: '1.000 STEEM',
783
+ # url: "https://steemit.com",
784
+ # new_signing_key: 'STM8LoQjQqJHvotqBo7HjnqmUbFW9oJ2theyqonzUd9DdJ7YYHsvD'
785
+ # }
786
+ # }
787
+ # }
788
+ #
789
+ # Steem::Broadcast.witness_set_properties(options)
790
+ #
791
+ # @param options [Hash] options
792
+ # @option options [String] :wif Active wif
793
+ # @option options [Hash] :params
794
+ # * :owner (String)
795
+ # * :props (String)
796
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
797
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_witness_set_properties
798
+ # @see https://github.com/steemit/steem/blob/master/doc/witness_parameters.md
799
+ def self.witness_set_properties(options, &block)
800
+ required_fields = %i(owner props)
801
+ params = options[:params]
802
+ check_required_fields(params, *required_fields)
803
+
804
+ if !!(account_creation_fee = params[:props][:account_creation_fee] rescue nil)
805
+ params[:props][:account_creation_fee] = normalize_amount(options.merge amount: account_creation_fee, serialize: true)
806
+ end
807
+
808
+ if !!(sbd_exchange_rate = params[:props][:sbd_exchange_rate] rescue nil)
809
+ params[:props][:sbd_exchange_rate][:base] = normalize_amount(options.merge amount: sbd_exchange_rate[:base], serialize: true)
810
+ params[:props][:sbd_exchange_rate][:quote] = normalize_amount(options.merge amount: sbd_exchange_rate[:quote], serialize: true)
811
+ params[:props][:sbd_exchange_rate] = params[:props][:sbd_exchange_rate].to_json
812
+ end
813
+
814
+ %i(key new_signing_key).each do |key|
815
+ if !!params[key] && params[key].size == 53
816
+ params[key] = params[key][3..-1]
817
+ end
818
+ end
819
+
820
+ %i(account_creation_fee sbd_exchange_rate url new_signing_key).each do |key|
821
+ next unless !!params[:props][key]
822
+
823
+ val = params[:props][key].to_s
824
+
825
+ params[:props][key] = hexlify val unless val =~ /^[0-9A-F]+$/i
826
+ end
827
+
828
+ params[:props] = params[:props].to_a
829
+
830
+ params[:extensions] ||= []
831
+ ops = [[:witness_set_properties, params]]
832
+
833
+ process(options.merge(ops: ops), &block)
834
+ end
835
+
614
836
  # All accounts with a VFS (Vesting Fund Shares) can vote for or against any
615
837
  # witness.
616
838
  #
@@ -844,9 +1066,9 @@ module Steem
844
1066
 
845
1067
  check_required_fields(params, *required_fields)
846
1068
 
847
- params[:sbd_amount] = Type::Amount.to_nia(params[:sbd_amount])
848
- params[:steem_amount] = Type::Amount.to_nia(params[:steem_amount])
849
- params[:fee] = Type::Amount.to_nia(params[:fee])
1069
+ params[:sbd_amount] = normalize_amount(options.merge amount: params[:sbd_amount])
1070
+ params[:steem_amount] = normalize_amount(options.merge amount: params[:steem_amount])
1071
+ params[:fee] = normalize_amount(options.merge amount: params[:fee])
850
1072
 
851
1073
  params[:ratification_deadline] = Time.parse(params[:ratification_deadline].to_s)
852
1074
  params[:ratification_deadline] = params[:ratification_deadline].strftime('%Y-%m-%dT%H:%M:%S')
@@ -905,8 +1127,8 @@ module Steem
905
1127
  params = options[:params]
906
1128
  check_required_fields(params, *required_fields)
907
1129
 
908
- params[:sbd_amount] = Type::Amount.to_nia(params[:sbd_amount])
909
- params[:steem_amount] = Type::Amount.to_nia(params[:steem_amount])
1130
+ params[:sbd_amount] = normalize_amount(options.merge amount: params[:sbd_amount])
1131
+ params[:steem_amount] = normalize_amount(options.merge amount: params[:steem_amount])
910
1132
 
911
1133
  ops = [[:escrow_release, params]]
912
1134
 
@@ -954,7 +1176,7 @@ module Steem
954
1176
  check_required_fields(params, *required_fields)
955
1177
 
956
1178
  params[:memo] ||= ''
957
- params[:amount] = Type::Amount.to_nia(params[:amount])
1179
+ params[:amount] = normalize_amount(options.merge amount: params[:amount])
958
1180
 
959
1181
  ops = [[:transfer_to_savings, params]]
960
1182
 
@@ -977,7 +1199,7 @@ module Steem
977
1199
  check_required_fields(params, *required_fields)
978
1200
 
979
1201
  params[:memo] ||= ''
980
- params[:amount] = Type::Amount.to_nia(params[:amount])
1202
+ params[:amount] = normalize_amount(options.merge amount: params[:amount])
981
1203
 
982
1204
  ops = [[:transfer_from_savings, params]]
983
1205
 
@@ -1039,7 +1261,7 @@ module Steem
1039
1261
  params = options[:params]
1040
1262
  check_required_fields(params, *required_fields)
1041
1263
 
1042
- params[:vesting_shares] = Type::Amount.to_nia(params[:vesting_shares])
1264
+ params[:vesting_shares] = normalize_amount(options.merge amount: params[:vesting_shares])
1043
1265
  ops = [[:delegate_vesting_shares, params]]
1044
1266
 
1045
1267
  process(options.merge(ops: ops), &block)
@@ -1075,8 +1297,8 @@ module Steem
1075
1297
 
1076
1298
  check_required_fields(params, *required_fields)
1077
1299
 
1078
- params[:fee] = Type::Amount.to_nia(params[:fee])
1079
- params[:delegation] = Type::Amount.to_nia(params[:delegation])
1300
+ params[:fee] = normalize_amount(options.merge amount: params[:fee])
1301
+ params[:delegation] = normalize_amount(options.merge amount: params[:delegation])
1080
1302
  params[:extensions] ||= []
1081
1303
 
1082
1304
  ops = [[:account_create_with_delegation, params]]
@@ -1084,6 +1306,188 @@ module Steem
1084
1306
  process(options.merge(ops: ops), &block)
1085
1307
  end
1086
1308
 
1309
+ # @param options [Hash] options
1310
+ # @option options [String] :wif Active wif
1311
+ # @option options [Hash] :params
1312
+ # * :creator (String)
1313
+ # * :fee (String)
1314
+ # * :extensions (Array)
1315
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
1316
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_claim_account
1317
+ def self.claim_account(options, &block)
1318
+ required_fields = %i(creator fee)
1319
+ params = options[:params]
1320
+
1321
+ check_required_fields(params, *required_fields)
1322
+
1323
+ params[:fee] = normalize_amount(options.merge amount: params[:fee])
1324
+ params[:extensions] ||= []
1325
+
1326
+ ops = [[:claim_account, params]]
1327
+
1328
+ process(options.merge(ops: ops), &block)
1329
+ end
1330
+
1331
+ # @param options [Hash] options
1332
+ # @option options [String] :wif Active wif
1333
+ # @option options [Hash] :params
1334
+ # * :control_account (String)
1335
+ # * :symbol (Hash)
1336
+ # * :smt_creation_fee (Hash)
1337
+ # * :precision (Integer)
1338
+ # * :extensions (Array)
1339
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
1340
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_smt_create
1341
+ def self.smt_create(options, &block)
1342
+ required_fields = %i(control_account symbol smt_creation_fee precision)
1343
+ params = options[:params]
1344
+
1345
+ check_required_fields(params, *required_fields)
1346
+
1347
+ params[:smt_creation_fee] = normalize_amount(options.merge amount: params[:smt_creation_fee])
1348
+ params[:extensions] ||= []
1349
+
1350
+ ops = [[:smt_create, params]]
1351
+
1352
+ process(options.merge(ops: ops), &block)
1353
+ end
1354
+
1355
+ # @param options [Hash] options
1356
+ # @option options [String] :wif Active wif
1357
+ # @option options [Hash] :params
1358
+ # * :control_account (String)
1359
+ # * :symbol (Hash)
1360
+ # * :contribution_begin_time (String)
1361
+ # * :contribution_end_time (String)
1362
+ # * :launch_time max_supply (String)
1363
+ # * :steem_units_hard_cap (Integer)
1364
+ # * :steem_units_soft_cap (Integer)
1365
+ # * :steem_units_min (Integer)
1366
+ # * initial_generation_policy (String)
1367
+ # * :extensions (Array)
1368
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
1369
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_smt_create
1370
+ def self.smt_setup(options, &block)
1371
+ required_fields = %i(control_account symbol contribution_begin_time contribution_end_time launch_time max_supply steem_units_hard_cap steem_units_soft_cap steem_units_min initial_generation_policy)
1372
+ params = options[:params]
1373
+
1374
+ check_required_fields(params, *required_fields)
1375
+
1376
+ params[:extensions] ||= []
1377
+
1378
+ ops = [[:smt_setup, params]]
1379
+
1380
+ process(options.merge(ops: ops), &block)
1381
+ end
1382
+
1383
+ # @param options [Hash] options
1384
+ # @option options [String] :wif Active wif
1385
+ # @option options [Hash] :params
1386
+ # * :control_account (String)
1387
+ # * :symbol (Hash)
1388
+ # * :setup_parameters (Array)
1389
+ # * :extensions (Array)
1390
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
1391
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_smt_create
1392
+ def self.smt_set_setup_parameters(options, &block)
1393
+ required_fields = %i(control_account symbol setup_parameters)
1394
+ params = options[:params]
1395
+
1396
+ check_required_fields(params, *required_fields)
1397
+
1398
+ params[:extensions] ||= []
1399
+
1400
+ ops = [[:smt_set_setup_parameters, params]]
1401
+
1402
+ process(options.merge(ops: ops), &block)
1403
+ end
1404
+
1405
+ # @param options [Hash] options
1406
+ # @option options [String] :wif Active wif
1407
+ # @option options [Hash] :params
1408
+ # * :control_account (String)
1409
+ # * :symbol (Hash)
1410
+ # * :runtime_parameters (Array)
1411
+ # * :extensions (Array)
1412
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
1413
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_smt_create
1414
+ def self.smt_set_runtime_parameters(options, &block)
1415
+ required_fields = %i(control_account symbol runtime_parameters)
1416
+ params = options[:params]
1417
+
1418
+ check_required_fields(params, *required_fields)
1419
+
1420
+ params[:extensions] ||= []
1421
+
1422
+ ops = [[:smt_set_runtime_parameters, params]]
1423
+
1424
+ process(options.merge(ops: ops), &block)
1425
+ end
1426
+
1427
+ # @param options [Hash] options
1428
+ # @option options [String] :wif Active wif
1429
+ # @option options [Hash] :params
1430
+ # * :control_account (String)
1431
+ # * :symbol (Hash)
1432
+ # * :extensions (Array)
1433
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
1434
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_smt_create
1435
+ def self.smt_setup_emissions(options, &block)
1436
+ required_fields = %i(control_account symbol schedule_time emissions_unit interval_seconds interval_count lep_time rep_time lep_abs_amount rep_abs_amount lep_rel_amount_numerator rep_rel_amount_numerator rel_amount_denom_bits remove floor_emissions)
1437
+ params = options[:params]
1438
+
1439
+ check_required_fields(params, *required_fields)
1440
+
1441
+ params[:extensions] ||= []
1442
+
1443
+ ops = [[:smt_setup_emissions, params]]
1444
+
1445
+ process(options.merge(ops: ops), &block)
1446
+ end
1447
+
1448
+ # @param options [Hash] options
1449
+ # @option options [String] :wif Active wif
1450
+ # @option options [Hash] :params
1451
+ # * :control_account (String)
1452
+ # * :symbol (Hash)
1453
+ # * :extensions (Array)
1454
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
1455
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_smt_create
1456
+ def self.smt_contribute(options, &block)
1457
+ required_fields = %i(contributor symbol contribution_id contribution)
1458
+ params = options[:params]
1459
+
1460
+ check_required_fields(params, *required_fields)
1461
+
1462
+ params[:extensions] ||= []
1463
+
1464
+ ops = [[:smt_contribute, params]]
1465
+
1466
+ process(options.merge(ops: ops), &block)
1467
+ end
1468
+
1469
+ # @param options [Hash] options
1470
+ # @option options [String] :wif Active wif
1471
+ # @option options [Hash] :params
1472
+ # * :from_account (String)
1473
+ # * :to_pool (String)
1474
+ # * :amount (Hash)
1475
+ # * :extensions (Array)
1476
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
1477
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_smt_create
1478
+ def self.delegate_to_pool(options, &block)
1479
+ required_fields = %i(from_account to_pool amount)
1480
+ params = options[:params]
1481
+
1482
+ check_required_fields(params, *required_fields)
1483
+
1484
+ params[:extensions] ||= []
1485
+
1486
+ ops = [[:delegate_to_pool, params]]
1487
+
1488
+ process(options.merge(ops: ops), &block)
1489
+ end
1490
+
1087
1491
  # @param options [Hash] options
1088
1492
  # @option options [Array<Array<Hash>] :ops Operations to process.
1089
1493
  # @option options [Boolean] :pretend Just validate, do not broadcast.
@@ -1097,9 +1501,17 @@ module Steem
1097
1501
  trx = tx.transaction
1098
1502
 
1099
1503
  response = if !!options[:pretend]
1100
- database_api(options).verify_authority(trx: trx)
1504
+ if !!options[:app_base]
1505
+ database_api(options).verify_authority(trx: trx)
1506
+ else
1507
+ database_api(options).verify_authority(trx)
1508
+ end
1101
1509
  else
1102
- network_broadcast_api(options).broadcast_transaction_synchronous(trx: trx)
1510
+ if !!options[:app_base]
1511
+ network_broadcast_api(options).broadcast_transaction(trx: trx)
1512
+ else
1513
+ network_broadcast_api(options).broadcast_transaction_synchronous(trx)
1514
+ end
1103
1515
  end
1104
1516
 
1105
1517
  break
@@ -1119,14 +1531,38 @@ module Steem
1119
1531
  end
1120
1532
  end
1121
1533
  private
1534
+ # @private
1535
+ def self.normalize_amount(options)
1536
+ if !!options[:app_base]
1537
+ Type::Amount.to_h(options[:amount])
1538
+ elsif !!options[:serialize]
1539
+ Type::Amount.to_s(options[:amount])
1540
+ else
1541
+ Type::Amount.to_s(options[:amount])
1542
+ end
1543
+ end
1544
+
1545
+ def self.normalize_beneficiaries(options)
1546
+ # Type::Beneficiaries.new(options[:beneficiaries])
1547
+ {beneficiaries: options[:beneficiaries]}
1548
+ end
1549
+
1122
1550
  # @private
1123
1551
  def self.database_api(options)
1124
- options[:database_api] ||= Steem::DatabaseApi.new(options)
1552
+ options[:database_api] ||= if !!options[:app_base]
1553
+ Steem::DatabaseApi.new(options)
1554
+ else
1555
+ Steem::CondenserApi.new(options)
1556
+ end
1125
1557
  end
1126
1558
 
1127
1559
  # @private
1128
1560
  def self.network_broadcast_api(options)
1129
- options[:network_broadcast_api] ||= Steem::NetworkBroadcastApi.new(options)
1561
+ options[:network_broadcast_api] ||= if !!options[:app_base]
1562
+ Steem::NetworkBroadcaseApi.new(options)
1563
+ else
1564
+ Steem::CondenserApi.new(options)
1565
+ end
1130
1566
  end
1131
1567
 
1132
1568
  # @private