steem_api 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d808e15bb5bd8b10b70af26c21af568880d3d8e25d892fe98ad777e1b9da1464
4
- data.tar.gz: 1e7813932ab8c9568b8885260409aa1731ea0a31acefec85c2e01529c3b6d558
3
+ metadata.gz: 60041edca796504270f02e4317f7931f96881bf31e46669f3e28b183392caf97
4
+ data.tar.gz: 50eb29b87407ed3da0d9e3ec8f31ca4eb665e98d8d1842eee4ef11723b8b6aaa
5
5
  SHA512:
6
- metadata.gz: a61f2735cf47ccecf244af806d5cccb72779c3ccfc8bcd524cf4c0e2385f6ec1f9d0d1af1426c33824b562a856b9647d402fb8ab94304308642c6e6ca31022e4
7
- data.tar.gz: e40ea12b512db4aab6d7b2a33651445442b6020633f106dae9ce8acbaeabcee10d87968ca8c75da926cdf91eedf3e171f268799e17a9b7b459cc78cab2badb43
6
+ metadata.gz: 1492198c88ef64ea3e9f105339729be53e073a41c8b5c8b9d0fd9e4330570120d929795df529aff746ee316f9347d08411a7ee141222f4b433a74d480c7569ce
7
+ data.tar.gz: a9931f0dc925f795b71136d2585fb33447662d7756f1468e6935a3e1a25d146fe49fb99462d56eb89ef5e1d4da180c0da8f7b89ec8e4a4b52220eb3784de1d91
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'pry'
4
-
5
3
  # Specify your gem's dependencies in steem_api.gemspec
6
4
  gemspec
data/Rakefile CHANGED
@@ -2,7 +2,6 @@ require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
  require 'steem_api'
4
4
  require 'awesome_print'
5
- require 'pry'
6
5
 
7
6
  Rake::TestTask.new(:test) do |t|
8
7
  t.libs << 'test'
@@ -77,39 +76,6 @@ namespace :created do
77
76
  ap customs
78
77
  puts "# Total custom_json_operation: #{customs.values.sum}"
79
78
  end
80
-
81
- desc 'Lists comment_operations count grouped by author and date.'
82
- task :comments, [:author, :days_ago, :min_count] do |t, args|
83
- now = Time.now.utc
84
- author = args[:author]
85
- after_timestamp = now - ((args[:days_ago] || '30').to_i * 86400)
86
- min_count = (args[:min_count] || 1000).to_i
87
-
88
- comments = SteemApi::Tx::Comment.all
89
-
90
- if !!author || author == '%'
91
- unless author == '%'
92
- comments = comments.where(author: author)
93
- end
94
- elsif author =~ /.*%.*/
95
- comments = comments.where('author LIKE ?', author)
96
- end
97
-
98
- comments = comments.where('timestamp > ?', after_timestamp)
99
- comments = comments.group('CAST(timestamp AS DATE)', :author)
100
- comments = comments.order('cast_timestamp_as_date ASC')
101
-
102
- comments = comments.count
103
-
104
- comments = comments.map do |k, v|
105
- [k, v] if v >= min_count
106
- end.compact.to_h
107
-
108
- puts "# Daily creation count by #{author.nil? ? 'all authors' : author} since #{after_timestamp} ..."
109
- ap comments
110
- puts "# Total authors: #{comments.keys.uniq.size}"
111
- puts "# Total comments: #{comments.values.sum}"
112
- end
113
79
  end
114
80
 
115
81
  desc 'Lists sum of transfers grouped by date, from, and to.'
@@ -131,22 +97,6 @@ task :transfers, [:minimum_amount, :symbol, :days_ago] do |t, args|
131
97
  ap transfers.sum(:amount)
132
98
  end
133
99
 
134
- desc 'Lists sum of delegations grouped by year and from.'
135
- task :delegations, [:minimum_amount, :days_ago] do |t, args|
136
- now = Time.now.utc
137
- minimum_amount = (args[:minimum_amount] || '1000000').to_f
138
- after_timestamp = now - ((args[:days_ago] || '30').to_i * 86400)
139
-
140
- delegations = SteemApi::Tx::DelegateVestingShare.where('vesting_shares > ?', minimum_amount)
141
- delegations = delegations.where('timestamp > ?', after_timestamp)
142
- delegations = delegations.group("FORMAT(timestamp, 'yyyy')", :delegator)
143
- delegations = delegations.order('format_timestamp_yyyy ASC')
144
-
145
- puts "Daily delegation sum over #{'%.3f' % minimum_amount} since #{after_timestamp} ..."
146
- ap delegations.count(:vesting_shares).map{|k, v| [k[1], v] if v > 50}.compact.to_h
147
- # ap delegations.sum(:vesting_shares)
148
- end
149
-
150
100
  desc 'Lists sum of powered up grouped by date, from, and to.'
151
101
  task :powerup, [:minimum_amount, :symbol, :days_ago, :not_to_self] do |t, args|
152
102
  now = Time.now.utc
@@ -266,55 +216,38 @@ task :app_names, [:app, :days_ago] do |t, args|
266
216
  end
267
217
 
268
218
  desc 'Do all crosschecks of given account.'
269
- task :crosscheck, [:account, :after_timestamp] do |t, args|
270
- account_name = args[:account]
271
- after_timestamp = args[:after_timestamp]
272
-
273
- abort 'Account name required.' if account_name.nil? || account_name == ''
274
-
275
- if after_timestamp.nil? || after_timestamp == ''
276
- account = SteemApi::Account.find_by(name: account_name)
277
-
278
- abort "No account found: #{account_name}" if account.nil?
279
- end
280
-
281
- Rake::Task["crosscheck:powerdowns"].invoke(account_name, after_timestamp)
282
- Rake::Task["crosscheck:powerups"].invoke(account_name, after_timestamp)
283
- Rake::Task["crosscheck:transfers"].invoke(account_name, after_timestamp)
284
- Rake::Task["crosscheck:vesting_from"].invoke(account_name, after_timestamp)
285
- Rake::Task["crosscheck:vesting_to"].invoke(account_name, after_timestamp)
219
+ task :crosscheck, [:account] do |t, args|
220
+ account = args[:account]
221
+
222
+ Rake::Task["crosscheck:powerdowns"].invoke(account)
223
+ Rake::Task["crosscheck:powerups"].invoke(account)
224
+ Rake::Task["crosscheck:transfers"].invoke(account)
225
+ Rake::Task["crosscheck:vesting_from"].invoke(account)
226
+ Rake::Task["crosscheck:vesting_to"].invoke(account)
286
227
  end
287
228
 
288
229
  namespace :crosscheck do
289
230
  desc 'List of accounts grouped by transfer count crosschecked by memo of given account.'
290
- task :transfers, [:account, :after_timestamp] do |t, args|
231
+ task :transfers, [:account] do |t, args|
291
232
  exchanges = %w(bittrex poloniex openledger blocktrades deepcrypto8 gopax
292
233
  binanceexchange teambitwala changelly hitbtc-exchange korbit roomofsatoshi
293
234
  shapeshiftio)
294
- account_name = args[:account]
295
- after_timestamp = args[:after_timestamp]
296
-
297
- if account_name.nil? || account_name == ''
298
- abort 'Account name required.'
299
- elsif exchanges.include? account_name
300
- abort 'That procedure is not recommended.'
301
- end
302
-
303
- if after_timestamp.nil? || after_timestamp == ''
304
- account = SteemApi::Account.find_by(name: account_name)
305
-
306
- abort "No account found: #{account_name}" if account.nil?
307
-
308
- after_timestamp = account.created
235
+ account = args[:account]
236
+
237
+ if account.nil? || account == ''
238
+ puts 'Account name required.'
239
+ exit
240
+ elsif exchanges.include? account
241
+ puts 'That procedure is not recommended.'
242
+ exit
309
243
  end
310
244
 
311
245
  all = SteemApi::Tx::Transfer.where(type: 'transfer')
312
246
  transfers = all.where.not(memo: '')
313
- transfers = transfers.where('timestamp >= ?', after_timestamp)
314
247
  transfers = transfers.where(to: exchanges)
315
248
  transfers = if account =~ /%/
316
249
  table = SteemApi::Tx::Transfer.arel_table
317
- transfers.where(table[:from].matches(account_name))
250
+ transfers.where(table[:from].matches(account))
318
251
  else
319
252
  transfers.where(from: account)
320
253
  end
@@ -330,30 +263,23 @@ namespace :crosscheck do
330
263
  end
331
264
 
332
265
  desc 'List of accounts grouped by vesting transfers from a given account'
333
- task :vesting_from, [:account, :after_timestamp] do |t, args|
334
- account_name = args[:account]
335
- after_timestamp = args[:after_timestamp]
336
-
337
- abort 'Account name required.' if account_name.nil? || account_name == ''
266
+ task :vesting_from, [:account] do |t, args|
267
+ account = args[:account]
338
268
 
339
- if after_timestamp.nil? || after_timestamp == ''
340
- account = SteemApi::Account.find_by(name: account_name)
341
-
342
- abort "No account found: #{account_name}" if account.nil?
343
-
344
- after_timestamp = account.created
269
+ if account.nil? || account == ''
270
+ puts 'Account name required.'
271
+ exit
345
272
  end
346
273
 
347
274
  table = SteemApi::Tx::Transfer.arel_table
348
275
  all = SteemApi::Tx::Transfer.where(type: 'transfer_to_vesting')
349
276
  transfers = all.where(table[:from].not_eq(:to))
350
- transfers = transfers.where('timestamp >= ?', after_timestamp)
351
277
  transfers = transfers.where.not(to: '')
352
278
  transfers = if account =~ /%/
353
279
  table = SteemApi::Tx::Transfer.arel_table
354
- transfers.where(table[:from].matches(account_name))
280
+ transfers.where(table[:from].matches(account))
355
281
  else
356
- transfers.where(from: account_name)
282
+ transfers.where(from: account)
357
283
  end
358
284
 
359
285
  if transfers.none?
@@ -366,30 +292,23 @@ namespace :crosscheck do
366
292
  end
367
293
 
368
294
  desc 'List of accounts grouped by vesting transfers to a given account'
369
- task :vesting_to, [:account, :after_timestamp] do |t, args|
370
- account_name = args[:account]
371
- after_timestamp = args[:after_timestamp]
372
-
373
- abort 'Account name required.' if account_name.nil? || account_name == ''
295
+ task :vesting_to, [:account] do |t, args|
296
+ account = args[:account]
374
297
 
375
- if after_timestamp.nil? || after_timestamp == ''
376
- account = SteemApi::Account.find_by(name: account_name)
377
-
378
- abort "No account found: #{account_name}" if account.nil?
379
-
380
- after_timestamp = account.created
298
+ if account.nil? || account == ''
299
+ puts 'Account name required.'
300
+ exit
381
301
  end
382
302
 
383
303
  table = SteemApi::Tx::Transfer.arel_table
384
304
  all = SteemApi::Tx::Transfer.where(type: 'transfer_to_vesting')
385
305
  transfers = all.where(table[:from].not_eq(table[:to]))
386
- transfers = transfers.where('timestamp >= ?', after_timestamp)
387
306
  transfers = transfers.where.not(to: '')
388
307
  transfers = if account =~ /%/
389
308
  table = SteemApi::Tx::Transfer.arel_table
390
- transfers.where(table[:to].matches(account_name))
309
+ transfers.where(table[:to].matches(account))
391
310
  else
392
- transfers.where(to: account_name)
311
+ transfers.where(to: account)
393
312
  end
394
313
 
395
314
  if transfers.none?
@@ -402,30 +321,22 @@ namespace :crosscheck do
402
321
  end
403
322
 
404
323
  desc 'List of accounts grouped by powerdown sums crosschecked by given account.'
405
- task :powerdowns, [:account, :after_timestamp] do |t, args|
406
- account_name = args[:account]
407
- after_timestamp = args[:after_timestamp]
408
-
409
- abort 'Account name required.' if account_name.nil? || account_name == ''
324
+ task :powerdowns, [:account] do |t, args|
325
+ account = args[:account]
410
326
 
411
- if after_timestamp.nil? || after_timestamp == ''
412
- account = SteemApi::Account.find_by(name: account_name)
413
-
414
- abort "No account found: #{account_name}" if account.nil?
415
-
416
- after_timestamp = account.created
327
+ if account.nil? || account == ''
328
+ puts 'Account name required.'
329
+ exit
417
330
  end
418
331
 
419
332
  table = SteemApi::Vo::FillVestingWithdraw.arel_table
420
333
  all = SteemApi::Vo::FillVestingWithdraw.where(table[:from_account].not_eq(table[:to_account]))
421
334
  powerdowns = if account =~ /%/
422
- all.where(table[:from_account].matches(account_name))
335
+ all.where(table[:from_account].matches(account))
423
336
  else
424
- all.where(from_account: account_name)
337
+ all.where(from_account: account)
425
338
  end
426
339
 
427
- powerdowns = powerdowns.where('timestamp >= ?', after_timestamp)
428
-
429
340
  if powerdowns.none?
430
341
  puts "No match."
431
342
  else
@@ -438,30 +349,22 @@ namespace :crosscheck do
438
349
  end
439
350
 
440
351
  desc 'List of accounts grouped by powerup sums crosschecked by given account.'
441
- task :powerups, [:account, :after_timestamp] do |t, args|
442
- account_name = args[:account]
443
- after_timestamp = args[:after_timestamp]
444
-
445
- abort 'Account name required.' if account_name.nil? || account_name == ''
352
+ task :powerups, [:account] do |t, args|
353
+ account = args[:account]
446
354
 
447
- if after_timestamp.nil? || after_timestamp == ''
448
- account = SteemApi::Account.find_by(name: account_name)
449
-
450
- abort "No account found: #{account_name}" if account.nil?
451
-
452
- after_timestamp = account.created
355
+ if account.nil? || account == ''
356
+ puts 'Account name required.'
357
+ exit
453
358
  end
454
359
 
455
360
  table = SteemApi::Vo::FillVestingWithdraw.arel_table
456
361
  all = SteemApi::Vo::FillVestingWithdraw.where(table[:from_account].not_eq(table[:to_account]))
457
362
  powerups = if account =~ /%/
458
- all.where(table[:to_account].matches(account_name))
363
+ all.where(table[:to_account].matches(account))
459
364
  else
460
- all.where(to_account: account_name)
365
+ all.where(to_account: account)
461
366
  end
462
367
 
463
- powerups = powerups.where('timestamp >= ?', after_timestamp)
464
-
465
368
  if powerups.none?
466
369
  puts "No match."
467
370
  else
@@ -474,23 +377,6 @@ namespace :crosscheck do
474
377
  end
475
378
  end
476
379
 
477
- namespace :count do
478
- desc 'Count transactions of type (default comment) grouped by date.'
479
- task :transactions, [:type, :days_ago] do |t, args|
480
- now = Time.now.utc
481
- type = args[:type] || 'comment'
482
- after_timestamp = now - ((args[:days_ago] || '7').to_i * 86400)
483
-
484
- trxs = SteemApi::Transaction.where('expiration > ?', after_timestamp)
485
- trxs = trxs.where("[Transactions].[type] = ?", type)
486
- trxs = trxs.group('CAST([Transactions].[expiration] AS DATE)')
487
- trxs = trxs.order('cast_transactions_expiration_as_date ASC')
488
- trxs = trxs.count
489
-
490
- ap trxs
491
- end
492
- end
493
-
494
380
  namespace :rewards do
495
381
  desc 'Lists author rewards grouped by date.'
496
382
  task :author, [:symbol, :days_ago, :author] do |t, args|
@@ -522,11 +408,7 @@ namespace :rewards do
522
408
  when 'VESTS' then rewards.sum(:vesting_payout)
523
409
  when 'MVESTS'
524
410
  rewards.sum('vesting_payout / 1000000')
525
- when 'SP'
526
- rewards.sum("vesting_payout / 1000000 * #{SteemApi::DynamicGlobalProperties.steem_per_mvest.to_f}")
527
- when 'USD'
528
- rewards.sum("vesting_payout / 1000000 * #{SteemApi::DynamicGlobalProperties.usd_per_mvest.to_f}")
529
- else; puts "Unknown symbol: #{symbol}. Symbols supported: SBD, STEEM, VESTS, MVESTS, SP, USD"
411
+ else; puts "Unknown symbol: #{symbol}. Symbols supported: SBD, STEEM, VESTS, MVESTS"
530
412
  end
531
413
 
532
414
  ap rewards
@@ -535,25 +417,16 @@ namespace :rewards do
535
417
  end
536
418
 
537
419
  desc 'Lists curation rewards grouped by date.'
538
- task :curation, [:symbol, :days_ago, :curator] do |t, args|
420
+ task :curation, [:symbol, :days_ago] do |t, args|
539
421
  now = Time.now.utc
540
422
  symbol = (args[:symbol] || 'MVESTS').upcase
541
423
  after_timestamp = now - ((args[:days_ago] || '7').to_i * 86400)
542
- curator = args[:curator]
543
-
424
+
544
425
  rewards = SteemApi::Vo::CurationReward
545
426
  rewards = rewards.where('timestamp > ?', after_timestamp)
546
427
  rewards = rewards.group('CAST(timestamp AS DATE)')
547
428
  rewards = rewards.order('cast_timestamp_as_date ASC')
548
429
 
549
- if !!curator
550
- if curator =~ /%/
551
- rewards = rewards.where("curator LIKE ?", curator)
552
- else
553
- rewards = rewards.where(curator: curator)
554
- end
555
- end
556
-
557
430
  puts "Daily curation reward #{symbol} sum grouped by date since #{after_timestamp} ..."
558
431
 
559
432
  case symbol
@@ -561,12 +434,7 @@ namespace :rewards do
561
434
  ap rewards.sum("TRY_PARSE(REPLACE(reward, ' VESTS', '') AS float)")
562
435
  when 'MVESTS'
563
436
  ap rewards.sum("TRY_PARSE(REPLACE(reward, ' VESTS', '') AS float) / 1000000")
564
- when 'SP'
565
- steem_per_mvest = dgpo.total_vesting_fund_steem / (dgpo.total_vesting_shares / 1e6)
566
- ap rewards.sum("TRY_PARSE(REPLACE(reward, ' VESTS', '') AS float) / 1000000 * #{SteemApi::DynamicGlobalProperties.steem_per_mvest.to_f}")
567
- when 'USD'
568
- ap rewards.sum("TRY_PARSE(REPLACE(reward, ' VESTS', '') AS float) / 1000000 * #{SteemApi::DynamicGlobalProperties.usd_per_mvest.to_f}")
569
- else; puts "Unknown symbol: #{symbol}. Symbols supported: VESTS, MVESTS, SP, USD"
437
+ else; puts "Unknown symbol: #{symbol}. Symbols supported: VESTS, MVESTS"
570
438
  end
571
439
  end
572
440
  end
@@ -624,77 +492,32 @@ task :claimed, [:account_name, :days_ago, :symbol] do |t, args|
624
492
  puts "# Total claimed #{symbol}: #{claims.values.sum}"
625
493
  end
626
494
 
627
- desc "Total balance of transfers from party a to party b."
628
- task :balance, [:party_a, :party_b, :symbol, :days_ago] do |t, args|
495
+ task :balance, [:party_a, :party_b, :symbol] do |t, args|
629
496
  party_a = args[:party_a]
630
497
  party_b = args[:party_b]
631
498
  symbol = args[:symbol].upcase
632
- days_ago = args[:days_ago]
633
499
 
634
- balance_a = SteemApi::Tx::Transfer.where(to: party_a, from: party_b, amount_symbol: symbol)
635
- balance_a = balance_a.after(days_ago.to_f.days.ago) if !!days_ago
636
- balance_a = balance_a.sum(:amount).to_f
637
-
638
- balance_b = SteemApi::Tx::Transfer.where(to: party_b, from: party_a, amount_symbol: symbol)
639
- balance_b = balance_b.after(days_ago.to_f.days.ago) if !!days_ago
640
- balance_b = balance_b.sum(:amount).to_f
500
+ balance_a = SteemApi::Tx::Transfer.where(to: party_a, from: party_b, amount_symbol: symbol).sum(:amount).to_f
501
+ balance_b = SteemApi::Tx::Transfer.where(to: party_b, from: party_a, amount_symbol: symbol).sum(:amount).to_f
641
502
 
642
503
  puts "#{party_a}: %.3f #{symbol}, difference: %.3f #{symbol}" % [balance_a, (balance_a - balance_b)]
643
504
  puts "#{party_b}: %.3f #{symbol}, difference: %.3f #{symbol}" % [balance_b, (balance_b - balance_a)]
644
505
  end
645
506
 
646
- desc 'Lists downvotes cast by follower aginst following.'
647
- task :follow_downvote, [:follower] do |t, args|
648
- follower = args[:follower]
649
- follows = SteemApi::Follower.where(follower: follower)
650
- downvotes = SteemApi::Tx::Vote.where(voter: follower, author: follows.select(:following)).
651
- where('weight < 0').
652
- order(:timestamp)
653
-
654
- puts downvotes.pluck("CONCAT(weight / 100.0, ' %: ', 'https://steemit.com/@', author, '/', permlink)")
655
- end
656
-
657
- desc 'List conversion SBD conversion request sums grouped by day.'
658
- task :convert, [:direction, :days_ago, :segment] do |t, args|
659
- now = Time.now.utc
660
- direction = (args[:direction] || 'in').downcase.to_sym
661
- after_timestamp = now - ((args[:days_ago] || '90').to_f * 86400)
662
- segment = (args[:segment] || 'daily').downcase.to_sym
663
-
664
- converts = SteemApi::Vo::FillConvertRequest
665
- converts = converts.where('timestamp > ?', after_timestamp)
666
- converts = converts.where("TRY_PARSE(REPLACE(amount_in, ' SBD', '') AS float) > 0")
667
- converts = converts.where("TRY_PARSE(REPLACE(amount_out, ' STEEM', '') AS float) > 0")
668
-
669
- case segment
670
- when :daily
671
- converts = converts.group('CAST(timestamp AS DATE)')
672
- converts = converts.order('cast_timestamp_as_date ASC')
673
- when :monthly
674
- converts = converts.group("FORMAT(timestamp, 'yyyy-MM')")
675
- converts = converts.order('format_timestamp_yyyy_mm ASC')
676
- else
677
- raise "Unknown segment: #{direction}"
678
- end
679
-
680
-
681
- case direction
682
- when :in
683
- puts "#{segment.capitalize} conversion requests filled (in) sum grouped by date since #{after_timestamp} ..."
684
- ap converts.sum("TRY_PARSE(REPLACE(amount_in, ' SBD', '') AS float)")
685
- when :out
686
- puts "#{segment.capitalize} conversion requests filled (out) sum grouped by date since #{after_timestamp} ..."
687
- ap converts.sum("TRY_PARSE(REPLACE(amount_out, ' STEEM', '') AS float)")
688
- when :ratio
689
- puts "#{segment.capitalize} conversion requests filled (STEEM ratio) sum grouped by date since #{after_timestamp} ..."
690
- ap converts.average("TRY_PARSE(REPLACE(amount_out, ' STEEM', '') AS float) / TRY_PARSE(REPLACE(amount_in, ' SBD', '') AS float)")
691
- when :inverted_ratio
692
- puts "#{segment.capitalize} conversion requests filled (SBD ratio) sum grouped by date since #{after_timestamp} ..."
693
- ap converts.average("TRY_PARSE(REPLACE(amount_in, ' SBD', '') AS float) / TRY_PARSE(REPLACE(amount_out, ' STEEM', '') AS float)")
694
- else
695
- raise "Unknown direction: #{direction}"
696
- end
697
- end
507
+ # Doesn't look like this table exists.
508
+ # desc 'List conversion SBD conversion request sums grouped by day.'
509
+ # task :convert, [:days_ago] do |t, args|
510
+ # now = Time.now.utc
511
+ # after_timestamp = now - ((args[:days_ago] || '3.5').to_f * 86400)
512
+ #
513
+ # converts = SteemApi::Vo::FillConvertRequest
514
+ # converts = converts.where('timestamp > ?', after_timestamp)
515
+ # converts = converts.group('CAST(timestamp AS DATE)')
516
+ # converts = converts.order('cast_timestamp_as_date ASC')
517
+ #
518
+ # puts "Daily conversion requests failled sum grouped by date since #{after_timestamp} ..."
519
+ # ap converts.sum(:amount)
520
+ # end
698
521
 
699
522
  desc 'Build a new version of the steem_api gem.'
700
523
  task :build do
@@ -65,6 +65,12 @@ require "steem_api/models/vo/proposal_pay"
65
65
  module SteemApi
66
66
  end
67
67
 
68
+ module SteemSQL
69
+ # Initial deprecation of SteemApi module in favor of SteemSQL.
70
+
71
+ include SteemApi
72
+ end
73
+
68
74
  # Monkeypatch to implement: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/274#issuecomment-167578393
69
75
  # Copied from: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/d4b6e4134e15d8d73be48ad6d8da1911f7001d9e/lib/active_record/connection_adapters/sqlserver/schema_statements.rb
70
76
  # Switched "sp_helptext" from above (#view_information) to use "sp_columns"
@@ -1,19 +1,8 @@
1
- require 'open-uri'
2
-
3
1
  module SteemApi
4
2
  class DynamicGlobalProperties < SteemApi::SqlBase
5
3
 
6
4
  self.table_name = :DynamicGlobalProperties
7
5
 
8
- def self.steem_per_mvest
9
- dgpo = first
10
- dgpo.total_vesting_fund_steem / (dgpo.total_vesting_shares / 1e6)
11
- end
12
-
13
- def self.usd_per_mvest
14
- prices = JSON[open('https://postpromoter.net/api/prices').read]
15
- (SteemApi::DynamicGlobalProperties.steem_per_mvest * prices.fetch('steem_price'))
16
- end
17
6
  end
18
7
  end
19
8
 
@@ -1,5 +1,3 @@
1
- require 'steem'
2
-
3
1
  module SteemApi
4
2
  class Transaction < SteemApi::SqlBase
5
3
 
@@ -15,31 +13,13 @@ module SteemApi
15
13
  scope :yesterday, -> { before(1.day.ago).after(2.days.ago) }
16
14
 
17
15
  scope :type, lambda { |type| where(type: type) }
18
- scope :trx_id, lambda { |trx_id|
19
- url = "https://anyx.io/v1/account_history_api/get_transaction?id=#{trx_id}"
20
- trx = JSON[open(url).read]
21
- expiration = Time.parse(trx.fetch('expiration') + 'Z')
22
- block_num = trx.fetch('block_num')
23
- transaction_num = trx.fetch('transaction_num') + 1
24
-
25
- where(expiration: expiration, block_num: block_num, transaction_num: transaction_num)
26
- }
27
-
28
- def trx_id
29
- @block_api ||= Steem::BlockApi.new
30
- @trx_id ||= @block_api.get_block(block_num: block_num) do |result|
31
- return nil if result.nil? || result.block.nil?
32
-
33
- result.block.transaction_ids[transaction_num - 1]
34
- end
35
- end
36
16
 
37
17
  # So you have a Transaction#tx_id and you want to know what the operation was
38
18
  # that lead to it. Well, that's tricky because all of the ops are in their
39
19
  # own tables. This method will (slowly) try to find the appropriate table.
40
20
  def op
41
21
  retries = 0
42
-
22
+ puts type
43
23
  # Here, we map the type to class name, if supported. Most of them can be
44
24
  # mapped automatically, e.g. "vote" => "Vote" but some types share tables
45
25
  # with one another. We also use timestamps to narrow the search
@@ -11,7 +11,7 @@ module SteemApi
11
11
  scope :nsfw, lambda { |nsfw = true| normalized_json.where("JSON_VALUE(json_metadata, '$[1].is_nsfw') = ?", nsfw) }
12
12
  scope :account, lambda { |account|
13
13
  account = [account].flatten
14
- normalized_json.where("required_auths IN(?) OR required_posting_auths IN(?) OR JSON_VALUE(json_metadata, '$[1].account') IN(?)", account, account, account)
14
+ normalized_json.where("required_auth IN(?) OR required_posting_auth IN(?) OR JSON_VALUE(json_metadata, '$[1].account') IN(?)", account, account, account)
15
15
  }
16
16
  scope :permlink, lambda { |permlink|
17
17
  normalized_json.where("JSON_VALUE(json_metadata, '$[1].permlink') = ?", permlink)
@@ -1,3 +1,3 @@
1
1
  module SteemApi
2
- VERSION = '1.1.4'
2
+ VERSION = '1.1.5'
3
3
  end
@@ -38,5 +38,4 @@ Gem::Specification.new do |spec|
38
38
  spec.add_runtime_dependency "activerecord-sqlserver-adapter", [">= 4", "< 6"]
39
39
  spec.add_runtime_dependency "activesupport", [">= 4", "< 6"]
40
40
  spec.add_runtime_dependency 'awesome_print', '~> 1.7', '>= 1.7.0'
41
- spec.add_runtime_dependency 'steem-ruby', '~> 0.9', '>= 0.9.4'
42
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steem_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Chaney (netuoso)
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-11-23 00:00:00.000000000 Z
12
+ date: 2019-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -313,26 +313,6 @@ dependencies:
313
313
  - - ">="
314
314
  - !ruby/object:Gem::Version
315
315
  version: 1.7.0
316
- - !ruby/object:Gem::Dependency
317
- name: steem-ruby
318
- requirement: !ruby/object:Gem::Requirement
319
- requirements:
320
- - - "~>"
321
- - !ruby/object:Gem::Version
322
- version: '0.9'
323
- - - ">="
324
- - !ruby/object:Gem::Version
325
- version: 0.9.4
326
- type: :runtime
327
- prerelease: false
328
- version_requirements: !ruby/object:Gem::Requirement
329
- requirements:
330
- - - "~>"
331
- - !ruby/object:Gem::Version
332
- version: '0.9'
333
- - - ">="
334
- - !ruby/object:Gem::Version
335
- version: 0.9.4
336
316
  description: Rails compatible gem that provides full DB connection and models to SteemSQL.com
337
317
  email:
338
318
  - andrewc@pobox.com