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

Unified network settings and removal of config file #408

Merged
merged 18 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
93bb827
add default-config.yaml and network-config.yaml
iamdefinitelyahuman Apr 8, 2020
de3659b
deprecate networks in brownie-config, add network-config
iamdefinitelyahuman Apr 8, 2020
d52b325
merge ARGV into CONFIG, refactor _config methods
iamdefinitelyahuman Apr 9, 2020
4895acd
refactor: update brownie/network references to ARGV and CONFIG
iamdefinitelyahuman Apr 9, 2020
2a16d54
refactor: update brownie/_cli references to CONFIG, ARGV
iamdefinitelyahuman Apr 9, 2020
451d16b
refactor: update brownie/test references to ARGV, CONFIG
iamdefinitelyahuman Apr 9, 2020
0c27236
refactor: update project and utils references to ARGV, CONFIG
iamdefinitelyahuman Apr 9, 2020
bcdc27f
refactor: update tests based on ARGV, CONFIG
iamdefinitelyahuman Apr 9, 2020
6c66234
feat: show_colors config setting
iamdefinitelyahuman Apr 9, 2020
8ab1b66
feat: do not require config file in projects
iamdefinitelyahuman Apr 9, 2020
93a7dbe
test: update conftest to not use brownie-config
iamdefinitelyahuman Apr 9, 2020
a138bc3
docs: update documentation re: config file
iamdefinitelyahuman Apr 9, 2020
4de121b
add chainid field to networks, load networks file from data folder
iamdefinitelyahuman Apr 11, 2020
aa7011f
save deployments according to chainid
iamdefinitelyahuman Apr 11, 2020
0abe8bb
style: rename 'production' to 'live' in networks
iamdefinitelyahuman Apr 13, 2020
c5ed7f2
cli: add brownie networks cli tool
iamdefinitelyahuman Apr 10, 2020
163c3af
test: add test cases for brownie networks cli
iamdefinitelyahuman Apr 13, 2020
65c0af8
doc: update documentation re: networks cli
iamdefinitelyahuman Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion brownie/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/python3

from brownie._config import CONFIG as config
from brownie._config import CONFIG as _CONFIG
from brownie.convert import Fixed, Wei
from brownie.project import compile_source, run
from brownie.network import accounts, alert, history, rpc, web3
from brownie.network.contract import Contract # NOQA: F401

config = _CONFIG.settings

__all__ = [
"accounts", # accounts is an Accounts singleton
"alert",
Expand Down
5 changes: 3 additions & 2 deletions brownie/_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path

from brownie import network
from brownie._config import ARGV
from brownie._config import CONFIG
from brownie.exceptions import ProjectNotFound
from brownie.utils import color, notify
from brownie.utils.docopt import docopt, levenshtein_norm
Expand All @@ -23,6 +23,7 @@
test Run test cases in the tests/ folder
run Run a script in the scripts/ folder
accounts Manage local accounts
networks Manage network settings
gui Load the GUI to view opcodes and test coverage
analyze Find security vulnerabilities using the MythX API

Expand All @@ -49,7 +50,7 @@ def main():
sys.exit(f"Invalid command. Did you mean 'brownie {distances[0][0]}'?")
sys.exit("Invalid command. Try 'brownie --help' for available commands.")

ARGV["cli"] = cmd
CONFIG.argv["cli"] = cmd
sys.modules["brownie"].a = network.accounts
sys.modules["brownie"].__all__.append("a")

Expand Down
16 changes: 8 additions & 8 deletions brownie/_cli/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from brownie import project
from brownie._cli.__main__ import __version__
from brownie._config import ARGV, _update_argv_from_docopt
from brownie._config import CONFIG, _update_argv_from_docopt
from brownie.exceptions import ProjectNotFound
from brownie.utils import color, notify
from brownie.utils.docopt import docopt
Expand Down Expand Up @@ -73,8 +73,8 @@ def get_mythx_client() -> Client:
:return: A PythX client instance
"""

if ARGV["api-key"]:
auth_args = {"api_key": ARGV["api-key"]}
if CONFIG.argv["api-key"]:
auth_args = {"api_key": CONFIG.argv["api-key"]}
elif environ.get("MYTHX_API_KEY"):
auth_args = {"api_key": environ.get("MYTHX_API_KEY")}
else:
Expand Down Expand Up @@ -156,7 +156,7 @@ def construct_request_from_artifact(cls, artifact) -> AnalysisSubmissionRequest:
source_list=source_list or None,
main_source=artifact.get("sourcePath"),
solc_version=artifact.get("compiler", {}).get("version"),
analysis_mode=ARGV["mode"] or ANALYSIS_MODES[0],
analysis_mode=CONFIG.argv["mode"] or ANALYSIS_MODES[0],
)

def send_requests(self) -> None:
Expand Down Expand Up @@ -202,7 +202,7 @@ def wait_for_jobs(self) -> None:
raise ValidationError("No requests given")
for contract_name, response in self.responses.items():
while not self.client.analysis_ready(response.uuid):
time.sleep(int(ARGV["interval"]))
time.sleep(int(CONFIG.argv["interval"]))
self.reports[contract_name] = self.client.report(response.uuid)

def generate_highlighting_report(self) -> None:
Expand Down Expand Up @@ -308,7 +308,7 @@ def main():
args = docopt(__doc__)
_update_argv_from_docopt(args)

if ARGV["mode"] not in ANALYSIS_MODES:
if CONFIG.argv["mode"] not in ANALYSIS_MODES:
raise ValidationError(
"Invalid analysis mode: Must be one of [{}]".format(", ".join(ANALYSIS_MODES))
)
Expand All @@ -327,7 +327,7 @@ def main():
submission.send_requests()

# exit if user wants an async analysis run
if ARGV["async"]:
if CONFIG.argv["async"]:
print(
"\nAll contracts were submitted successfully. Check the dashboard at "
"https://dashboard.mythx.io/ for the progress and results of your analyses"
Expand All @@ -352,7 +352,7 @@ def main():
json.dump(submission.highlight_report, fp, indent=2, sort_keys=True)

# Launch GUI if user requested it
if ARGV["gui"]:
if CONFIG.argv["gui"]:
print("Launching the Brownie GUI")
gui = importlib.import_module("brownie._gui").Gui
gui().mainloop()
6 changes: 3 additions & 3 deletions brownie/_cli/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import brownie
from brownie import network, project
from brownie._config import ARGV, CONFIG, _get_data_folder, _update_argv_from_docopt
from brownie._config import CONFIG, _get_data_folder, _update_argv_from_docopt
from brownie.utils import color
from brownie.utils.docopt import docopt

Expand All @@ -21,7 +21,7 @@
__doc__ = f"""Usage: brownie console [options]

Options:
--network <name> Use a specific network (default {CONFIG['network']['default']})
--network <name> Use a specific network (default {CONFIG.settings['networks']['default']})
--tb -t Show entire python traceback on exceptions
--help -h Display this message

Expand All @@ -41,7 +41,7 @@ def main():
active_project = None
print("No project was loaded.")

network.connect(ARGV["network"])
network.connect(CONFIG.argv["network"])

shell = Console(active_project)
shell.interact(banner="Brownie environment is ready.", exitmsg="")
Expand Down
Loading