Skip to content

Commit dd9e7ab

Browse files
authored
Merge pull request corpetty#15 from pavelch/master
implement get most recent block from Geth/Parity Proxy APIs
2 parents 96942af + 6fb9973 commit dd9e7ab

File tree

3 files changed

+181
-0
lines changed

3 files changed

+181
-0
lines changed

.gitignore

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,158 @@
88
.idea
99
/__pycache__/
1010

11+
### JetBrains template
12+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
13+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
14+
15+
# User-specific stuff:
16+
.idea/**/workspace.xml
17+
.idea/**/tasks.xml
18+
.idea/dictionaries
19+
20+
# Sensitive or high-churn files:
21+
.idea/**/dataSources/
22+
.idea/**/dataSources.ids
23+
.idea/**/dataSources.xml
24+
.idea/**/dataSources.local.xml
25+
.idea/**/sqlDataSources.xml
26+
.idea/**/dynamic.xml
27+
.idea/**/uiDesigner.xml
28+
29+
# Gradle:
30+
.idea/**/gradle.xml
31+
.idea/**/libraries
32+
33+
# CMake
34+
cmake-build-debug/
35+
36+
# Mongo Explorer plugin:
37+
.idea/**/mongoSettings.xml
38+
39+
## File-based project format:
40+
*.iws
41+
42+
## Plugin-specific files:
43+
44+
# IntelliJ
45+
out/
46+
47+
# mpeltonen/sbt-idea plugin
48+
.idea_modules/
49+
50+
# JIRA plugin
51+
atlassian-ide-plugin.xml
52+
53+
# Cursive Clojure plugin
54+
.idea/replstate.xml
55+
56+
# Crashlytics plugin (for Android Studio and IntelliJ)
57+
com_crashlytics_export_strings.xml
58+
crashlytics.properties
59+
crashlytics-build.properties
60+
fabric.properties
61+
### Python template
62+
# Byte-compiled / optimized / DLL files
63+
__pycache__/
64+
*.py[cod]
65+
*$py.class
66+
67+
# C extensions
68+
*.so
69+
70+
# Distribution / packaging
71+
.Python
72+
build/
73+
develop-eggs/
74+
dist/
75+
downloads/
76+
eggs/
77+
.eggs/
78+
lib/
79+
lib64/
80+
parts/
81+
sdist/
82+
var/
83+
wheels/
84+
*.egg-info/
85+
.installed.cfg
86+
*.egg
87+
MANIFEST
88+
89+
# PyInstaller
90+
# Usually these files are written by a python script from a template
91+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
92+
*.manifest
93+
*.spec
94+
95+
# Installer logs
96+
pip-log.txt
97+
pip-delete-this-directory.txt
98+
99+
# Unit test / coverage reports
100+
htmlcov/
101+
.tox/
102+
.coverage
103+
.coverage.*
104+
.cache
105+
nosetests.xml
106+
coverage.xml
107+
*.cover
108+
.hypothesis/
109+
110+
# Translations
111+
*.mo
112+
*.pot
113+
114+
# Django stuff:
115+
*.log
116+
.static_storage/
117+
.media/
118+
local_settings.py
119+
120+
# Flask stuff:
121+
instance/
122+
.webassets-cache
123+
124+
# Scrapy stuff:
125+
.scrapy
126+
127+
# Sphinx documentation
128+
docs/_build/
129+
130+
# PyBuilder
131+
target/
132+
133+
# Jupyter Notebook
134+
.ipynb_checkpoints
135+
136+
# pyenv
137+
.python-version
138+
139+
# celery beat schedule file
140+
celerybeat-schedule
141+
142+
# SageMath parsed files
143+
*.sage.py
144+
145+
# Environments
146+
.env
147+
.venv
148+
env/
149+
venv/
150+
ENV/
151+
env.bak/
152+
venv.bak/
153+
154+
# Spyder project settings
155+
.spyderproject
156+
.spyproject
157+
158+
# Rope project settings
159+
.ropeproject
160+
161+
# mkdocs documentation
162+
/site
163+
164+
# mypy
165+
.mypy_cache/

etherscan/proxies.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from .client import Client
2+
3+
4+
class Proxies(Client):
5+
def __init__(self, api_key='YourApiKeyToken'):
6+
Client.__init__(self, address='', api_key=api_key)
7+
self.url_dict[self.MODULE] = 'proxy'
8+
9+
def get_most_recent_block(self):
10+
self.url_dict[self.ACTION] = 'eth_blockNumber'
11+
self.build_url()
12+
req = self.connect()
13+
return req['result']

tests/test_proxies.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import re
2+
3+
from etherscan.proxies import Proxies
4+
5+
API_KEY = 'YourAPIkey'
6+
7+
8+
def test_get_most_recent_block():
9+
api = Proxies(api_key=API_KEY)
10+
most_recent = int(api.get_most_recent_block(), 16)
11+
print(most_recent)
12+
p = re.compile('^[0-9]{7}$')
13+
assert (p.match(str(most_recent)))

0 commit comments

Comments
 (0)