This repository has been archived by the owner on Sep 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
279 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "key" : "E9K4A1AC8H1V3ZIR1DAIKZ6B961CRXF2DR" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from unittest import mock | ||
|
||
from etherollapp.etheroll.utils import get_etherscan_api_key | ||
|
||
|
||
class TestUtils: | ||
def test_get_etherscan_api_key(self): | ||
""" | ||
Verifies the key can be retrieved from either: | ||
1) environment | ||
2) file | ||
3) or fallbacks on default key | ||
""" | ||
expected_key = "0102030405060708091011121314151617" | ||
# 1) environment | ||
with mock.patch.dict( | ||
"os.environ", {"ETHERSCAN_API_KEY": expected_key} | ||
): | ||
actual_key = get_etherscan_api_key() | ||
assert actual_key == expected_key | ||
# 2) file | ||
read_data = '{ "key" : "%s" }' % (expected_key) | ||
api_key_path = "api_key.json" | ||
with mock.patch( | ||
"builtins.open", mock.mock_open(read_data=read_data) | ||
) as m_open: | ||
actual_key = get_etherscan_api_key(api_key_path=api_key_path) | ||
assert expected_key == actual_key | ||
# verifies the file was read | ||
assert m_open.call_args_list == [mock.call(api_key_path, mode="r")] | ||
# 3) or fallbacks on default key | ||
with mock.patch("builtins.open") as m_open, mock.patch( | ||
"etherollapp.etheroll.utils.logger" | ||
) as m_logger: | ||
m_open.side_effect = FileNotFoundError | ||
actual_key = get_etherscan_api_key(api_key_path) | ||
assert "YourApiKeyToken" == actual_key | ||
# verifies the fallback warning was logged | ||
assert m_logger.warning.call_args_list == [ | ||
mock.call( | ||
"Cannot get Etherscan API key. " | ||
"File api_key.json not found, " | ||
"defaulting to YourApiKeyToken." | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
__version__ = '2019.1101' | ||
__version__ = '2019.1108' | ||
# The `__version_code__` is used for the F-Droid auto update and should match | ||
# the `versionCode` from the `build.gradle` file located in: | ||
# `.buildozer/android/platform/build-*/dists/etheroll__*/build.gradle` | ||
# `.buildozer/android/platform/build/dists/etheroll/` | ||
# The auto update method used is the `HTTP`, see: | ||
# https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode | ||
__version_code__ = 721203001 | ||
__version_code__ = 721203008 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from pythonforandroid.recipe import PythonRecipe | ||
|
||
|
||
class EthAbiRecipe(PythonRecipe): | ||
""" | ||
This recipes is a workaround to build on F-Droid build server. | ||
Their build server doesn't have Python3.6 yet, hence we want to force this | ||
recipe to build on the compiled host Python, refs: | ||
https://github.com/AndreMiras/EtherollApp/issues/167 | ||
""" | ||
version = '2.0.0' | ||
url = ( | ||
'https://pypi.python.org/packages/source/e/eth-abi/' | ||
'eth-abi-{version}.tar.gz' | ||
) | ||
depends = ['setuptools'] | ||
call_hostpython_via_targetpython = False | ||
|
||
|
||
recipe = EthAbiRecipe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from pythonforandroid.recipe import PythonRecipe | ||
|
||
|
||
class EthAccountRecipe(PythonRecipe): | ||
""" | ||
This recipes is a workaround to build on F-Droid build server. | ||
Their build server doesn't have Python3.6 yet, hence we want to force this | ||
recipe to build on the compiled host Python, refs: | ||
https://github.com/AndreMiras/EtherollApp/issues/167 | ||
""" | ||
version = '0.4.0' | ||
url = ( | ||
'https://pypi.python.org/packages/source/e/eth-account/' | ||
'eth-account-{version}.tar.gz' | ||
) | ||
depends = ['setuptools'] | ||
patches = ['setup.py.patch'] | ||
call_hostpython_via_targetpython = False | ||
|
||
|
||
recipe = EthAccountRecipe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/setup.py b/setup.py | ||
index f4a2ad0..4e52b68 100644 | ||
--- a/setup.py | ||
+++ b/setup.py | ||
@@ -57,7 +57,6 @@ setup( | ||
"hexbytes>=0.1.0,<1", | ||
"rlp>=1.0.0,<2" | ||
], | ||
- setup_requires=['setuptools-markdown'], | ||
python_requires='>=3.6, <4', | ||
extras_require=extras_require, | ||
py_modules=['eth_account'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import glob | ||
from os.path import basename, exists, join | ||
|
||
import sh | ||
from pythonforandroid.recipe import CythonRecipe | ||
from pythonforandroid.toolchain import current_directory, shprint | ||
|
||
|
||
class KivyRecipe(CythonRecipe): | ||
version = '1.11.1' | ||
url = 'https://github.com/kivy/kivy/archive/{version}.zip' | ||
name = 'kivy' | ||
|
||
depends = ['sdl2', 'pyjnius', 'setuptools'] | ||
|
||
def cythonize_build(self, env, build_dir='.'): | ||
super(KivyRecipe, self).cythonize_build(env, build_dir=build_dir) | ||
|
||
if not exists(join(build_dir, 'kivy', 'include')): | ||
return | ||
|
||
# If kivy is new enough to use the include dir, copy it | ||
# manually to the right location as we bypass this stage of | ||
# the build | ||
with current_directory(build_dir): | ||
build_libs_dirs = glob.glob(join('build', 'lib.*')) | ||
|
||
for dirn in build_libs_dirs: | ||
shprint(sh.cp, '-r', join('kivy', 'include'), | ||
join(dirn, 'kivy')) | ||
|
||
def cythonize_file(self, env, build_dir, filename): | ||
# We can ignore a few files that aren't important to the | ||
# android build, and may not work on Android anyway | ||
do_not_cythonize = ['window_x11.pyx', ] | ||
if basename(filename) in do_not_cythonize: | ||
return | ||
super(KivyRecipe, self).cythonize_file(env, build_dir, filename) | ||
|
||
def get_recipe_env(self, arch): | ||
env = super(KivyRecipe, self).get_recipe_env(arch) | ||
if 'sdl2' in self.ctx.recipe_build_order: | ||
env['USE_SDL2'] = '1' | ||
env['KIVY_SPLIT_EXAMPLES'] = '1' | ||
env['KIVY_SDL2_PATH'] = ':'.join([ | ||
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'), | ||
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'), | ||
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer'), | ||
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'), | ||
]) | ||
|
||
return env | ||
|
||
|
||
class CustomKivyRecipe(KivyRecipe): | ||
""" | ||
Overrides `KivyRecipe`, patches performance issue, refs: | ||
- https://github.com/kivy/kivy/pull/6242 | ||
- https://github.com/kivy/python-for-android/issues/2002 | ||
""" | ||
patches = ('revert4219.patch',) | ||
|
||
|
||
recipe = CustomKivyRecipe() |
Oops, something went wrong.