def get_chain_manager(self, account: Account) -> ChainManager: if account.account_type == "ethereum": accounts = BlockchainAccounts(eth=[account.address], btc=[], ksm=[]) elif account.account_type == "bitcoin": accounts = BlockchainAccounts(eth=[], btc=[account.address], ksm=[]) else: raise ValueError('Unable to create chain manager for account') # Eventually we should allow premium credentials in config file premium = False eth_modules = self.get_settings().active_modules if not premium: eth_modules = [mod for mod in eth_modules if mod not in PREMIUM_ONLY_ETH_MODULES] logger.debug('Creating ChainManager with modules: %s', eth_modules) manager = ChainManager( database=self, blockchain_accounts=accounts, beaconchain=self.beaconchain, data_directory=self.data_directory, ethereum_manager=self.ethereum_manager, kusama_manager=None, msg_aggregator=self.msg_aggregator, btc_derivation_gap_limit=self.get_settings().btc_derivation_gap_limit, greenlet_manager=self.greenlet_manager, premium=premium, eth_modules=eth_modules ) # Monkey-patch function that uses singleton manager.queried_addresses_for_module = lambda self, module = None: [account] return manager
def session_database( session_user_data_dir, messages_aggregator, session_db_password, session_db_settings, session_start_with_logged_in_user, session_ignored_assets, session_include_etherscan_key, session_include_cryptocompare_key, session_tags, session_manually_tracked_balances, data_migration_version, session_use_custom_database, ) -> Optional[DBHandler]: if not session_start_with_logged_in_user: return None # No sessions blockchain accounts given blockchain_accounts = BlockchainAccounts([], [], [], [], []) return _init_database( data_dir=session_user_data_dir, msg_aggregator=messages_aggregator, password=session_db_password, db_settings=session_db_settings, ignored_assets=session_ignored_assets, blockchain_accounts=blockchain_accounts, include_etherscan_key=session_include_etherscan_key, include_cryptocompare_key=session_include_cryptocompare_key, tags=session_tags, manually_tracked_balances=session_manually_tracked_balances, data_migration_version=data_migration_version, use_custom_database=session_use_custom_database, )
def get_chain_manager(self, account: Any) -> ChainManager: if 'ethereum' in account: accounts = BlockchainAccounts(eth=[account['ethereum']], btc=[]) elif 'bitcoin' in account: accounts = BlockchainAccounts(eth=[], btc=[account['bitcoin']]) else: raise ValueError('Invalid account') return ChainManager( blockchain_accounts=accounts, owned_eth_tokens=[], ethereum_manager=self.ethereum_manager, msg_aggregator=self.msg_aggregator, alethio=self.alethio, greenlet_manager=self.greenlet_manager, premium=False, eth_modules=[], )
def fixture_blockchain_accounts( ethereum_accounts: List[ChecksumEthAddress], btc_accounts: List[BTCAddress], ksm_accounts: List[KusamaAddress], ) -> BlockchainAccounts: return BlockchainAccounts( eth=ethereum_accounts, btc=btc_accounts.copy(), ksm=ksm_accounts.copy(), )
def get_blockchain_accounts(self) -> BlockchainAccounts: """Returns a Blockchain accounts instance""" cursor = self.conn.cursor() query = cursor.execute( 'SELECT blockchain, account FROM blockchain_accounts;', ) query = query.fetchall() eth_list = list() btc_list = list() for entry in query: if entry[0] == S_ETH: eth_list.append(entry[1]) elif entry[0] == S_BTC: btc_list.append(entry[1]) else: log.warning( f'unknown blockchain type {entry[0]} found in DB. Ignoring...', ) return BlockchainAccounts(eth=eth_list, btc=btc_list)
def session_database( session_user_data_dir, messages_aggregator, session_db_password, session_db_settings, session_start_with_logged_in_user, session_ignored_assets, ) -> Optional[DBHandler]: if not session_start_with_logged_in_user: return None # No sessions blockchain accounts given blockchain_accounts = BlockchainAccounts([], []) return _init_database( data_dir=session_user_data_dir, msg_aggregator=messages_aggregator, password=session_db_password, db_settings=session_db_settings, ignored_assets=session_ignored_assets, blockchain_accounts=blockchain_accounts, )
def blockchain_accounts( ethereum_accounts: List[ChecksumEthAddress], btc_accounts: List[BTCAddress], ) -> BlockchainAccounts: return BlockchainAccounts(eth=ethereum_accounts, btc=btc_accounts.copy())
def blockchain_accounts(ethereum_accounts: List[EthAddress]) -> BlockchainAccounts: return BlockchainAccounts(eth=ethereum_accounts, btc=[])
def get_blockchain_accounts(self) -> BlockchainAccounts: if self._active_eth_address: return BlockchainAccounts(eth=[self._active_eth_address], btc=[], ksm=[]) return BlockchainAccounts(eth=[], btc=[], ksm=[])