From 28384af1894311122233f95889d9ee88f47cd6e2 Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Tue, 12 Jan 2021 23:37:24 +0100 Subject: [PATCH 1/3] feat: allow "true" and "false" as strings --- brownie_tokens/template.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/brownie_tokens/template.py b/brownie_tokens/template.py index 6f40000..45473b5 100644 --- a/brownie_tokens/template.py +++ b/brownie_tokens/template.py @@ -21,6 +21,12 @@ None: "return", } +STRING_CONVERT = { + "true": True, + "false": False, + "none": None, +} + with Path(__file__).parent.joinpath("token-template.vy").open() as fp: TEMPLATE = fp.read() @@ -29,7 +35,7 @@ def ERC20( name: str = "Test Token", symbol: str = "TST", decimals: int = 18, - success: Union[bool, None] = True, + success: Union[bool, str, None] = True, fail: Union[bool, str, None] = "revert", ) -> Contract: """ @@ -54,6 +60,12 @@ def ERC20( Contract Deployed ERC20 contract """ + # understand success and fail when given as strings + if isinstance(success, str) and success.lower() in STRING_CONVERT: + success = STRING_CONVERT[success.lower()] + if isinstance(fail, str) and fail.lower() in STRING_CONVERT: + fail = STRING_CONVERT[fail.lower()] + if success not in RETURN_STATEMENT: valid_keys = [str(i) for i in RETURN_STATEMENT.keys()] raise ValueError(f"Invalid value for `success`, valid options are: {', '.join(valid_keys)}") From 162c2bf4fe31dac43f1b0a8cace97b6f57b9a60d Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Tue, 12 Jan 2021 23:41:04 +0100 Subject: [PATCH 2/3] fix: pin vyper version when compiling ERC20 --- brownie_tokens/template.py | 2 +- brownie_tokens/token-template.vy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/brownie_tokens/template.py b/brownie_tokens/template.py index 45473b5..b3cfd8d 100644 --- a/brownie_tokens/template.py +++ b/brownie_tokens/template.py @@ -78,7 +78,7 @@ def ERC20( return_statement=RETURN_STATEMENT[success], fail_statement=FAIL_STATEMENT[fail], ) - deployer = compile_source(source).Vyper + deployer = compile_source(source, vyper_version="0.2.8").Vyper return deployer.deploy( name, diff --git a/brownie_tokens/token-template.vy b/brownie_tokens/token-template.vy index 9300119..589b5fd 100644 --- a/brownie_tokens/token-template.vy +++ b/brownie_tokens/token-template.vy @@ -1,4 +1,4 @@ -# @version ^0.2.0 +# @version 0.2.8 """ @notice Mock non-standard ERC20 for testing """ From 61c754cf730ad0dd49e88592b7466b69f277c4c9 Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Tue, 12 Jan 2021 23:44:05 +0100 Subject: [PATCH 3/3] release: update changelog, bump version to v0.0.2 --- CHANGELOG.md | 5 +++++ setup.cfg | 6 +++--- setup.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d837a26..5e9f77a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,5 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/iamdefinitelyahuman/brownie-token-tester) +## [0.0.2](https://github.com/iamdefinitelyahuman/brownie-token-tester/tree/v0.0.2) - 2021-01-12 +### Fixed +- Improved handling of string types for `success` and `revert` kwargs in `ERC20` init +- Explicitly target Vyper version `0.2.8` to avoid issues when Solidity is not installed + ## [0.0.1](https://github.com/iamdefinitelyahuman/brownie-token-tester/tree/v0.0.1) - 2020-12-12 - Initial alpha release diff --git a/setup.cfg b/setup.cfg index cf7f961..df9678d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,12 +1,12 @@ [bumpversion] -current_version = 0.0.1 +current_version = 0.0.2 [bumpversion:file:setup.py] [flake8] max-line-length = 100 ignore = E203,W503 -per-file-ignores = +per-file-ignores = */__init__.py: F401 [tool:isort] @@ -24,7 +24,7 @@ ignore_missing_imports = True follow_imports = silent [tool:pytest] -addopts = +addopts = --cov brownie_tokens/ --cov-report term --cov-report xml diff --git a/setup.py b/setup.py index a7b89c6..b14d0db 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ name="brownie-token-tester", packages=find_packages(exclude=["tests", "tests.*"]), py_modules=["brownie_tokens"], - version="0.0.1", # don't change this manually, use bumpversion instead + version="0.0.2", # don't change this manually, use bumpversion instead license="MIT", description="Helper objects for generating ERC20s while testing a Brownie project.", long_description=long_description,