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/v20181028'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Oct 28, 2018
2 parents e64977c + 68deb58 commit a7d9e6d
Show file tree
Hide file tree
Showing 32 changed files with 489 additions and 293 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/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>
<a href="https://github.com/AndreMiras/EtherollApp/releases/download/v20181028/etheroll-2018.1028-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
3 changes: 2 additions & 1 deletion buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ requirements =
python3crystax==3.6,
setuptools,
kivy==1.10.1,
plyer==1.3.0,
plyer==1.3.1,
oscpy==0.3.0,
android,
gevent,
cffi,
Expand Down
4 changes: 4 additions & 0 deletions docs/Debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ https://lab.miguelmota.com/ethereum-input-data-decoder/example/
```
buildozer android adb -- logcat
```
or with filtering:
```
buildozer android adb -- logcat | grep -E '(python |service ):'
```
2 changes: 1 addition & 1 deletion docs/Troubleshoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ List of devices attached

Update your udev rules, there's an example to adapt to your Android device here:
```
sudo cp root/etc/udev/rules.d/51-android.rules /etc/udev/rules.d/
sudo cp docs/root/etc/udev/rules.d/51-android.rules /etc/udev/rules.d/
```
Then replug your device and rerun the command.

Expand Down
13 changes: 13 additions & 0 deletions docs/root/etc/udev/rules.d/51-android.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://developer.android.com/studio/run/device.html
# copy to:
# /etc/udev/rules.d/
# then:
# sudo systemctl restart udev
# Huawei (12d1)
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"
# Samsung (04e8)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
# HTC (0bb4)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
# Google & LineageOS (18d1)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ rlp==0.6.0
# https://github.com/golemfactory/golem-messages/pull/112/files
https://github.com/mfranciszkiewicz/pyelliptic/archive/1.5.10.tar.gz#egg=pyelliptic
https://github.com/AndreMiras/garden.layoutmargin/archive/20180517.zip#egg=layoutmargin
plyer==1.3.0
plyer==1.3.1
oscpy==0.3.0
9 changes: 9 additions & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Change Log


## [v20181028]

- Click notification to open the app, refs #114
- Bets 2nd decimal place precision, refs #116
- Platform agnostic notification service, refs #120
- Updates balance on roll, refs #115
- Removes typing patch, refs #72


## [v20180918]

- Notify when roll processed, refs #57, #103, #106
Expand Down
4 changes: 2 additions & 2 deletions src/etheroll/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from kivy.properties import StringProperty
from kivy.uix.boxlayout import BoxLayout

from etheroll.utils import (StringIOCBWrite, SubScreen, load_kv_from_py,
run_in_thread)
from etheroll.ui_utils import SubScreen, load_kv_from_py
from etheroll.utils import StringIOCBWrite, run_in_thread
from version import __version__

load_kv_from_py(__file__)
Expand Down
62 changes: 27 additions & 35 deletions src/etheroll/controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
import os

from kivy.app import App
from kivy.clock import Clock, mainthread
from kivy.logger import Logger
Expand All @@ -12,16 +10,16 @@
from raven import Client
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.patches import patch_find_library_android
from etheroll.settings import SettingsScreen
from etheroll.switchaccount import SwitchAccountScreen
from etheroll.utils import Dialog, load_kv_from_py, run_in_thread
from etheroll.ui_utils import Dialog, load_kv_from_py
from etheroll.utils import run_in_thread
from osc.osc_app_server import OscAppServer
from sentry_utils import configure_sentry
from service.utils import start_service
from service.utils import start_roll_pulling_service

patch_find_library_android()
patch_typing_python351()
load_kv_from_py(__file__)


Expand Down Expand Up @@ -62,7 +60,7 @@ def on_keyboard(self, window, key, *args):
if Dialog.dialogs:
Dialog.dismiss_all_dialogs()
return True
from etheroll.utils import SubScreen
from etheroll.ui_utils import SubScreen
current_screen = self.screen_manager.current_screen
# if is sub-screen loads previous and stops the propagation
# otherwise propagates the key to exit
Expand All @@ -89,8 +87,9 @@ def account_utils(self):
Gets or creates the AccountUtils object so it loads lazily.
"""
from ethereum_utils import AccountUtils
from etheroll.store import Store
if self._account_utils is None:
keystore_dir = self.get_keystore_path()
keystore_dir = Store.get_keystore_path()
self._account_utils = AccountUtils(keystore_dir=keystore_dir)
return self._account_utils

Expand All @@ -103,30 +102,6 @@ def preload_account_utils(self, dt):
# not using that returned value, but it peaces linter
return account_utils

@classmethod
def get_keystore_path(cls):
"""
This is the Kivy default keystore path.
"""
keystore_path = os.environ.get('KEYSTORE_PATH')
if keystore_path is None:
keystore_path = cls.get_default_keystore_path()
return keystore_path

@staticmethod
def get_default_keystore_path():
"""
Returns the keystore path, which is the same as the default pyethapp
one.
"""
KEYSTORE_DIR_PREFIX = os.path.expanduser("~")
# uses kivy user_data_dir (/sdcard/<app_name>)
if platform == "android":
KEYSTORE_DIR_PREFIX = App.get_running_app().user_data_dir
keystore_dir = os.path.join(
KEYSTORE_DIR_PREFIX, KEYSTORE_DIR_SUFFIX)
return keystore_dir

def bind_wager_property(self):
"""
Binds wager recap label.
Expand Down Expand Up @@ -338,6 +313,23 @@ def player_roll_dice(
roll_screen.toggle_widgets(True)
self.dialog_roll_success(tx_hash)

@staticmethod
def start_services():
"""
Starts both roll pulling service and OSC service.
The roll pulling service is getting the OSC server connection
parameters so it can communicate to it.
"""
app = App.get_running_app()
osc_server, sockname = OscAppServer.get_or_create(app)
server_address, server_port = sockname
print(sockname)
arguments = {
'osc_server_address': server_address,
'osc_server_port': server_port,
}
start_roll_pulling_service(arguments)

def roll(self):
"""
Retrieves bet parameters from user input and sends it as a signed
Expand All @@ -358,7 +350,7 @@ def roll(self):
self.player_roll_dice(
bet_size, chances, wallet_path, password, gas_price)
# restarts roll pulling service to reset the roll activity period
start_service()
self.start_services()

def load_switch_account(self):
"""
Expand Down Expand Up @@ -441,7 +433,7 @@ def build(self):
self.icon = "docs/images/icon.png"
self.theme_cls.theme_style = 'Dark'
self.theme_cls.primary_palette = 'Indigo'
start_service()
Controller.start_services()
return Controller()


Expand Down
3 changes: 2 additions & 1 deletion src/etheroll/createnewaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from kivy.properties import StringProperty
from kivy.uix.boxlayout import BoxLayout

from etheroll.utils import Dialog, load_kv_from_py, run_in_thread
from etheroll.ui_utils import Dialog, load_kv_from_py
from etheroll.utils import run_in_thread

load_kv_from_py(__file__)

Expand Down
2 changes: 1 addition & 1 deletion src/etheroll/customtoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from kivy.clock import Clock
from kivymd.toolbar import Toolbar

from etheroll.utils import load_kv_from_py
from etheroll.ui_utils import load_kv_from_py

load_kv_from_py(__file__)

Expand Down
7 changes: 3 additions & 4 deletions src/etheroll/importkeystore.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from kivy.app import App
from kivy.clock import Clock
from kivy.properties import StringProperty
from kivy.uix.boxlayout import BoxLayout

from etheroll.utils import load_kv_from_py
from etheroll.store import Store
from etheroll.ui_utils import load_kv_from_py

load_kv_from_py(__file__)

Expand All @@ -19,5 +19,4 @@ def _after_init(self, dt):
"""
Sets keystore_path.
"""
controller = App.get_running_app().root
self.keystore_path = controller.get_keystore_path()
self.keystore_path = Store.get_keystore_path()
2 changes: 1 addition & 1 deletion src/etheroll/passwordform.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from kivy.properties import StringProperty
from kivy.uix.boxlayout import BoxLayout

from etheroll.utils import Dialog, load_kv_from_py
from etheroll.ui_utils import Dialog, load_kv_from_py

load_kv_from_py(__file__)

Expand Down
18 changes: 0 additions & 18 deletions src/etheroll/patches.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ctypes.util
import os
import typing
from ctypes.util import find_library as original_find_library

from kivy.utils import platform
Expand Down Expand Up @@ -33,20 +32,3 @@ def patch_find_library_android():
"""
if platform == 'android':
ctypes.util.find_library = find_library


CT_co = typing.TypeVar('CT_co', covariant=True, bound=type)


class Type(typing.Generic[CT_co], extra=type):
__slots__ = ()


def patch_typing_python351():
"""
Python 3.5.1 doesn't have typing.Type, refs:
https://github.com/crystax/android-vendor-python-3-5/issues/1
"""
# TODO: check Python version and only patch if == 3.5.1
if not hasattr(typing, 'Type'):
typing.Type = Type
4 changes: 2 additions & 2 deletions src/etheroll/roll.kv
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
size_hint_y: None
MDTextField:
id: bet_size_input_id
text: "0.1"
text: "0.10"
font_size: dp(20)
input_filter: 'float'
width: dp(40)
size_hint_x: None
MDSlider:
id: bet_size_slider_id
range: 0, 10
step: 0.1
step: 0.05

<ChanceOfWinning>:
orientation: "vertical"
Expand Down
5 changes: 3 additions & 2 deletions src/etheroll/roll.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import Screen

from etheroll.utils import Dialog, load_kv_from_py, run_in_thread
from etheroll.ui_utils import Dialog, load_kv_from_py
from etheroll.utils import run_in_thread
from pyetheroll.constants import ROUND_DIGITS

load_kv_from_py(__file__)
Expand All @@ -32,7 +33,7 @@ def _after_init(self, dt):
inpt = self.ids.bet_size_input_id
cast_to = float
# shows less digits than the constant default to keep the input tiny
round_digits = 1
round_digits = 2
BetSize.bind_slider_input(slider, inpt, cast_to, round_digits)

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion src/etheroll/roll_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from kivymd.label import MDLabel
from kivymd.list import ILeftBody, ThreeLineAvatarListItem

from etheroll.utils import Dialog, SubScreen, load_kv_from_py, run_in_thread
from etheroll.ui_utils import Dialog, SubScreen, load_kv_from_py
from etheroll.utils import run_in_thread
from pyetheroll.constants import ROUND_DIGITS

load_kv_from_py(__file__)
Expand Down
2 changes: 1 addition & 1 deletion src/etheroll/scroll_view_spinner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from kivymd.spinner import MDSpinner

from etheroll.utils import load_kv_from_py
from etheroll.ui_utils import load_kv_from_py

load_kv_from_py(__file__)

Expand Down
2 changes: 1 addition & 1 deletion src/etheroll/scrollablelabel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from kivy.properties import StringProperty
from kivy.uix.scrollview import ScrollView

from etheroll.utils import load_kv_from_py
from etheroll.ui_utils import load_kv_from_py

load_kv_from_py(__file__)

Expand Down
2 changes: 1 addition & 1 deletion src/etheroll/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from etheroll.store import Store
from etheroll.utils import SubScreen, load_kv_from_py
from etheroll.ui_utils import SubScreen, load_kv_from_py
from pyetheroll.constants import DEFAULT_GAS_PRICE_GWEI, ChainID

load_kv_from_py(__file__)
Expand Down
Loading

0 comments on commit a7d9e6d

Please sign in to comment.