mirror of
https://github.com/autistic-symposium/blockchain-data-engineering-toolkit.git
synced 2025-04-26 10:49:23 -04:00
fix api url
This commit is contained in:
parent
468b86b2c9
commit
5a8dc6cc5f
@ -80,15 +80,6 @@ class TokenIndexer:
|
|||||||
# Private methods: logic #
|
# Private methods: logic #
|
||||||
###########################################
|
###########################################
|
||||||
|
|
||||||
def _get_block_timestamp(self, block_number) -> int:
|
|
||||||
"""Get the timestamp of a given block."""
|
|
||||||
|
|
||||||
try:
|
|
||||||
block_timestamp = self.web3.eth.getBlock(block_number)['timestamp']
|
|
||||||
return datetime.datetime.utcfromtimestamp(block_timestamp)
|
|
||||||
except (BlockNotFound, ValueError):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _get_logs(self, from_block: int, to_block: int) -> list:
|
def _get_logs(self, from_block: int, to_block: int) -> list:
|
||||||
"""Get logs from a given address between two blocks,"""
|
"""Get logs from a given address between two blocks,"""
|
||||||
|
|
||||||
@ -127,7 +118,6 @@ class TokenIndexer:
|
|||||||
processed_logs[log['transactionHash']]['from'] = '0x' + log['topics'][1][26:]
|
processed_logs[log['transactionHash']]['from'] = '0x' + log['topics'][1][26:]
|
||||||
processed_logs[log['transactionHash']]['to'] = '0x' + log['topics'][2][26:]
|
processed_logs[log['transactionHash']]['to'] = '0x' + log['topics'][2][26:]
|
||||||
processed_logs[log['transactionHash']]['amount'] = float(Decimal(convert_hex_to_int(log['data'])) * self.decimal)
|
processed_logs[log['transactionHash']]['amount'] = float(Decimal(convert_hex_to_int(log['data'])) * self.decimal)
|
||||||
processed_logs[log['transactionHash']]['timestamp'] = self._get_block_timestamp(convert_hex_to_int(log['blockNumber']))
|
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
print(f'Error processing logs: {e}')
|
print(f'Error processing logs: {e}')
|
||||||
|
|
||||||
@ -138,6 +128,15 @@ class TokenIndexer:
|
|||||||
# Public methods #
|
# Public methods #
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
|
def get_block_timestamp(self, block_number) -> int:
|
||||||
|
"""Get the timestamp of a given block."""
|
||||||
|
|
||||||
|
try:
|
||||||
|
block_timestamp = self.web3.eth.getBlock(block_number)['timestamp']
|
||||||
|
return datetime.datetime.utcfromtimestamp(block_timestamp)
|
||||||
|
except (BlockNotFound, ValueError):
|
||||||
|
return None
|
||||||
|
|
||||||
def get_transfer_logs_chunks(self, from_block=None, to_block=None) -> list:
|
def get_transfer_logs_chunks(self, from_block=None, to_block=None) -> list:
|
||||||
"""Get transfer logs from a given address between two blocks by small chunks"""
|
"""Get transfer logs from a given address between two blocks by small chunks"""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user