steem_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +5 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +13 -0
  7. data/README.md +3 -0
  8. data/Rakefile +10 -0
  9. data/bin/steem_api +5 -0
  10. data/lib/steem_api.rb +46 -0
  11. data/lib/steem_api/models/.DS_Store +0 -0
  12. data/lib/steem_api/models/account.rb +79 -0
  13. data/lib/steem_api/models/block.rb +19 -0
  14. data/lib/steem_api/models/comment.rb +68 -0
  15. data/lib/steem_api/models/connection.rb +33 -0
  16. data/lib/steem_api/models/sql_base.rb +23 -0
  17. data/lib/steem_api/models/token.rb +22 -0
  18. data/lib/steem_api/models/transaction.rb +24 -0
  19. data/lib/steem_api/models/tx/account_create.rb +26 -0
  20. data/lib/steem_api/models/tx/account_recover.rb +20 -0
  21. data/lib/steem_api/models/tx/account_update.rb +22 -0
  22. data/lib/steem_api/models/tx/account_witness_proxy.rb +19 -0
  23. data/lib/steem_api/models/tx/account_witness_vote.rb +20 -0
  24. data/lib/steem_api/models/tx/claim_reward_balance.rb +21 -0
  25. data/lib/steem_api/models/tx/comment.rb +24 -0
  26. data/lib/steem_api/models/tx/comments_option.rb +23 -0
  27. data/lib/steem_api/models/tx/convert.rb +20 -0
  28. data/lib/steem_api/models/tx/custom.rb +19 -0
  29. data/lib/steem_api/models/tx/delegate_vesting_share.rb +20 -0
  30. data/lib/steem_api/models/tx/delete_comment.rb +19 -0
  31. data/lib/steem_api/models/tx/escrow_approve.rb +23 -0
  32. data/lib/steem_api/models/tx/escrow_dispute.rb +22 -0
  33. data/lib/steem_api/models/tx/escrow_release.rb +25 -0
  34. data/lib/steem_api/models/tx/escrow_transfer.rb +28 -0
  35. data/lib/steem_api/models/tx/feed.rb +20 -0
  36. data/lib/steem_api/models/tx/limit_order.rb +26 -0
  37. data/lib/steem_api/models/tx/pow.rb +19 -0
  38. data/lib/steem_api/models/tx/transfer.rb +24 -0
  39. data/lib/steem_api/models/tx/vote.rb +21 -0
  40. data/lib/steem_api/models/tx/withdraw.rb +19 -0
  41. data/lib/steem_api/models/tx/withdraw_vesting_route.rb +21 -0
  42. data/lib/steem_api/models/tx/witness_update.rb +24 -0
  43. data/lib/steem_api/models/vo/author_reward.rb +22 -0
  44. data/lib/steem_api/models/vo/curation_reward.rb +21 -0
  45. data/lib/steem_api/models/vo/fill_convert_request.rb +21 -0
  46. data/lib/steem_api/models/vo/fill_order.rb +23 -0
  47. data/lib/steem_api/models/vo/fill_vesting_withdraw.rb +21 -0
  48. data/lib/steem_api/models/vo/interest.rb +19 -0
  49. data/lib/steem_api/models/vo/shutdown_witness.rb +18 -0
  50. data/lib/steem_api/version.rb +3 -0
  51. data/lib/version.rb +3 -0
  52. data/steem_api.gemspec +29 -0
  53. metadata +178 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 603a2105f5a3e70ee39574bea52688163af0ca81
4
+ data.tar.gz: 979e08cb6a18dfc31e05b158ab83a3a6601479f8
5
+ SHA512:
6
+ metadata.gz: 35cfd0ff9162d41f6454a29d536873b500ca1808523da10a26453936ff854273ac490013c0727ad9f8afca127ef9b8f7c02df9f49477a35d78592c973e13a764
7
+ data.tar.gz: 6ad334e3bb74ab4cf5229583c41899c763c5cb47580e425f876170d5e48203898426744dc42e1e068ad19ff4c0bfb8ae23dfa0392d1abcf751a48b089ffb036e
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.14.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at andrewc@pobox.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in steem_api.gemspec
4
+ gemspec
@@ -0,0 +1,13 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
@@ -0,0 +1,3 @@
1
+ # SteemApi
2
+
3
+ Todo: Add stuff here
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'steem_api'
4
+
5
+ puts "Welcome to SteemApi Version: #{SteemApi::VERSION}"
@@ -0,0 +1,46 @@
1
+ require "steem_api/version"
2
+
3
+ # Top Level Models
4
+ require "steem_api/models/sql_base"
5
+ require "steem_api/models/account"
6
+ require "steem_api/models/block"
7
+ require "steem_api/models/comment"
8
+ require "steem_api/models/connection"
9
+ require "steem_api/models/token"
10
+ require "steem_api/models/transaction"
11
+
12
+ # Sub Level Models
13
+ require "steem_api/models/tx/account_create"
14
+ require "steem_api/models/tx/account_recover"
15
+ require "steem_api/models/tx/account_witness_proxy"
16
+ require "steem_api/models/tx/account_witness_vote"
17
+ require "steem_api/models/tx/claim_reward_balance"
18
+ require "steem_api/models/tx/comment"
19
+ require "steem_api/models/tx/comments_option"
20
+ require "steem_api/models/tx/convert"
21
+ require "steem_api/models/tx/custom"
22
+ require "steem_api/models/tx/delegate_vesting_share"
23
+ require "steem_api/models/tx/delete_comment"
24
+ require "steem_api/models/tx/escrow_approve"
25
+ require "steem_api/models/tx/escrow_dispute"
26
+ require "steem_api/models/tx/escrow_release"
27
+ require "steem_api/models/tx/escrow_transfer"
28
+ require "steem_api/models/tx/feed"
29
+ require "steem_api/models/tx/limit_order"
30
+ require "steem_api/models/tx/pow"
31
+ require "steem_api/models/tx/transfer"
32
+ require "steem_api/models/tx/vote"
33
+ require "steem_api/models/tx/withdraw"
34
+ require "steem_api/models/tx/withdraw_vesting_route"
35
+ require "steem_api/models/tx/witness_update"
36
+
37
+ require "steem_api/models/vo/author_reward"
38
+ require "steem_api/models/vo/curation_reward"
39
+ require "steem_api/models/vo/fill_convert_request"
40
+ require "steem_api/models/vo/fill_order"
41
+ require "steem_api/models/vo/fill_vesting_withdraw"
42
+ require "steem_api/models/vo/interest"
43
+ require "steem_api/models/vo/shutdown_witness"
44
+
45
+ module SteemApi
46
+ end
@@ -0,0 +1,79 @@
1
+ module SteemApi
2
+ class Account < SteemApi::SqlBase
3
+
4
+ self.table_name = :Accounts
5
+
6
+ def witness?
7
+ self.witness_votes != "[]"
8
+ end
9
+
10
+ end
11
+ end
12
+
13
+ # Structure
14
+ #
15
+ # SteemApi::Account(
16
+ # id: varchar,
17
+ # name: varchar,
18
+ # owner: varchar_max,
19
+ # active: varchar_max,
20
+ # posting: varchar_max,
21
+ # memo_key: varchar_max,
22
+ # json_metadata: text,
23
+ # proxy: varchar,
24
+ # last_owner_update: datetime,
25
+ # last_account_update: datetime,
26
+ # created: datetime,
27
+ # mined: boolean,
28
+ # owner_challenged: boolean,
29
+ # active_challenged: boolean,
30
+ # last_owner_proved: datetime,
31
+ # last_active_proved: datetime,
32
+ # recovery_account: varchar,
33
+ # last_account_recovery: datetime,
34
+ # reset_account: varchar,
35
+ # comment_count: integer,
36
+ # lifetime_vote_count: integer,
37
+ # post_count: integer,
38
+ # can_vote: boolean,
39
+ # voting_power: integer,
40
+ # last_vote_time: datetime,
41
+ # balance: varchar,
42
+ # savings_balance: varchar,
43
+ # sbd_balance: varchar,
44
+ # sbd_seconds: integer,
45
+ # sbd_seconds_last_update: datetime,
46
+ # sbd_last_interest_payment: datetime,
47
+ # savings_sbd_balance: varchar,
48
+ # savings_sbd_seconds: integer,
49
+ # savings_sbd_seconds_last_update: datetime,
50
+ # savings_sbd_last_interest_payment: datetime,
51
+ # savings_withdraw_requests: integer,
52
+ # vesting_shares: varchar,
53
+ # vesting_withdraw_rate: varchar,
54
+ # next_vesting_withdrawal: datetime,
55
+ # withdrawn: integer,
56
+ # to_withdraw: integer,
57
+ # withdraw_routes: integer,
58
+ # curation_rewards: integer,
59
+ # posting_rewards: integer,
60
+ # proxied_vsf_votes: varchar_max,
61
+ # witnesses_voted_for: integer,
62
+ # average_bandwidth: integer,
63
+ # lifetime_bandwidth: integer,
64
+ # last_bandwidth_update: datetime,
65
+ # average_market_bandwidth: integer,
66
+ # last_market_bandwidth_update: datetime,
67
+ # last_post: datetime,
68
+ # last_root_post: datetime,
69
+ # vesting_balance: varchar,
70
+ # reputation: integer,
71
+ # transfer_history: varchar_max,
72
+ # market_history: varchar_max,
73
+ # post_history: varchar_max,
74
+ # vote_history: varchar_max,
75
+ # other_history: varchar_max,
76
+ # witness_votes: varchar_max,
77
+ # dirty: boolean,
78
+ # TS: ss_timestamp
79
+ # )
@@ -0,0 +1,19 @@
1
+ module SteemApi
2
+ class Block < SteemApi::SqlBase
3
+
4
+ self.table_name = :Blocks
5
+ self.primary_key = :block_num
6
+
7
+ end
8
+ end
9
+
10
+ # Structure
11
+ #
12
+ # SteemApi::Block(
13
+ # block_num: integer,
14
+ # previous: varchar,
15
+ # timestamp: datetime,
16
+ # witness: varchar,
17
+ # witness_signature: varchar,
18
+ # transaction_merkle_root: varchar
19
+ # )
@@ -0,0 +1,68 @@
1
+ module SteemApi
2
+ class Comment < SteemApi::SqlBase
3
+
4
+ self.table_name = :Comments
5
+
6
+ def self.find_by_author(user)
7
+ self.where(author: user)
8
+ end
9
+
10
+ def self.find_by_parent(user)
11
+ self.where(parent_author: user)
12
+ end
13
+
14
+ end
15
+ end
16
+
17
+ # Strcture
18
+ #
19
+ # SteemApi::Comment(
20
+ # ID: integer,
21
+ # author: varchar,
22
+ # permlink: varchar,
23
+ # category: varchar,
24
+ # parent_author: varchar,
25
+ # parent_permlink: varchar,
26
+ # title: text,
27
+ # body: text,
28
+ # json_metadata: text,
29
+ # last_update: datetime,
30
+ # created: datetime,
31
+ # active: datetime,
32
+ # last_payout: datetime,
33
+ # depth: integer,
34
+ # children: integer,
35
+ # net_rshares: integer,
36
+ # abs_rshares: integer,
37
+ # vote_rshares: integer,
38
+ # children_abs_rshares: integer,
39
+ # cashout_time: datetime,
40
+ # max_cashout_time: datetime,
41
+ # total_vote_weight: float,
42
+ # reward_weight: integer,
43
+ # total_payout_value: money,
44
+ # curator_payout_value: money,
45
+ # author_rewards: money,
46
+ # net_votes: integer,
47
+ # root_comment: varchar,
48
+ # mode: varchar,
49
+ # max_accepted_payout: money,
50
+ # percent_steem_dollars: integer,
51
+ # allow_replies: boolean,
52
+ # allow_votes: boolean,
53
+ # allow_curation_rewards: boolean,
54
+ # beneficiaries: varchar_max,
55
+ # url: varchar_max,
56
+ # root_title: text,
57
+ # pending_payout_value: money,
58
+ # total_pending_payout_value: money,
59
+ # active_votes: varchar_max,
60
+ # replies: varchar_max,
61
+ # author_reputation: integer,
62
+ # promoted: varchar,
63
+ # body_length: integer,
64
+ # reblogged_by: varchar_max,
65
+ # body_language: varchar,
66
+ # dirty: boolean,
67
+ # TS: ss_timestamp
68
+ # )
@@ -0,0 +1,33 @@
1
+ require 'rest-client'
2
+ require 'nokogiri'
3
+
4
+ module SteemApi
5
+ class Connection < SteemApi::SqlBase
6
+
7
+ self.table_name = nil
8
+
9
+ def self.steem_per_mvests
10
+ begin
11
+ # SteemDollar.com (fastest)
12
+ steemdollar_response = RestClient::Request.execute(method: :get, url: "https://www.steemdollar.com/vests.php", timeout: 3, open_timeout: 3).body
13
+ Nokogiri::XML.parse(steemdollar_response).css('.text-intro')[2].text.match(/1\s*VESTS\s*=\s*(\d*\.\d*)/)[1]
14
+
15
+ # Steemd.com
16
+ # steemd_response = RestClient::Request.execute(method: :get, url: "https://steemd.com", timeout: 3, open_timeout: 3).body
17
+ # Nokogiri::XML.parse(steemd_response).css('.hash3').first.text.match(/^steem_per_mvests(\d*.\d*)/)[1]
18
+ rescue => e
19
+ Rails.logger.error("Error: #{e}")
20
+ Settings.steem_per_mvests
21
+ end
22
+ end
23
+
24
+ def self.tables
25
+ self.connection.tables
26
+ end
27
+
28
+ def self.columns(model_name)
29
+ "SteemApi::#{model_name}".constantize.columns.map(&:name)
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,23 @@
1
+ require "active_record"
2
+
3
+ module SteemApi
4
+ class SqlBase < ActiveRecord::Base
5
+
6
+ establish_connection({
7
+ adapter: "sqlserver",
8
+ host: "sql.steemsql.com",
9
+ username: "steemit",
10
+ password: "steemit",
11
+ timeout: 60
12
+ })
13
+
14
+ self.table_name = nil
15
+ self.inheritance_column = nil
16
+ self.abstract_class = true
17
+
18
+ def tx
19
+ SteemApi::Transaction.find_by(tx_id: self.tx_id)
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module SteemApi
2
+ class Token < SteemApi::SqlBase
3
+
4
+ self.table_name = :Tokens
5
+
6
+ end
7
+ end
8
+
9
+ # Structure
10
+ #
11
+ # SteemApi::Token(
12
+ # id: integer,
13
+ # hour: boolean,
14
+ # symbol: varchar,
15
+ # time: smalldatetime,
16
+ # open: real,
17
+ # close: real,
18
+ # high: real,
19
+ # low: real,
20
+ # volumefrom: real,
21
+ # volumeto: real
22
+ # )