From 1f3edbf676c295d8df76758352ab2abeac559b0a Mon Sep 17 00:00:00 2001 From: harisang Date: Mon, 23 Oct 2023 13:03:08 +0300 Subject: [PATCH 1/3] get block number from tx hash --- src/apis/web3api.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/apis/web3api.py b/src/apis/web3api.py index e45e627..7bf5a15 100644 --- a/src/apis/web3api.py +++ b/src/apis/web3api.py @@ -85,7 +85,17 @@ def get_transaction(self, tx_hash: str) -> Optional[TxData]: transaction = None return transaction - + + def get_tx_block_number(self, tx_hash: str) -> Optional[int]: + """ + Takes tx hash as input, returns block number where tx took place. + """ + transaction = self.get_transaction(tx_hash) + if transaction is None: + return None + else: + return transaction['blockNumber'] + def get_receipt(self, tx_hash: str) -> Optional[TxReceipt]: """ Get the receipt of a transaction from the transaction hash. From 563458d9c67baece630269eef14d676ffb4a0b7b Mon Sep 17 00:00:00 2001 From: harisang Date: Mon, 23 Oct 2023 13:06:24 +0300 Subject: [PATCH 2/3] remove whitespaces --- src/apis/web3api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/apis/web3api.py b/src/apis/web3api.py index 7bf5a15..ffdc9a2 100644 --- a/src/apis/web3api.py +++ b/src/apis/web3api.py @@ -85,7 +85,7 @@ def get_transaction(self, tx_hash: str) -> Optional[TxData]: transaction = None return transaction - + def get_tx_block_number(self, tx_hash: str) -> Optional[int]: """ Takes tx hash as input, returns block number where tx took place. @@ -94,8 +94,8 @@ def get_tx_block_number(self, tx_hash: str) -> Optional[int]: if transaction is None: return None else: - return transaction['blockNumber'] - + return transaction["blockNumber"] + def get_receipt(self, tx_hash: str) -> Optional[TxReceipt]: """ Get the receipt of a transaction from the transaction hash. From e57d92766998136db0756c6821d43da74efad56c Mon Sep 17 00:00:00 2001 From: harisang Date: Mon, 23 Oct 2023 13:08:20 +0300 Subject: [PATCH 3/3] fix pylint error --- src/apis/web3api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/apis/web3api.py b/src/apis/web3api.py index ffdc9a2..edcc5dc 100644 --- a/src/apis/web3api.py +++ b/src/apis/web3api.py @@ -93,8 +93,7 @@ def get_tx_block_number(self, tx_hash: str) -> Optional[int]: transaction = self.get_transaction(tx_hash) if transaction is None: return None - else: - return transaction["blockNumber"] + return transaction["blockNumber"] def get_receipt(self, tx_hash: str) -> Optional[TxReceipt]: """