Skip to content

Commit

Permalink
add evm version mapping for vyper, tiny refactor of evm version mappi…
Browse files Browse the repository at this point in the history
…ng logic
  • Loading branch information
charles-cooper committed Jun 1, 2023
1 parent 6cd8f3d commit 846026b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
12 changes: 3 additions & 9 deletions brownie/project/compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@
"remappings": [],
},
}
EVM_SOLC_VERSIONS = [
("istanbul", Version("0.5.13")),
("petersburg", Version("0.5.5")),
("byzantium", Version("0.4.0")),
]



def compile_and_format(
Expand Down Expand Up @@ -177,10 +173,8 @@ def generate_input_json(
optimizer = {"enabled": optimize, "runs": runs if optimize else 0}

if evm_version is None:
if language == "Solidity":
evm_version = next(i[0] for i in EVM_SOLC_VERSIONS if solidity.get_version() >= i[1])
else:
evm_version = "paris"
_module = solidity if language == "Solidity" else vyper
evm_version = next(i[0] for i in _module.EVM_VERSION_MAPPING if _module.get_version() >= i[1])

input_json: Dict = deepcopy(STANDARD_JSON)
input_json["language"] = language
Expand Down
6 changes: 6 additions & 0 deletions brownie/project/compiler/solidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@

AVAILABLE_SOLC_VERSIONS = None

EVM_VERSION_MAPPING = [
("istanbul", Version("0.5.13")),
("petersburg", Version("0.5.5")),
("byzantium", Version("0.4.0")),
]

# error codes used in Solidity >=0.8.0
# docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require
SOLIDITY_ERROR_CODES = {
Expand Down
8 changes: 8 additions & 0 deletions brownie/project/compiler/vyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
_active_version = Version(vyper.__version__)


EVM_VERSION_MAPPING = [
("shanghai", Version("0.3.9")),
("paris", Version("0.3.7")),
("berlin", Version("0.2.12")),
("istanbul", Version("0.1.0")),
]


def get_version() -> Version:
return _active_version

Expand Down

0 comments on commit 846026b

Please sign in to comment.