eth-brownie / brownie

A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
https://eth-brownie.readthedocs.io
MIT License
2.63k stars 550 forks source link

Hide RPC_URLs URL when running scripts #1130

Open PatrickAlphaC opened 3 years ago

PatrickAlphaC commented 3 years ago

Overview

When running a script, I often have URLs with restricted APIs associated with them, and I'd like them to be hidden from the shell when running them.

IE:

patrick@iMac: [~/code/defi_py_mix -  (main)] $ brownie run scripts/swap/short_sell.py --network mainnet-fork
Brownie v1.14.6 - Python development framework for Ethereum

DefiPyMixProject is the active project.

Launching 'ganache-cli --accounts 10 --fork RPC_URL_WITH_EXPOSED_API_KEY --mnemonic brownie --port 8545 --hardfork istanbul'...

Running 'scripts/swap/short_sell.py::main'...
Transaction sent: 0x77d4b094d1e83c7afbaeebead6503ecf5c0ce19daa75a83ae0f57e95e314bfc1
  Gas price: 0.0 gwei   Gas limit: 6721975   Nonce: 1
  Transaction confirmed - Block: 12724651   Gas used: 43738 (0.65%)

Wondering if there is a way to run it like:

patrick@iMac: [~/code/defi_py_mix -  (main)] $ brownie run scripts/swap/short_sell.py --network mainnet-fork
Brownie v1.14.6 - Python development framework for Ethereum

DefiPyMixProject is the active project.

Launching 'ganache-cli --accounts 10 --fork https://.... --mnemonic brownie --port 8545 --hardfork istanbul'...

Running 'scripts/swap/short_sell.py::main'...
Transaction sent: 0x77d4b094d1e83c7afbaeebead6503ecf5c0ce19daa75a83ae0f57e95e314bfc1
  Gas price: 0.0 gwei   Gas limit: 6721975   Nonce: 1
  Transaction confirmed - Block: 12724651   Gas used: 43738 (0.65%)

And then maybe add a "verbose" flag to the API when I want to see everything in the shell

iamdefinitelyahuman commented 3 years ago

Good idea - this shouldn't be too hard to implement, we can just filter out the same values we're injecting via environment variables

Scowley4 commented 2 years ago

Not a permanent solution, but if you want to turn it off in your local version, you could mess with (edit or remove) this line:

https://github.com/eth-brownie/brownie/blob/ce8e5bd02397e76848b447ed922bbcab8c283b9d/brownie/network/rpc/ganache.py#L70

Probably easier than editing it out of a video/image.