ApeWorX / ape-vyper

Vyper compiler plugin for the Ape Framework, using VVM
https://www.apeworx.io/
Apache License 2.0
24 stars 9 forks source link

feat: contract flattener #107

Closed mikeshultz closed 3 months ago

mikeshultz commented 3 months ago

What I did

Adds Vyper contract flattener functionality.

fixes: #75

How I did it

How to verify it

Checklist

mikeshultz commented 3 months ago

Depends on release after https://github.com/ApeWorX/ape/pull/1963

mikeshultz commented 3 months ago

I think the biggest thing I would prefer is to get rid of the OUTFILE requirement. Writing "out" should be done using the >> operator.

ape vyper flatten path.vy >> out.vy

This is how I originally wanted to do it but the ape logger ruins stdout. The click command can't get in and adjust log level before ape starts outputting stuff we don't want. Open to ideas.

antazoey commented 3 months ago

Open to ideas.

one idea, let it default to stdout still so it isn't required. my other idea: update ape_cli_context or something that allows us to completely disable the logger.

question, what are some of the earliest logs you were seeing?

mikeshultz commented 3 months ago

Open to ideas.

one idea, let it default to stdout still so it isn't required. my other idea: update ape_cli_context or something that allows us to completely disable the logger.

Maybe, but defaulting to stdout seems like it'll be very annoying to users when the output isn't a compilable contract.

I'm not sure adjusting that decorator will do much when most of the output I've been seeing has come during plugin/config loading .

question, what are some of the earliest logs you were seeing?

Couple examples. In a dev env:

WARNING: Found 2 packages named 'eth-ape'.
Installation paths:
    /home/mike/.venvs/ape-dev/lib/python3.11/site-packages/eth_ape-0.6.20.dev208+gbe26439c.d20240319.dist-info,
    /home/mike/dev/ape/src/eth_ape.egg-info

In a clean project env:

WARNING (ape-vyper): Unprocessed plugin config(s): solidity, hardhat. Plugins may not be installed yet or keys may be mis-spelled.

Think I've seen some others as well but this is what I was able to get on first tries. We could suss out every warning or log output I can generate and suppress it but it doesn't really fix the fact that this is a common behavior of the ape logger. Unless we can somehow completely shut down logging at logger init time, I'm not sure we can reliably prevent stdout from being ruined.