def raise_block_not_found_for_uncle_at_index( params: Tuple[BlockIdentifier, Union[HexStr, int]]) -> NoReturn: block_identifier = params[0] uncle_index = to_integer_if_hex(params[1]) raise BlockNotFound( f"Uncle at index: {uncle_index} of block with id: {block_identifier} not found." )
def raise_block_not_found(params: Tuple[BlockIdentifier, bool]) -> NoReturn: try: block_identifier = params[0] message = f"Block with id: {block_identifier!r} not found." except IndexError: message = "Unknown block identifier" raise BlockNotFound(message)
def raise_block_not_found_for_uncle_at_index( params: Tuple[BlockIdentifier, Union[HexStr, int]]) -> NoReturn: try: block_identifier = params[0] uncle_index = to_integer_if_hex(params[1]) message = (f"Uncle at index: {uncle_index} of block with id: " f"{block_identifier!r} not found.") except IndexError: message = "Unknown block identifier or uncle index" raise BlockNotFound(message)
def getUncleCount(self, block_identifier: BlockIdentifier) -> int: """ `eth_getUncleCountByBlockHash` `eth_getUncleCountByBlockNumber` """ method = select_method_for_block_identifier( block_identifier, if_predefined=RPC.eth_getUncleCountByBlockNumber, if_hash=RPC.eth_getUncleCountByBlockHash, if_number=RPC.eth_getUncleCountByBlockNumber, ) result = self.web3.manager.request_blocking( method, [block_identifier], ) if result is None: raise BlockNotFound(f"Block with id: {block_identifier} not found.") return result
def getBlockTransactionCount(self, block_identifier): """ `eth_getBlockTransactionCountByHash` `eth_getBlockTransactionCountByNumber` """ method = select_method_for_block_identifier( block_identifier, if_predefined='eth_getBlockTransactionCountByNumber', if_hash='eth_getBlockTransactionCountByHash', if_number='eth_getBlockTransactionCountByNumber', ) result = self.web3.manager.request_blocking( method, [block_identifier], ) if result is None: raise BlockNotFound(f"Block with id: {block_identifier} not found.") return result
def getUncleByBlock(self, block_identifier: BlockIdentifier, uncle_index: int) -> Uncle: """ `eth_getUncleByBlockHashAndIndex` `eth_getUncleByBlockNumberAndIndex` """ method = select_method_for_block_identifier( block_identifier, if_predefined=RPC.eth_getUncleByBlockNumberAndIndex, if_hash=RPC.eth_getUncleByBlockHashAndIndex, if_number=RPC.eth_getUncleByBlockNumberAndIndex, ) result = self.web3.manager.request_blocking( method, [block_identifier, uncle_index], ) if result is None: raise BlockNotFound( f"Uncle at index: {uncle_index} of block with id: {block_identifier} not found." ) return result
def getBlock(self, block_identifier, full_transactions=False): """ `hpb_getBlockByHash` `hpb_getBlockByNumber` """ method = select_method_for_block_identifier( block_identifier, if_predefined='hpb_getBlockByNumber', if_hash='hpb_getBlockByHash', if_number='hpb_getBlockByNumber', ) result = self.web3.manager.request_blocking( method, [block_identifier, full_transactions], ) if result is None: raise BlockNotFound( f"Block with id: {block_identifier} not found.") return result
def getBlock( self, block_identifier: BlockIdentifier, full_transactions: bool=False ) -> BlockData: """ `eth_getBlockByHash` `eth_getBlockByNumber` """ method = select_method_for_block_identifier( block_identifier, if_predefined=RPC.eth_getBlockByNumber, if_hash=RPC.eth_getBlockByHash, if_number=RPC.eth_getBlockByNumber, ) result = self.web3.manager.request_blocking( method, [block_identifier, full_transactions], ) if result is None: raise BlockNotFound(f"Block with id: {block_identifier} not found.") return result
def raise_block_not_found(params: Tuple[BlockIdentifier, bool]) -> NoReturn: block_identifier = params[0] raise BlockNotFound(f"Block with id: {block_identifier} not found.")