Create processor class, fix signature matching in utils
This commit is contained in:
parent
20bab3c448
commit
98cb1ffcae
15
processor.py
15
processor.py
@ -1,6 +1,13 @@
|
|||||||
|
|
||||||
|
class Processor:
|
||||||
|
def __init__(self, base_provider, inspectors) -> None:
|
||||||
|
self.base_provider = base_provider
|
||||||
|
self.inspectors = inspectors
|
||||||
|
|
||||||
def get_transaction_evaluations(block_data):
|
def get_transaction_evaluations(self, block_data):
|
||||||
for transaction_hash in block_data.transaction_hashes:
|
for transaction_hash in block_data.transaction_hashes:
|
||||||
calls = block_data.get_filtered_calls(transaction_hash)
|
calls = block_data.get_filtered_calls(transaction_hash)
|
||||||
print(calls)
|
|
||||||
|
for inspector in self.inspectors:
|
||||||
|
inspector.inspect(calls)
|
||||||
|
# print(calls)
|
@ -1,3 +1,4 @@
|
|||||||
|
from processor import Processor
|
||||||
from web3.providers import base
|
from web3.providers import base
|
||||||
from inspector_uniswap import UniswapInspector
|
from inspector_uniswap import UniswapInspector
|
||||||
import block
|
import block
|
||||||
@ -17,4 +18,9 @@ base_provider = Web3.HTTPProvider(args.rpc)
|
|||||||
block_data = block.createFromBlockNumber(args.block_number[0], base_provider)
|
block_data = block.createFromBlockNumber(args.block_number[0], base_provider)
|
||||||
|
|
||||||
## Build a Uniswap inspector
|
## Build a Uniswap inspector
|
||||||
uniswap_inspector = UniswapInspector(base_provider)
|
uniswap_inspector = UniswapInspector(base_provider)
|
||||||
|
|
||||||
|
## Create a processor, pass in an ARRAY of inspects
|
||||||
|
processor = Processor(base_provider, [uniswap_inspector, uniswap_inspector])
|
||||||
|
|
||||||
|
processor.get_transaction_evaluations(block_data)
|
11
utils.py
11
utils.py
@ -1,6 +1,7 @@
|
|||||||
|
from hexbytes.main import HexBytes
|
||||||
|
|
||||||
def check_call_for_signature(call, signatures):
|
def check_call_for_signature(call, signatures):
|
||||||
if (call.action.input == None):
|
if (call['action']['input'] == None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
## By default set this to False
|
## By default set this to False
|
||||||
@ -8,7 +9,13 @@ def check_call_for_signature(call, signatures):
|
|||||||
|
|
||||||
## Iterate over all signatures, and if our call matches any of them set it to True
|
## Iterate over all signatures, and if our call matches any of them set it to True
|
||||||
for signature in signatures:
|
for signature in signatures:
|
||||||
if call.action.input.startsWith(signature):
|
# print("Desired signature:", str(signature))
|
||||||
|
# print("Actual", HexBytes(call['action']['input']))
|
||||||
|
|
||||||
|
if HexBytes(call['action']['input']).startswith((signature)):
|
||||||
|
## Note that we are turning the input into hex bytes here, which seems to be fine
|
||||||
|
## Working with strings was doing weird things
|
||||||
|
print("hit")
|
||||||
signature_present_boolean = True
|
signature_present_boolean = True
|
||||||
|
|
||||||
return signature_present_boolean
|
return signature_present_boolean
|
Loading…
x
Reference in New Issue
Block a user