ApeWorX / ape-foundry

Foundry network provider for the Ape Framework
https://www.apeworx.io/
Apache License 2.0
33 stars 13 forks source link

feat: add get_auto_mine function [APE-998] #51

Closed wakamex closed 1 year ago

wakamex commented 1 year ago

What I did

add anvil's get_autoMine call so you can tell what kind of behavior your anvil done is up to. reference: https://book.getfoundry.sh/reference/anvil/

How I did it

added this code:

    def get_auto_mine(self) -> bool:
        return self._make_request("anvil_getAutoMine", [])

How to verify it

install the plugin, connect to an anvil node, and run provider.get_auto_mine().

using anvil default:

print(f"{provider.get_auto_mine()=}")
provider.get_auto_mine()=True

with anvil --block-time 1 that mines a new block every 1 second... automatically?

print(f"{provider.get_auto_mine()=}")
provider.get_auto_mine()=False

Checklist

wakamex commented 1 year ago

I can add a test if y'all want, here's how I'm currently using it:

automine = provider._make_request("anvil_getAutomine", parameters={})
if bot_config.devnet and automine:  # anvil automatically mines after you send a transaction. or manually.
    ape.chain.mine()