def eth_getLogs(self, fromBlock=None, toBlock=None, address=None, topics=None, validate_block_number=True): """validate_block_number (default True), if True will also check the node's current blockNumber and make sure it is not lower than either the fromBlock or toBlock arguments""" kwargs = {} if fromBlock: kwargs['fromBlock'] = validate_block_param(fromBlock) if toBlock: kwargs['toBlock'] = validate_block_param(toBlock) if address: kwargs['address'] = validate_hex_int(address) if topics: # validate topics if not isinstance(topics, list): raise TypeError("topics must be an array of DATA") for topic in topics: if isinstance(topic, list): if not all(validate_hex_int(t, 32) for t in topic if t is not None): raise TypeError("topics must be an array of DATA") else: if topic is not None and not validate_hex_int(topic): raise TypeError("topics must be an array of DATA") kwargs['topics'] = topics if validate_block_number and (fromBlock or toBlock): return self._eth_getLogs_with_block_number_validation(kwargs) else: return self._fetch("eth_getLogs", [kwargs])
def eth_newFilter(self, *, fromBlock=None, toBlock=None, address=None, topics=None): kwargs = {} if fromBlock: kwargs['fromBlock'] = validate_block_param(fromBlock) if toBlock: kwargs['toBlock'] = validate_block_param(toBlock) if address: kwargs['address'] = validate_hex_int(address) if topics: if not isinstance(topics, list): raise TypeError("topics must be an array of DATA") kwargs['topics'] = [None if i is None else validate_hex_int(i, 32) for i in topics] return self._fetch("eth_newFilter", [kwargs])
def eth_call(self, *, to_address, from_address=None, gas=None, gasprice=None, value=None, data=None, block="latest", result_processor=None): to_address = validate_hex_int(to_address) block = validate_block_param(block) callobj = {"to": to_address} if from_address: callobj['from'] = validate_hex_int(from_address) if gas: callobj['gas'] = validate_hex_int(gas) if gasprice: callobj['gasPrice'] = validate_hex_int(gasprice) if value: callobj['value'] = validate_hex_int(value) if data: callobj['data'] = validate_hex_int(data) return self._fetch("eth_call", [callobj, block], result_processor)
def eth_getCode(self, address, block="latest"): address = validate_hex_int(address) block = validate_block_param(block) return self._fetch("eth_getCode", [address, block])
def eth_getBlockByNumber(self, number, with_transactions=True): number = validate_block_param(number) return self._fetch("eth_getBlockByNumber", [number, with_transactions])
def eth_getTransactionCount(self, address, block="latest"): address = validate_hex_int(address) block = validate_block_param(block) return self._fetch("eth_getTransactionCount", [address, block], parse_int)