Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web3.py V6 upgrade #96

Merged
merged 10 commits into from
Jul 31, 2024
Merged

Web3.py V6 upgrade #96

merged 10 commits into from
Jul 31, 2024

Conversation

odysseus0
Copy link
Collaborator

Add support for Web3.py v6 and enhance Flashbots module

This pull request introduces support for Web3.py v6 and includes several improvements to the Flashbots module, enhancing type safety and refactoring code for better maintainability.

Key Changes

  1. Web3.py v6 Support

    • Updated code to be compatible with Web3.py v6
    • Adjusted type hints and function signatures to align with Web3.py v6 changes
    • Updated dependencies to include Web3.py v6
  2. Network Handling Refactor

    • Converted Network type to Enum for improved type safety
    • Updated FLASHBOTS_NETWORKS to use Network enum as keys
    • Added EnumAction class for argparse to handle Network enum
  3. Improved Transaction Handling

    • Updated create_transaction function for dynamic gas price calculation
    • Enhanced flashbot() function with better documentation
  4. Type Safety Enhancements

    • Introduced FlashbotsWeb3 class for better type checking
    • Updated type hints throughout the code to align with Web3.py v6
  5. Code Quality Improvements

    • Switched from Black to Ruff for code formatting and linting
    • Reordered and optimized imports across multiple files
  6. Enhanced Logging

    • Added logging to Flashbots class for key operations
    • Implemented dynamic logging configuration in simple.py example

Additional Notes

  • The simple.py example has been updated with command-line arguments for network selection and log level
  • Error handling for environment variables in examples has been improved
  • Minor code style improvements and formatting adjustments have been made throughout the project

These changes primarily focus on ensuring compatibility with Web3.py v6 while also enhancing the overall quality, maintainability, and usability of the Flashbots module.

- Add logger to Flashbots class
- Include log messages for key operations:
  - Sending bundle
  - Simulating bundle
  - Sending private transaction
  - Cancelling private transaction
- Use proper logging instead of print in example.py
- Streamline header combination in make_request method
- Update docstring to accurately reflect provider's purpose
- Improve overall code readability
- Remove Black configuration and dependencies
- Add Ruff configuration and dependencies
- Update VSCode settings for Python to use Ruff
- Add pre-commit config for Ruff
- Replace GitHub Actions workflow for Black with Ruff
- Update pyproject.toml to configure Ruff
- Reorder and optimize imports across multiple files
- Remove unused imports
- Standardize import order and grouping
- Minor code formatting adjustments
- Remove trailing whitespace

This commit improves code consistency and readability by applying
ruff's linting and formatting rules to the project.
- Introduce FlashbotsWeb3 class to enhance type checking
- Remove Goerli-specific PoA middleware injection
- Update flashbot function to return FlashbotsWeb3 instance
- Improve error handling for environment variables in examples
- Enhance address handling with Web3.to_checksum_address
- Update transaction nonce type to use web3.types.Nonce
- Minor code style improvements and type annotations
- Add flashbots/constants.py with FLASHBOTS_NETWORKS
- Update flashbots/types.py to include new network types
- Modify setup_web3 function to use the new network configuration
- Remove NETWORK_CONFIG and related functions from examples/simple.py
- Update create_transaction function to dynamically calculate gas prices
- Modify transaction creation in main function
- Add command-line arguments for network selection and log level
- Implement dynamic logging configuration
- Update docstrings with usage instructions and examples
- Refactor network type to 'Network' for consistency
- Add get_networks() function to retrieve available networks
- Improve flashbot() function documentation
- Minor code cleanup and formatting improvements
- Convert Network type to Enum for better type safety
- Update FLASHBOTS_NETWORKS to use Network enum as keys
- Remove get_networks() function, use Network enum values directly
- Add EnumAction class for argparse to handle Network enum
- Update parse_arguments() and related functions to use Network enum
- Adjust type hints throughout the code to reflect these changes
@odysseus0 odysseus0 changed the title Release/2.0.0 Release/2.1 Jul 31, 2024
@odysseus0 odysseus0 changed the title Release/2.1 Web3.py V6 upgrade Jul 31, 2024
Copy link
Member

@zeroXbrock zeroXbrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super clean, thx @odysseus0!

@zeroXbrock zeroXbrock merged commit 7892c87 into master Jul 31, 2024
2 checks passed
@zeroXbrock zeroXbrock deleted the dev-main branch July 31, 2024 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants