Skip to content

Commit

Permalink
Merge branch 'main' into refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhagarwal03 authored Aug 27, 2024
2 parents 3f87517 + bc574c3 commit 28d58cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"0x83F20F44975D03b1b09e64809B757c47f942BEeA"
)

INVALIDATED_ORDER_TOPIC = (
"0x875b6cb035bbd4ac6500fabc6d1e4ca5bdc58a3e2b424ccb5c24cdbebeb009a9"
)

REQUEST_TIMEOUT = 5

# Time limit, currently set to 1 full day, after which Coingecko Token List is re-fetched (in seconds)
Expand Down
14 changes: 11 additions & 3 deletions src/helpers/blockchain_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from hexbytes import HexBytes
from web3 import Web3
from src.helpers.config import logger
from src.constants import SETTLEMENT_CONTRACT_ADDRESS
from src.constants import SETTLEMENT_CONTRACT_ADDRESS, INVALIDATED_ORDER_TOPIC


class BlockchainData:
Expand Down Expand Up @@ -41,12 +41,20 @@ def get_tx_hashes_blocks(
involving the settlement contract.
"""
tx_hashes_blocks = []

for block_number in range(start_block, end_block + 1):
block = self.web3.eth.get_block(block_number, full_transactions=True)
for tx in block.transactions: # type: ignore[attr-defined]
if tx.to and tx.to.lower() == SETTLEMENT_CONTRACT_ADDRESS.lower():
tx_hashes_blocks.append((tx.hash.to_0x_hex(), block_number))
receipt = self.web3.eth.get_transaction_receipt(tx.hash)
# ignore txs that trigger the OrderInvalidated event
if any(
log.topics[0].to_0x_hex() == INVALIDATED_ORDER_TOPIC
for log in receipt.logs # type: ignore[attr-defined]
):
continue
# status = 0 indicates a reverted tx, status = 1 is successful tx
if receipt.status == 1: # type: ignore[attr-defined]
tx_hashes_blocks.append((tx.hash.to_0x_hex(), block_number))
return tx_hashes_blocks

def get_auction_id(self, tx_hash: str) -> int:
Expand Down

0 comments on commit 28d58cd

Please sign in to comment.