Skip to main content
Glama
bytecode_analyzer.cpython-311.pyc2.51 kB
� �2�g���H�ddlmZmZmZddlmZddlZGd�d��ZdS)�)�Dict�List�Optional)�Web3Nc�N�eZdZdefd�Zdefd�Zdedeefd�Zdefd�Z dS)�BytecodeAnalyzer�bytecodec�:�||_t��|_dS)z3Initialize the bytecode analyzer with raw bytecode.N)r r�w3)�selfr s �=/Users/arjun/repos/sparkmango/mpc_server/bytecode_analyzer.py�__init__zBytecodeAnalyzer.__init__s�� �� ��&�&������returnc��|j�d��r|jdd�n|j}dggt|��|�|��d�}|S)z<Analyze the bytecode and return a structured representation.�0x�N�Unknown)� contract_name�methods�storage_variables�bytecode_length�opcodes)r � startswith�len� _get_opcodes)r r �analysiss r �analyzezBytecodeAnalyzer.analyze sh��)-� �(@�(@��(F�(F�Y�4�=����$�$�D�M��'��!#�"�8�}�}��(�(��2�2�  � ���rc��g}d}|t|��kro|||dz�}|sn_|j�t�|����}|�|��|dz }|t|��k�o|S)zConvert bytecode to opcodes.rr)rr �to_hex�bytes�fromhex�append)r r r�i�byte�opcodes r rzBytecodeAnalyzer._get_opcodes!s����� ���#�h�-�-����A�a��c�E�?�D�� ���W�^�^�E�M�M�$�$7�$7�8�8�F� �N�N�6� "� "� "� ��F�A��#�h�-�-����rc��g|jd�S)z0Generate a basic ABI from the bytecode analysis.)�abir )r )r s r � generate_abizBytecodeAnalyzer.generate_abi4s���� � � � rN) �__name__� __module__� __qualname__�strrrrrrr)�rr rrs������������� ������,�S��T�#�Y�����& �d� � � � � � rr)�typingrrr�web3r�jsonrr.rr �<module>r2sp��'�'�'�'�'�'�'�'�'�'������� � � � �5 �5 �5 �5 �5 �5 �5 �5 �5 �5 r

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ArjunBhuptani/sparkmango'

If you have feedback or need assistance with the MCP directory API, please join our Discord server