async def get_latest_update_block_number(self, network: str, tokenId: int) -> List[int]: contract = self.get_contract(network=network) if not contract.updateMethodSignature: return [] events = await contract.ethClient.get_log_entries( address=contract.address, startBlockNumber=contract.startBlockNumber, topics=[ Web3.keccak(text=contract.updateMethodSignature).hex(), int_to_hex(tokenId) ]) return next((event['blockNumber'] for event in reversed(events)), None)
async def get_transferred_token_ids_in_blocks( self, network: str, startBlockNumber: int, endBlockNumber: int) -> List[int]: contract = self.get_contract(network=network) events = await contract.ethClient.get_log_entries( address=contract.address, startBlockNumber=startBlockNumber, endBlockNumber=endBlockNumber, topics=[Web3.keccak(text=contract.transferMethodSignature).hex()]) return [ int.from_bytes(bytes(event['topics'][3]), 'big') for event in events ]
def new_certificate(diag_id: str, certificate: str) -> HexBytes: db = get_db() # Calculate the hash hash = Web3.keccak(text=certificate) db.execute( 'REPLACE INTO certificate (diag_id, hash, cert) VALUES (?, ?, ?)', (diag_id, hash.hex(), certificate) ) # Commit database, just in case db.commit() # Return certificate hash to caller return hash