Skip to content

Commit

Permalink
Merge pull request #167 from iamdefinitelyahuman/v1.0.0b11
Browse files Browse the repository at this point in the history
V1.0.0b11
  • Loading branch information
iamdefinitelyahuman authored Aug 17, 2019
2 parents eccd0c6 + e6f21f5 commit 21611a0
Show file tree
Hide file tree
Showing 109 changed files with 4,187 additions and 2,932 deletions.
69 changes: 52 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,54 @@
language: python
dist: xenial
sudo: true
install:
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo add-apt-repository -y ppa:deadsnakes/ppa
- sudo apt-get update
- sudo apt-get install -y python$TRAVIS_PYTHON_VERSION-dev python$TRAVIS_PYTHON_VERSION-tk npm solc
- npm -g install ganache-cli
- pip install -r requirements-dev.txt
- pip install tox-travis coveralls
# Based on https://github.com/cclauss/Travis-CI-Python-on-three-OSes
matrix:
include:
- name: '3.6'
python: 3.6
- name: '3.7'
python: 3.7
script: tox
after_success: if [ "${TRAVIS_PYTHON_VERSION}" == "3.7" ]; then coveralls; fi;
- name: "Python 3.7.1 on Xenial Linux"
language: python
python: 3.7
dist: xenial
sudo: true
install:
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo add-apt-repository -y ppa:deadsnakes/ppa
- sudo apt-get update
- sudo apt-get install -y python3.7-dev python3.7-tk npm solc
- npm -g install ganache-cli
- python -m pip install -r requirements-dev.txt
- pip install tox tox-travis
script:
- tox
after_success:
- python -m coveralls
- name: "Python 3.6.8 on Xenial Linux"
language: python
python: 3.6
dist: xenial
sudo: true
install:
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo add-apt-repository -y ppa:deadsnakes/ppa
- sudo apt-get update
- sudo apt-get install -y python3.6-dev python3.6-tk npm solc
- npm -g install ganache-cli
- python -m pip install -r requirements-dev.txt
- pip install tox tox-travis sphinx flake8
script: tox
- name: "Python 3.7.3 on Windows"
os: windows
language: node_js
node_js: '10'
install:
- npm -g install ganache-cli
- choco install python
- python -m pip install --upgrade pip
- python -m pip install -r requirements-dev.txt
- python setup.py install
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
script: python -m pytest tests/ --cov=brownie/ -p no:pytest-brownie
after_success: python -m coveralls

env:
global: COVERALLS_PARALLEL=true

notifications:
email: false
webhooks: https://coveralls.io/webhook
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
1.0.0b11
--------

- Require web3.py version 5, updates based on breaking changes
- Add support for ABIEncoderV2
- Add Project class, allow opening multiple projects at the same time
- Determine solc version using pragma, allow multiple versions in one project
- Set EVM version in config file
- Allow config file comments, change structure
- Add PublicKeyAccount and Contract (via ABI), allow tracebacks on unknown contracts
- Expanded Alert functionality
- Windows bugfixes

1.0.0b10
--------

Expand Down
3 changes: 1 addition & 2 deletions brownie/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from .project import (
compile_source,
run,
__brownie_import_all__
)
from brownie.network.contract import Contract # NOQA: F401
from brownie.gui import Gui
from brownie._config import CONFIG as config
from brownie.convert import Wei
Expand All @@ -24,7 +24,6 @@
'rpc',
'web3',
'project',
'__brownie_import_all__',
'compile_source',
'run',
'Wei',
Expand Down
67 changes: 39 additions & 28 deletions brownie/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from collections import defaultdict
import json
from pathlib import Path
import shutil
import re

from brownie._singleton import _Singleton


REPLACE = ['active_network', 'networks']
IGNORE = ['active_network', 'folders']
IGNORE = ['active_network', 'brownie_folder']


class ConfigDict(dict):
Expand Down Expand Up @@ -44,56 +44,67 @@ def _unlock(self):
self._locked = False


def _load_json(path):
with path.open() as fp:
raw_json = fp.read()
valid_json = re.sub(r'\/\/[^"]*?(?=\n|$)', '', raw_json)
return json.loads(valid_json)


def _load_default_config():
'''Loads the default configuration settings from brownie/data/config.json'''
with Path(__file__).parent.joinpath("data/config.json").open() as fp:
config = _Singleton("Config", (ConfigDict,), {})(json.load(fp))
config['folders'] = {
'brownie': str(Path(__file__).parent),
'project': None
}
config['active_network'] = {'name': None}
brownie_path = Path(__file__).parent
path = brownie_path.joinpath("data/config.json")
config = _Singleton("Config", (ConfigDict,), {})(_load_json(path))
config.update({
'active_network': {'name': None},
'brownie_folder': brownie_path,
})
return config


def load_project_config(project_path):
'''Loads configuration settings from a project's brownie-config.json'''
def _get_project_config_file(project_path):
project_path = Path(project_path)
if not project_path.exists():
raise ValueError("Project does not exist!")
config_path = Path(project_path).joinpath("brownie-config.json")
return _load_json(config_path)


def load_project_config(project_path):
'''Loads configuration settings from a project's brownie-config.json'''
config_data = _get_project_config_file(project_path)
CONFIG._unlock()
CONFIG['folders']['project'] = str(project_path)
config_path = project_path.joinpath("brownie-config.json")
try:
with config_path.open() as fp:
_recursive_update(CONFIG, json.load(fp), [])
except FileNotFoundError:
shutil.copy(
str(Path(CONFIG['folders']['brownie']).joinpath("data/config.json")),
str(config_path)
)
print("WARNING: No config file found for this project. A new one has been created.")
_recursive_update(CONFIG, config_data, [])
CONFIG.setdefault('active_network', {'name': None})
CONFIG._lock()


def load_project_compiler_config(project_path, compiler):
if not project_path:
return CONFIG['compiler'][compiler]
config_data = _get_project_config_file(project_path)
return config_data['compiler'][compiler]


def modify_network_config(network=None):
'''Modifies the 'active_network' configuration settings'''
CONFIG._unlock()
try:
if not network:
network = CONFIG['network_defaults']['name']
network = CONFIG['network']['default']

CONFIG['active_network'] = {
**CONFIG['network_defaults'],
**CONFIG['networks'][network]
**CONFIG['network']['settings'],
**CONFIG['network']['networks'][network]
}
CONFIG['active_network']['name'] = network

if ARGV['cli'] == "test":
CONFIG['active_network'].update(CONFIG['test'])
CONFIG['active_network'].update(CONFIG['pytest'])
if not CONFIG['active_network']['broadcast_reverting_tx']:
print("WARNING: Reverting transactions will NOT be broadcasted.")
return CONFIG['active_network']
except KeyError:
raise KeyError(f"Network '{network}' is not defined in config.json")
finally:
Expand All @@ -106,10 +117,10 @@ def _recursive_update(original, new, base):
if type(new[k]) is dict and k in REPLACE:
original[k] = new[k]
elif type(new[k]) is dict and k in original:
_recursive_update(original[k], new[k], base+[k])
_recursive_update(original[k], new[k], base + [k])
else:
original[k] = new[k]
for k in [i for i in original if i not in new and not set(base+[i]).intersection(IGNORE)]:
for k in [i for i in original if i not in new and not set(base + [i]).intersection(IGNORE)]:
print(
f"WARNING: '{'.'.join(base+[k])}' not found in the config file for this project."
" The default setting has been used."
Expand Down
4 changes: 2 additions & 2 deletions brownie/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from brownie.exceptions import ProjectNotFound
from brownie._config import ARGV

__version__ = "1.0.0b10" # did you change this in docs/conf.py as well?
__version__ = "1.0.0b11" # did you change this in docs/conf.py as well?

__doc__ = """Usage: brownie <command> [<args>...] [options <args>]
Expand Down Expand Up @@ -50,7 +50,7 @@ def main():
sys.modules['brownie'].__all__.append('a')

try:
importlib.import_module("brownie.cli."+args['<command>']).main()
importlib.import_module(f"brownie.cli.{args['<command>']}").main()
except ProjectNotFound:
notify("ERROR", "Brownie environment has not been initiated for this folder.")
print("Type 'brownie init' to create the file structure.")
Expand Down
14 changes: 10 additions & 4 deletions brownie/cli/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
__doc__ = f"""Usage: brownie console [options]
Options:
--network <name> Use a specific network (default {CONFIG['network_defaults']['name']})
--verbose -v Enable verbose reporting
--network <name> Use a specific network (default {CONFIG['network']['default']})
--tb -t Show entire python traceback on exceptions
--help -h Display this message
Expand All @@ -23,8 +22,15 @@ def main():
args = docopt(__doc__)
update_argv_from_docopt(args)

project.load()
if project.check_for_project():
active_project = project.load()
active_project.load_config()
print(f"{active_project._name} is the active project.")
else:
active_project = None
print("No project was loaded.")

network.connect(ARGV['network'])

shell = Console()
shell = Console(active_project)
shell.interact(banner="Brownie environment is ready.", exitmsg="")
19 changes: 15 additions & 4 deletions brownie/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from docopt import docopt

from brownie import network, project, run
from brownie.test.output import print_gas_profile
from brownie._config import ARGV, CONFIG, update_argv_from_docopt


Expand All @@ -13,9 +14,8 @@
[<function>] The function to call (default is main)
Options:
--network [name] Use a specific network (default {CONFIG['network_defaults']['name']})
--network [name] Use a specific network (default {CONFIG['network']['default']})
--gas -g Display gas profile for function calls
--verbose -v Enable verbose reporting
--tb -t Show entire python traceback on exceptions
--help -h Display this message
Expand All @@ -26,6 +26,17 @@
def main():
args = docopt(__doc__)
update_argv_from_docopt(args)
project.load()

if project.check_for_project():
active_project = project.load()
active_project.load_config()
print(f"{active_project._name} is the active project.")
else:
active_project = None
print("No project was loaded.")

network.connect(ARGV['network'])
run(args['<filename>'], args['<function>'] or "main", gas_profile=ARGV['gas'])

run(args['<filename>'], method_name=args['<function>'] or "main", project=active_project)
if ARGV['gas']:
print_gas_profile()
Loading

0 comments on commit 21611a0

Please sign in to comment.