def test_get_set_stored_network(self): """ Checks default stored network and set method. """ # checks default assert Settings.get_stored_network() == ChainID.MAINNET # checks set Settings.set_stored_network(ChainID.ROPSTEN) assert Settings.get_stored_network() == ChainID.ROPSTEN
def fetch_balance(self): """ Fetches the new balance & sets accounts_balance property. """ if self.current_account is None: return address = '0x' + self.current_account.address.hex() chain_id = Settings.get_stored_network() try: balance = PyWalib.get_balance(address, chain_id) except ConnectionError: Dialog.on_balance_connection_error() Logger.warning('ConnectionError', exc_info=True) return except ValueError: # most likely the JSON object could not be decoded, refs #91 # currently logged as an error, because we want more insight # in order to eventually handle it more specifically Dialog.on_balance_value_error() Logger.error('ValueError', exc_info=True) return except UnknownEtherscanException: # also handles uknown errors, refs #112 Dialog.on_balance_unknown_error() Logger.error('UnknownEtherscanException', exc_info=True) return # triggers accounts_balance observers update self.accounts_balance[address] = balance
def pywalib(self): """ Gets or creates the PyWalib object. Also recreates the object if the keystore_path changed. """ keystore_path = Settings.get_keystore_path() chain_id = Settings.get_stored_network() if self._pywalib is None or \ self._pywalib.keystore_dir != keystore_path or \ self._pywalib.chain_id != chain_id: self._pywalib = PyWalib( keystore_dir=keystore_path, chain_id=chain_id) return self._pywalib
def fetch_history(self): if self.current_account is None: return chain_id = Settings.get_stored_network() address = '0x' + self.current_account.address.hex() try: transactions = PyWalib.get_transaction_history(address, chain_id) except ConnectionError: Dialog.on_history_connection_error() Logger.warning('ConnectionError', exc_info=True) return except NoTransactionFoundException: transactions = [] except ValueError: # most likely the JSON object could not be decoded, refs #91 Dialog.on_history_value_error() # currently logged as an error, because we want more insight # in order to eventually handle it more specifically Logger.error('ValueError', exc_info=True) return # triggers accounts_history observers update self.controller.accounts_history[address] = transactions