etherscan_api 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +2 -1
- data/README.md +5 -5
- data/VERSION +1 -1
- data/etherscan_api.gemspec +90 -0
- data/lib/etherscan/accounts.rb +13 -13
- data/spec/etherscan/accounts_spec.rb +1 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94ca4f583b2c81087814b37c99b1821f2eee522b88677c122a660e7d76d7ede1
|
4
|
+
data.tar.gz: 59bc3c44379ac3095ebfae93f74485bf963f8411c980ed03257a6fa8c2ac5a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77c303ba5ce6866f580ff7913a0377804257e3b14076103c28eb8ccdf48cd6526384f646d51b984a0da87fa689845e6279a8e7e22722ddfc1d1434b0433708ee
|
7
|
+
data.tar.gz: '09a2dbe36b771b4f1b843a5d48bd9479f5848aaf4286f0374f6ba76fa597de7834557d1ed38d4163537f714c91bce1df7bee67d2015e4d5be1d635ca5a7b64fc'
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
gem 'faraday'
|
4
4
|
|
5
5
|
group :development do
|
6
6
|
gem 'json', '~> 2.1'
|
@@ -8,7 +8,7 @@ group :development do
|
|
8
8
|
gem 'shoulda', '>= 0'
|
9
9
|
gem 'rdoc', '~> 6.0.3'
|
10
10
|
gem 'bundler', '~> 1.0'
|
11
|
-
gem 'juwelier', '~> 2.
|
11
|
+
gem 'juwelier', '~> 2.4'
|
12
12
|
gem 'simplecov', '~> 0.16'
|
13
13
|
gem 'pry-byebug'
|
14
14
|
gem 'webmock'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# EtherScan API gem
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/etherscan_api.png)](http://badge.fury.io/rb/etherscan_api)
|
4
4
|
[![Build Status](https://travis-ci.org/dpaluy/etherscan.svg?branch=master)](https://travis-ci.org/dpaluy/etherscan)
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/75848a6693e61972e5f3/maintainability)](https://codeclimate.com/github/dpaluy/etherscan/maintainability)
|
6
6
|
[![Dependency Status](https://gemnasium.com/badges/github.com/dpaluy/etherscan.svg)](https://gemnasium.com/github.com/dpaluy/etherscan)
|
@@ -27,7 +27,7 @@ Get your api key: https://etherscan.io/myapikey
|
|
27
27
|
|
28
28
|
```
|
29
29
|
# config/initializers/etherscan.rb
|
30
|
-
|
30
|
+
Etherscan.configure do |config|
|
31
31
|
config.key = 'my_api_key'
|
32
32
|
end
|
33
33
|
```
|
@@ -45,7 +45,7 @@ address = '0xb36efd48c9912bd9fd58b67b65f7438f6364a256'
|
|
45
45
|
etherscan.balance(address, contract_address)
|
46
46
|
```
|
47
47
|
|
48
|
-
|
48
|
+
## Contributing to etherscan
|
49
49
|
|
50
50
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
51
51
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
@@ -55,7 +55,7 @@ etherscan.balance(address, contract_address)
|
|
55
55
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
56
56
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
57
57
|
|
58
|
-
|
58
|
+
## Copyright
|
59
59
|
|
60
|
-
Copyright (c) 2018 David Paluy. See LICENSE.txt for
|
60
|
+
Copyright (c) 2018 David Paluy. See [LICENSE.txt](LICENSE.txt) for
|
61
61
|
further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# Generated by juwelier
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: etherscan_api 0.3.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "etherscan_api".freeze
|
9
|
+
s.version = "0.3.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["David Paluy".freeze]
|
14
|
+
s.date = "2018-04-26"
|
15
|
+
s.description = "This Gem allows you to send Etherscan get requests using native Ruby".freeze
|
16
|
+
s.email = "dpaluy@gmail.com".freeze
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".codeclimate.yml",
|
23
|
+
".document",
|
24
|
+
".travis.yml",
|
25
|
+
"Gemfile",
|
26
|
+
"Gemfile.lock",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.md",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"etherscan_api.gemspec",
|
32
|
+
"lib/etherscan.rb",
|
33
|
+
"lib/etherscan/accounts.rb",
|
34
|
+
"lib/etherscan/api.rb",
|
35
|
+
"lib/etherscan/client.rb",
|
36
|
+
"lib/etherscan/config.rb",
|
37
|
+
"lib/etherscan/engine.rb",
|
38
|
+
"lib/etherscan/exceptions.rb",
|
39
|
+
"lib/etherscan/tokens.rb",
|
40
|
+
"spec/etherscan/accounts_spec.rb",
|
41
|
+
"spec/etherscan/api_spec.rb",
|
42
|
+
"spec/etherscan/tokens_spec.rb",
|
43
|
+
"spec/etherscan_spec.rb",
|
44
|
+
"spec/spec_helper.rb"
|
45
|
+
]
|
46
|
+
s.homepage = "http://github.com/dpaluy/etherscan".freeze
|
47
|
+
s.licenses = ["MIT".freeze]
|
48
|
+
s.rubygems_version = "2.7.3".freeze
|
49
|
+
s.summary = "Ruby Gem for the Etherscan API https://etherscan.io/apis".freeze
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
s.specification_version = 4
|
53
|
+
|
54
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
+
s.add_runtime_dependency(%q<faraday>.freeze, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<json>.freeze, ["~> 2.1"])
|
57
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0"])
|
58
|
+
s.add_development_dependency(%q<shoulda>.freeze, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 6.0.3"])
|
60
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
61
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.4"])
|
62
|
+
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16"])
|
63
|
+
s.add_development_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
64
|
+
s.add_development_dependency(%q<webmock>.freeze, [">= 0"])
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<faraday>.freeze, [">= 0"])
|
67
|
+
s.add_dependency(%q<json>.freeze, ["~> 2.1"])
|
68
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
|
69
|
+
s.add_dependency(%q<shoulda>.freeze, [">= 0"])
|
70
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 6.0.3"])
|
71
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
72
|
+
s.add_dependency(%q<juwelier>.freeze, ["~> 2.4"])
|
73
|
+
s.add_dependency(%q<simplecov>.freeze, ["~> 0.16"])
|
74
|
+
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
75
|
+
s.add_dependency(%q<webmock>.freeze, [">= 0"])
|
76
|
+
end
|
77
|
+
else
|
78
|
+
s.add_dependency(%q<faraday>.freeze, [">= 0"])
|
79
|
+
s.add_dependency(%q<json>.freeze, ["~> 2.1"])
|
80
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
|
81
|
+
s.add_dependency(%q<shoulda>.freeze, [">= 0"])
|
82
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 6.0.3"])
|
83
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
84
|
+
s.add_dependency(%q<juwelier>.freeze, ["~> 2.4"])
|
85
|
+
s.add_dependency(%q<simplecov>.freeze, ["~> 0.16"])
|
86
|
+
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
87
|
+
s.add_dependency(%q<webmock>.freeze, [">= 0"])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
data/lib/etherscan/accounts.rb
CHANGED
@@ -21,42 +21,42 @@ module Etherscan
|
|
21
21
|
|
22
22
|
# Get a list of 'Normal' Transactions By Address
|
23
23
|
# if page is not defined Returns up to 10000 last transactions
|
24
|
+
# Available args: start_block, end_block, sort, page, offset
|
24
25
|
# @param sort 'asc' -> ascending order, 'des' -> descending order
|
25
26
|
# @param start_block starting blockNo to retrieve results
|
26
27
|
# @param end_block ending blockNo to retrieve results
|
27
28
|
# @param page Paginated result <page number>
|
28
29
|
# @param offset max records to return
|
29
|
-
def normal_transactions(address,
|
30
|
+
def normal_transactions(address, args = {})
|
30
31
|
action = 'txlist'
|
31
|
-
|
32
|
-
transcations(action, address, contract_address, start_block, end_block, sort, page, offset)
|
32
|
+
transcations(action, address, nil, args)
|
33
33
|
end
|
34
34
|
|
35
35
|
# Get a list of 'Internal' Transactions By Address
|
36
|
-
|
36
|
+
# Available args: start_block, end_block, sort, page, offset
|
37
|
+
def internal_transactions(address, args = {})
|
37
38
|
action = 'txlistinternal'
|
38
|
-
|
39
|
-
transcations(action, address, contract_address, start_block, end_block, sort, page, offset)
|
39
|
+
transcations(action, address, nil, args)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Get a list of "ERC20 - Token Transfer Events"
|
43
43
|
# @param contract_address Token address (set nil to get a list of all ERC20 transactions)
|
44
44
|
# @param address Address for ERC20 transactions (optional)
|
45
|
-
|
46
|
-
|
45
|
+
# Available args: start_block, end_block, sort, page, offset
|
46
|
+
def token_transactions(contract_address, address = nil, args = {})
|
47
47
|
fail Etherscan::Exception, 'contract or address must be defined' if (contract_address || address).nil?
|
48
48
|
action = 'tokentx'
|
49
|
-
transcations(action, address, contract_address,
|
49
|
+
transcations(action, address, contract_address, args)
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
-
def transcations(action, address, contract_address,
|
54
|
+
def transcations(action, address, contract_address, args)
|
55
55
|
params = {
|
56
56
|
module: 'account', action: action,
|
57
|
-
address: address, contractaddress: contract_address,
|
58
|
-
startblock: start_block, endblock: end_block,
|
59
|
-
page: page, offset: offset
|
57
|
+
address: address, contractaddress: contract_address,
|
58
|
+
startblock: args[:start_block], endblock: args[:end_block],
|
59
|
+
page: args[:page], offset: args[:offset], sort: args[:sort]
|
60
60
|
}.select {|_, v| !v.nil? }
|
61
61
|
get(params)
|
62
62
|
end
|
@@ -48,7 +48,7 @@ describe Etherscan::Accounts do
|
|
48
48
|
}
|
49
49
|
]
|
50
50
|
response = { 'status' => '1', 'message' => 'OK', 'result' => transactions }
|
51
|
-
params = { module: 'account', action: 'txlist', address: address
|
51
|
+
params = { module: 'account', action: 'txlist', address: address }
|
52
52
|
expect(connection_mock).to receive(:get).with(params).and_return(response)
|
53
53
|
expected_response = subject.normal_transactions(address)
|
54
54
|
expect(expected_response).to eq(response['result'])
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etherscan_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Paluy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: json
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +100,14 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '2.
|
103
|
+
version: '2.4'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '2.
|
110
|
+
version: '2.4'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: simplecov
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,6 +167,7 @@ files:
|
|
153
167
|
- README.md
|
154
168
|
- Rakefile
|
155
169
|
- VERSION
|
170
|
+
- etherscan_api.gemspec
|
156
171
|
- lib/etherscan.rb
|
157
172
|
- lib/etherscan/accounts.rb
|
158
173
|
- lib/etherscan/api.rb
|