mirror of
https://github.com/blockchain-etl/ethereum-etl.git
synced 2026-01-09 05:48:10 -05:00
Half fix 194 token not detected
This commit is contained in:
@@ -32,9 +32,9 @@ class EthContractService:
|
||||
evm_code = EvmCode(contract=Contract(bytecode=bytecode), static_analysis=False, dynamic_analysis=False)
|
||||
evm_code.disassemble(bytecode)
|
||||
basic_blocks = evm_code.basicblocks
|
||||
if basic_blocks and len(basic_blocks) > 0:
|
||||
init_block = basic_blocks[0]
|
||||
instructions = init_block.instructions
|
||||
init_blocks = find_init_blocks(basic_blocks)
|
||||
if init_blocks and len(init_blocks) > 0:
|
||||
instructions = [instruction for init_block in init_blocks for instruction in init_block.instructions]
|
||||
push4_instructions = [inst for inst in instructions if inst.name == 'PUSH4']
|
||||
return sorted(list(set('0x' + inst.operand for inst in push4_instructions)))
|
||||
else:
|
||||
@@ -79,6 +79,18 @@ def clean_bytecode(bytecode):
|
||||
return bytecode
|
||||
|
||||
|
||||
def find_init_blocks(basic_blocks):
|
||||
init_blocks = []
|
||||
if basic_blocks and len(basic_blocks) > 0:
|
||||
for basic_block in basic_blocks:
|
||||
instructions = basic_block.instructions
|
||||
has_calldataload = any(instruction.name == 'CALLDATALOAD' for instruction in instructions)
|
||||
if has_calldataload:
|
||||
init_blocks.append(basic_block)
|
||||
|
||||
return init_blocks
|
||||
|
||||
|
||||
def get_function_sighash(signature):
|
||||
return '0x' + function_signature_to_4byte_selector(signature).hex()
|
||||
|
||||
|
||||
@@ -58,7 +58,11 @@ from ethereumetl.service.eth_contract_service import EthContractService
|
||||
'0x2f745c59', '0x34c05ca8', '0x392e53cd', '0x3f4ba83a', '0x42842e0e', '0x46904840', '0x4f558e79', '0x4f6ccce7',
|
||||
'0x509484d5', '0x5c975abb', '0x6352211e', '0x70a08231', '0x7bdc60d9', '0x7bf9a7c4', '0x8456cb59', '0x8da5cb5b',
|
||||
'0x8ed3fa7c', '0x90e7a074', '0x95d89b41', '0x99e0dd7c', '0xa22cb465', '0xacb2ad6f', '0xb88d4fde', '0xc0ac9983',
|
||||
'0xc87b56dd', '0xc9a6964a', '0xdce0b4e4', '0xe985e9c5', '0xee5301d5', '0xf2fde38b', '0xffffffff'], False, True)
|
||||
'0xc87b56dd', '0xc9a6964a', '0xdce0b4e4', '0xe985e9c5', '0xee5301d5', '0xf2fde38b', '0xffffffff'], False, True),
|
||||
(
|
||||
'0x608060405234801561001057600080fd5b50600436106101425760003560e01c80637ecebe00116100b8578063a9059cbb1161007c578063a9059cbb146106b4578063b753a98c1461071a578063bb35783b14610768578063bf353dbb146107d6578063dd62ed3e1461082e578063f2d5d56b146108a657610142565b80637ecebe00146104a15780638fcbaf0c146104f957806395d89b411461059f5780639c52a7f1146106225780639dc29fac1461066657610142565b8063313ce5671161010a578063313ce567146102f25780633644e5151461031657806340c10f191461033457806354fd4d501461038257806365fae35e1461040557806370a082311461044957610142565b806306fdde0314610147578063095ea7b3146101ca57806318160ddd1461023057806323b872dd1461024e57806330adf81f146102d4575b600080fd5b61014f6108f4565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561018f578082015181840152602081019050610174565b50505050905090810190601f1680156101bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610216600480360360408110156101e057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060',
|
||||
['0x7ecebe00', '0xa9059cbb', '0xb753a98c', '0xbb35783b', '0xbf353dbb', '0xdd62ed3e', '0xf2d5d56b'], True, False)
|
||||
|
||||
])
|
||||
def test_get_function_sighashes(bytecode, expected_sighashes, is_erc20, is_erc721):
|
||||
eth_contract_service = EthContractService()
|
||||
|
||||
Reference in New Issue
Block a user