コード例 #1
0
ファイル: controller.py プロジェクト: 0xLive/EtherollApp
 def transaction(self, to, amount_eth, wallet_path, password,
                 gas_price_gwei):
     """Converts input parameters for the underlying library."""
     value = int(amount_eth * 1e18)
     gas_price_wei = int(gas_price_gwei * 1e9)
     to = to_checksum_address(to)
     Dialog.snackbar_message("Sending transaction...")
     tx_hash = self.pyetheroll.transaction(to, value, wallet_path, password,
                                           gas_price_wei)
     self.dialog_transaction_success(tx_hash)
コード例 #2
0
ファイル: switchaccount.py プロジェクト: tundak/EtherollApp
 def on_empty_account_list():
     controller = App.get_running_app().root
     keystore_dir = controller.account_utils.keystore_dir
     title = "No account found"
     body = f"No account found in:\n{keystore_dir}"
     dialog = Dialog.create_dialog(title, body)
     dialog.open()
コード例 #3
0
 def show_redirect_dialog(self):
     title = "Account created, redirecting..."
     body = ""
     body += "Your account was created, "
     body += "you will be redirected to the overview."
     dialog = Dialog.create_dialog(title, body)
     dialog.open()
コード例 #4
0
ファイル: controller.py プロジェクト: 0xLive/EtherollApp
 def on_keyboard(self, window, key, *args):
     """
     Handles the back button (Android) and ESC key. Goes back to the
     previous screen, dicards dialogs or exits the application if none left.
     """
     if key == 27:
         if Dialog.dialogs:
             Dialog.dismiss_all_dialogs()
             return True
         from etherollapp.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
         if isinstance(current_screen, SubScreen):
             current_screen.on_back()
             return True
     return False
コード例 #5
0
ファイル: controller.py プロジェクト: 0xLive/EtherollApp
 def player_roll_dice(self, bet_size_eth, chances, wallet_path, password,
                      gas_price_gwei):
     """
     Sending the bet to the smart contract requires signing a transaction
     which requires CPU computation to unlock the account, hence this
     is ran in a thread.
     """
     roll_screen = self.roll_screen
     try:
         Dialog.snackbar_message("Sending bet...")
         roll_screen.toggle_widgets(False)
         bet_size_wei = int(bet_size_eth * 1e18)
         gas_price_wei = int(gas_price_gwei * 1e9)
         tx_hash = self.pyetheroll.player_roll_dice(bet_size_wei, chances,
                                                    wallet_path, password,
                                                    gas_price_wei)
     except (ValueError, ConnectionError) as exception:
         roll_screen.toggle_widgets(True)
         self.dialog_roll_error(exception)
         return
     roll_screen.toggle_widgets(True)
     self.dialog_roll_success(tx_hash)
コード例 #6
0
ファイル: controller.py プロジェクト: 0xLive/EtherollApp
 def dialog_roll_error(self, exception):
     """
     Shows different error message depending on the exception.
     On "MAC mismatch" (wrong password), void the cached password so the
     user can try again refs:
     https://github.com/AndreMiras/EtherollApp/issues/9
     """
     title = "Error rolling"
     body = str(exception)
     if body == 'MAC mismatch':
         title = "Wrong password"
         body = "Can't unlock wallet, wrong password."
         account = self.current_account
         self._account_passwords.pop(account.address.hex())
     dialog = Dialog.create_dialog(title, body)
     dialog.open()
コード例 #7
0
 def try_unlock(account, password):
     """
     Just as a security measure, verifies we can unlock
     the newly created account with provided password.
     """
     # making sure it's locked first
     account.lock()
     try:
         account.unlock(password)
     except ValueError:
         title = "Unlock error"
         body = ""
         body += "Couldn't unlock your account.\n"
         body += "The issue should be reported."
         dialog = Dialog.create_dialog(title, body)
         dialog.open()
         return
コード例 #8
0
 def dialog(cls, account):
     """Prompt the password dialog."""
     title = "Enter your password"
     password_form = cls()
     password_form.ids.account_id.text = "0x" + account.address.hex()
     dialog = Dialog.create_dialog_content_helper(title=title,
                                                  content=password_form)
     # workaround for MDDialog container size (too small by default)
     dialog.ids.container.size_hint_y = 1
     dialog.add_action_button(
         "Unlock",
         action=lambda *x: password_form.dispatch(
             'on_unlock', dialog, account, password_form.password))
     # hitting enter on the text should also submit
     password_form.ids.password_id.bind(
         on_text_validate=lambda *x: password_form.dispatch(
             'on_unlock', dialog, account, password_form.password))
     return dialog
コード例 #9
0
ファイル: controller.py プロジェクト: 0xLive/EtherollApp
 def show_qr_code(self):
     """Shows address QR Code in a dialog."""
     # lazy loading
     from kivy_garden.qrcode import QRCodeWidget
     from kivy.metrics import dp
     account = self.current_account
     if not account:
         return
     address = "0x" + account.address.hex()
     title = address
     qr_code = QRCodeWidget()
     qr_code.data = address
     dialog = Dialog.create_dialog_content_helper(title=title,
                                                  content=qr_code)
     # workaround for MDDialog container size (too small by default)
     dialog.ids.container.size_hint_y = 1
     dialog.height = dp(500)
     dialog.add_action_button("OK", action=lambda *x: dialog.dismiss())
     dialog.open()
     return dialog
コード例 #10
0
 def create_account(self):
     """
     Creates an account from provided form.
     Verify we can unlock it.
     Disables widgets during the process, so the user doesn't try
     to create another account during the process.
     """
     self.toggle_widgets(False)
     if not self.verify_fields():
         Dialog.show_invalid_form_dialog()
         self.toggle_widgets(True)
         return
     password = self.new_password1
     Dialog.snackbar_message("Creating account...")
     controller = App.get_running_app().root
     account = controller.account_utils.new_account(password=password)
     Dialog.snackbar_message("Created!")
     self.toggle_widgets(True)
     self.on_account_created(account)
     # CreateNewAccount.try_unlock(account, password)
     self.show_redirect_dialog()
     self.load_landing_page()
     return account
コード例 #11
0
ファイル: roll_results.py プロジェクト: tundak/EtherollApp
 def on_connection_refused():
     title = 'No network'
     body = 'No network, could not retrieve roll history.'
     dialog = Dialog.create_dialog(title, body)
     dialog.open()
コード例 #12
0
ファイル: controller.py プロジェクト: 0xLive/EtherollApp
 def on_permission_error(exception):
     title = "Permission denied"
     body = str(exception.args)
     dialog = Dialog.create_dialog(title, body)
     dialog.open()
コード例 #13
0
ファイル: controller.py プロジェクト: 0xLive/EtherollApp
 def dialog_transaction_success(tx_hash):
     title = "Transaction successful"
     body = "Transaction hash:\n" + tx_hash.hex()
     dialog = Dialog.create_dialog(title, body)
     dialog.open()
コード例 #14
0
ファイル: controller.py プロジェクト: 0xLive/EtherollApp
 def dialog_roll_success(tx_hash):
     title = "Rolled successfully"
     body = "Transaction hash:\n" + tx_hash.hex()
     dialog = Dialog.create_dialog(title, body)
     dialog.open()
コード例 #15
0
ファイル: controller.py プロジェクト: 0xLive/EtherollApp
 def on_account_none():
     """Error dialog on no account selected."""
     title = "No account selected"
     body = "Please select an account before rolling"
     dialog = Dialog.create_dialog(title, body)
     dialog.open()
コード例 #16
0
ファイル: roll.py プロジェクト: tundak/EtherollApp
 def on_connection_refused():
     title = 'No network'
     body = 'No network, could not retrieve account balance.'
     dialog = Dialog.create_dialog(title, body)
     dialog.open()