Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/v20180918'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Sep 17, 2018
2 parents 0555ffd + f69809d commit e64977c
Show file tree
Hide file tree
Showing 24 changed files with 269 additions and 134 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://secure.travis-ci.org/AndreMiras/EtherollApp.png?branch=develop)](http://travis-ci.org/AndreMiras/EtherollApp)

<a href="https://github.com/AndreMiras/EtherollApp/releases/download/v20180617/etheroll-2018.0617-debug.apk"><img src="https://www.scottishchildrenslottery.com/export/system/modules/com.assense.gaming.stv.template/resources/images/google-play-store.svg" width="200"></a>
<a href="https://github.com/AndreMiras/EtherollApp/releases/download/v20180918/etheroll-2018.0918-debug.apk"><img src="https://www.scottishchildrenslottery.com/export/system/modules/com.assense.gaming.stv.template/resources/images/google-play-store.svg" width="200"></a>

Provably fair dice game running on the [Ethereum blockchain](https://etheroll.com/#/smart-contract).
Built with Python, [Kivy](https://github.com/kivy/kivy) and love.
Expand Down
4 changes: 2 additions & 2 deletions buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ requirements =
hostpython3crystax==3.6,
python3crystax==3.6,
setuptools,
kivy==d8ef8c2,
kivy==1.10.1,
plyer==1.3.0,
android,
gevent,
cffi,
https://gitlab.com/kivymd/KivyMD/repository/archive.zip?ref=19e587e6,
https://github.com/AndreMiras/KivyMD/archive/9b2206a.tar.gz,
openssl,
pyelliptic==1.5.7,
asn1crypto==0.24.0,
Expand Down
3 changes: 2 additions & 1 deletion docs/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Start the release with git flow:
```
git flow release start vYYYYMMDD
```
Now update the CHANGELOG.md `[Unreleased]` section to match the new release version.
Now update the [CHANGELOG.md](/src/CHANGELOG.md) `[Unreleased]` section to match the new release version.
Also update the `__version__` string of the [version.py](/src/version.py) file. Then commit and finish release.
Optionally already update the direct download link from the [README.md](/README.md).
```
git commit -a -m "vYYYYMMDD"
git flow release finish
Expand Down
10 changes: 2 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ eth-testrpc==1.3.3
https://github.com/corpetty/py-etherscan-api/archive/cb91fb3.zip#egg=py-etherscan-api
flake8
isort
# on Ubuntu 16.04 Xenial, the error:
# x11 - ImportError: No module named window_x11
# is fixed by installing kivy master
# https://github.com/kivy/kivy/archive/27e3b90eae2a0155b22a435f1b6f65c913519db6.zip#egg=kivy
# on Ubuntu 18.04 Bionic, the compile error related to `MIX_INIT_MOD` is fixed by installing:
https://github.com/kivy/kivy/archive/d8ef8c2.zip#egg=kivy
# Kivy==1.10.0
https://gitlab.com/kivymd/KivyMD/repository/archive.zip?ref=19e587e6#egg=kivymd
Kivy==1.10.1
https://github.com/AndreMiras/KivyMD/archive/9b2206a.tar.gz#egg=kivymd
ethereum==2.1.1
# 2017/10/30 develop
https://github.com/ethereum/pyethapp/archive/8406f32.zip#egg=pyethapp
Expand Down
12 changes: 11 additions & 1 deletion src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
# Change Log


## [v20180918]

- Notify when roll processed, refs #57, #103, #106
- Recipes LDSHARED & CFLAGS cleaning, refs #104
- Updates broken Mainnet node, refs #111
- Upgrades to Kivy==1.10.1, refs #100


## [v20180911]

- Fix pycryptodome compilation, refs #99
- Notifie when roll processed, refs #57
- Update to new contract address


## [v20180617]

- Fix crash when deployed on SD, refs #96


## [v20180531]

- Handle wrong password error, refs #9
Expand Down
69 changes: 9 additions & 60 deletions src/etheroll/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

from kivy.app import App
from kivy.clock import Clock, mainthread
from kivy.logger import LOG_LEVELS, Logger
from kivy.logger import Logger
from kivy.properties import ObjectProperty
from kivy.uix.floatlayout import FloatLayout
from kivy.utils import platform
from kivymd.bottomsheet import MDListBottomSheet
from kivymd.theming import ThemeManager
from raven import Client
from raven.conf import setup_logging
from raven.handlers.logging import SentryHandler
from requests.exceptions import ConnectionError

from etheroll.constants import KEYSTORE_DIR_SUFFIX
from etheroll.patches import patch_find_library_android, patch_typing_python351
from etheroll.settings import SettingsScreen
from etheroll.switchaccount import SwitchAccountScreen
from etheroll.utils import Dialog, load_kv_from_py, run_in_thread
from version import __version__
from sentry_utils import configure_sentry
from service.utils import start_service

patch_find_library_android()
patch_typing_python351()
Expand Down Expand Up @@ -309,7 +309,7 @@ def dialog_roll_error(self, exception):
"""
title = "Error rolling"
body = str(exception)
if exception.args[0] == 'MAC mismatch':
if body == 'MAC mismatch':
title = "Wrong password"
body = "Can't unlock wallet, wrong password."
account = self.current_account
Expand All @@ -331,7 +331,7 @@ def player_roll_dice(
roll_screen.toggle_widgets(False)
tx_hash = self.pyetheroll.player_roll_dice(
bet_size, chances, wallet_path, password, gas_price)
except ValueError as exception:
except (ValueError, ConnectionError) as exception:
roll_screen.toggle_widgets(True)
self.dialog_roll_error(exception)
return
Expand All @@ -357,6 +357,8 @@ def roll(self):
if password is not None:
self.player_roll_dice(
bet_size, chances, wallet_path, password, gas_price)
# restarts roll pulling service to reset the roll activity period
start_service()

def load_switch_account(self):
"""
Expand Down Expand Up @@ -431,43 +433,6 @@ def captureException(self):
raise


def configure_sentry(in_debug=False):
"""
Configure the Raven client, or create a dummy one if `in_debug` is `True`.
"""
key = 'b290ecc8934f4cb599e6fa6af6cc5cc2'
# the public DSN URL is not available on the Python client
# so we're exposing the secret and will be revoking it on abuse
# https://github.com/getsentry/raven-python/issues/569
secret = '0ae02bcb5a75467d9b4431042bb98cb9'
project_id = '1111738'
dsn = 'https://{key}:{secret}@sentry.io/{project_id}'.format(
key=key, secret=secret, project_id=project_id)
if in_debug:
client = DebugRavenClient()
else:
client = Client(dsn=dsn, release=__version__)
# adds context for Android devices
if platform == 'android':
from jnius import autoclass
Build = autoclass("android.os.Build")
VERSION = autoclass('android.os.Build$VERSION')
android_os_build = {
'model': Build.MODEL,
'brand': Build.BRAND,
'device': Build.DEVICE,
'manufacturer': Build.MANUFACTURER,
'version_release': VERSION.RELEASE,
}
client.user_context({'android_os_build': android_os_build})
# Logger.error() to Sentry
# https://docs.sentry.io/clients/python/integrations/logging/
handler = SentryHandler(client)
handler.setLevel(LOG_LEVELS.get('error'))
setup_logging(handler)
return client


class EtherollApp(App):

theme_cls = ThemeManager()
Expand All @@ -476,25 +441,9 @@ def build(self):
self.icon = "docs/images/icon.png"
self.theme_cls.theme_style = 'Dark'
self.theme_cls.primary_palette = 'Indigo'
self.start_service()
start_service()
return Controller()

def start_service(self):
"""
Starts the roll pulling service.
"""
if platform == 'android':
from jnius import autoclass
package_name = 'etheroll'
package_domain = 'com.github.andremiras'
service_name = 'service'
service_class = '{}.{}.Service{}'.format(
package_domain, package_name, service_name.title())
service = autoclass(service_class)
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
argument = ''
service.start(mActivity, argument)


def main():
# only send Android errors to Sentry
Expand Down
54 changes: 54 additions & 0 deletions src/etheroll/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
from kivy.app import App
from kivy.clock import mainthread
from kivy.lang import Builder
from kivy.logger import LOG_LEVELS
from kivy.metrics import dp
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import Screen
from kivy.utils import platform
from kivymd.dialog import MDDialog
from kivymd.label import MDLabel
from kivymd.snackbar import Snackbar
from layoutmargin import AddMargin, MarginLayout
from raven import Client
from raven.conf import setup_logging
from raven.handlers.logging import SentryHandler

from version import __version__


def run_in_thread(fn):
Expand Down Expand Up @@ -52,6 +59,53 @@ def load_kv_from_py(f):
)


def configure_sentry(in_debug=False):
"""
Configure the Raven client, or create a dummy one if `in_debug` is `True`.
"""
key = 'b290ecc8934f4cb599e6fa6af6cc5cc2'
# the public DSN URL is not available on the Python client
# so we're exposing the secret and will be revoking it on abuse
# https://github.com/getsentry/raven-python/issues/569
secret = '0ae02bcb5a75467d9b4431042bb98cb9'
project_id = '1111738'
dsn = 'https://{key}:{secret}@sentry.io/{project_id}'.format(
key=key, secret=secret, project_id=project_id)
if in_debug:
client = DebugRavenClient()
else:
client = Client(dsn=dsn, release=__version__)
# adds context for Android devices
if platform == 'android':
from jnius import autoclass
Build = autoclass("android.os.Build")
VERSION = autoclass('android.os.Build$VERSION')
android_os_build = {
'model': Build.MODEL,
'brand': Build.BRAND,
'device': Build.DEVICE,
'manufacturer': Build.MANUFACTURER,
'version_release': VERSION.RELEASE,
}
client.user_context({'android_os_build': android_os_build})
# Logger.error() to Sentry
# https://docs.sentry.io/clients/python/integrations/logging/
handler = SentryHandler(client)
handler.setLevel(LOG_LEVELS.get('error'))
setup_logging(handler)
return client


class DebugRavenClient(object):
"""
The DebugRavenClient should be used in debug mode, it just raises
the exception rather than capturing it.
"""

def captureException(self):
raise


class StringIOCBWrite(StringIO):
"""
Inherits StringIO, provides callback on write.
Expand Down
5 changes: 3 additions & 2 deletions src/pyetheroll/transaction_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def decode_contract_call(contract_abi: list, call_data: str):
class HTTPProviderFactory:

PROVIDER_URLS = {
ChainID.MAINNET: 'https://api.myetherapi.com/eth',
# also https://api.myetherapi.com/rop
# ChainID.MAINNET: 'https://api.myetherapi.com/eth',
ChainID.MAINNET: 'https://mainnet.infura.io',
# ChainID.ROPSTEN: 'https://api.myetherapi.com/rop',
ChainID.ROPSTEN: 'https://ropsten.infura.io',
}

Expand Down
5 changes: 0 additions & 5 deletions src/python-for-android/recipes/cffi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class CffiRecipe(CompiledComponentsPythonRecipe):

def get_recipe_env(self, arch=None):
env = super(CffiRecipe, self).get_recipe_env(arch)
# sets linker to use the correct gcc (cross compiler)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
libffi = self.get_recipe('libffi', self.ctx)
includes = libffi.get_include_dirs(arch)
env['CFLAGS'] = ' -I'.join([env.get('CFLAGS', '')] + includes)
Expand All @@ -39,9 +37,6 @@ def get_recipe_env(self, arch=None):
ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version)
env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
env['LDFLAGS'] += ' -lpython{}m'.format(python_version)
# until `pythonforandroid/archs.py` gets merged upstream:
# https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6
env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python)
return env


Expand Down
5 changes: 0 additions & 5 deletions src/python-for-android/recipes/coincurve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class CoincurveRecipe(PythonRecipe):

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(CoincurveRecipe, self).get_recipe_env(arch, with_flags_in_cc)
# sets linker to use the correct gcc (cross compiler)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
libsecp256k1 = self.get_recipe('libsecp256k1', self.ctx)
libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch)
env['CFLAGS'] += ' -I' + os.path.join(libsecp256k1_dir, 'include')
Expand All @@ -26,9 +24,6 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version)
env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
env['LDFLAGS'] += ' -lpython{}m'.format(python_version)
# until `pythonforandroid/archs.py` gets merged upstream:
# https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6
env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python)
env['LDFLAGS'] += " -lsecp256k1"
return env

Expand Down
5 changes: 0 additions & 5 deletions src/python-for-android/recipes/cytoolz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ class CytoolzRecipe(PythonRecipe):

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(CytoolzRecipe, self).get_recipe_env(arch, with_flags_in_cc)
# sets linker to use the correct gcc (cross compiler)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
# required additional library and path for Crystax
if self.ctx.ndk == 'crystax':
# only keeps major.minor (discards patch)
python_version = self.ctx.python_recipe.version[0:3]
ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version)
env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
env['LDFLAGS'] += ' -lpython{}m'.format(python_version)
# until `pythonforandroid/archs.py` gets merged upstream:
# https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6
env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python)
return env


Expand Down
5 changes: 0 additions & 5 deletions src/python-for-android/recipes/greenlet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ class GreenletRecipe(PythonRecipe):

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(GreenletRecipe, self).get_recipe_env(arch, with_flags_in_cc)
# sets linker to use the correct gcc (cross compiler)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
# required additional library and path for Crystax
if self.ctx.ndk == 'crystax':
# only keeps major.minor (discards patch)
python_version = self.ctx.python_recipe.version[0:3]
ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version)
env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
env['LDFLAGS'] += ' -lpython{}m'.format(python_version)
# until `pythonforandroid/archs.py` gets merged upstream:
# https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6
env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python)
return env


Expand Down
5 changes: 0 additions & 5 deletions src/python-for-android/recipes/lru-dict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ class LruDictRecipe(PythonRecipe):

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(LruDictRecipe, self).get_recipe_env(arch, with_flags_in_cc)
# sets linker to use the correct gcc (cross compiler)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
# required additional library and path for Crystax
if self.ctx.ndk == 'crystax':
# only keeps major.minor (discards patch)
python_version = self.ctx.python_recipe.version[0:3]
ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version)
env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
env['LDFLAGS'] += ' -lpython{}m'.format(python_version)
# until `pythonforandroid/archs.py` gets merged upstream:
# https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6
env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python)
return env


Expand Down
2 changes: 0 additions & 2 deletions src/python-for-android/recipes/pycryptodome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class PycryptodomeRecipe(PythonRecipe):

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(PycryptodomeRecipe, self).get_recipe_env(arch, with_flags_in_cc)
# sets linker to use the correct gcc (cross compiler)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
env['LDFLAGS'] += ' -L{}'.format(os.path.join(self.ctx.bootstrap.build_dir, 'libs', arch.arch))
return env

Expand Down
Loading

0 comments on commit e64977c

Please sign in to comment.