-
Notifications
You must be signed in to change notification settings - Fork 45
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
Don't try to find service contracts for RedEyes #809
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from copy import deepcopy | ||
from json import JSONDecodeError | ||
from pathlib import Path | ||
from semver import compare | ||
from typing import Any, Dict, List, Optional | ||
|
||
from deprecated import deprecated | ||
|
@@ -164,6 +165,16 @@ def merge_deployment_data(dict1: Dict, dict2: Dict) -> Dict: | |
return result | ||
|
||
|
||
def version_provides_services(version: Optional[str]) -> bool: | ||
if version is None: | ||
return True | ||
if version == '0.3._': | ||
return False | ||
if version == '0.8.0_unlimited': | ||
return True | ||
return compare(version, '0.8.0') > -1 | ||
|
||
|
||
def get_contracts_deployment_info( | ||
chain_id: int, | ||
version: Optional[str] = None, | ||
|
@@ -172,7 +183,8 @@ def get_contracts_deployment_info( | |
"""Reads the deployment data. | ||
|
||
Parameter: | ||
module The name of the module. ALL means deployed contracts from all modules. | ||
module The name of the module. ALL means deployed contracts from all modules that are | ||
available for the version. | ||
""" | ||
if module not in DeploymentModule: | ||
raise ValueError(f'Unknown module {module} given to get_contracts_deployment_info()') | ||
|
@@ -186,7 +198,14 @@ def get_contracts_deployment_info( | |
services=False, | ||
)) | ||
|
||
if module == DeploymentModule.SERVICES or module == DeploymentModule.ALL: | ||
if module == DeploymentModule.SERVICES and not version_provides_services(version): | ||
raise ValueError( | ||
f'SERVICES module queried for version {version}, but {version}' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A space is missing. |
||
'does not provide service contracts.', | ||
) | ||
|
||
if (module == DeploymentModule.SERVICES or module == DeploymentModule.ALL) and \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style nitpick: We never use module_match = module == DeploymentModule.SERVICES or module == DeploymentModule.ALL
if module_match and version_provides_services(version):
file.append(.... Also wouldn't the check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When people ask for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yes. My bad! |
||
version_provides_services(version): | ||
files.append(contracts_deployed_path( | ||
chain_id=chain_id, | ||
version=version, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this is confusing. What exactly do you want to achieve with the last check.
Looking at the docs of the semver module this will return true for versions >= 0.8.0.
If this is what you want to achieve then perhaps do
compare(version, '0.8.0') >= 0
since this way it will be a bit more obvious what is happening. The-1
had me confused and I had to check the docs. And perhaps also add a docstring as not everyone knows how this compare function looks like.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change to
>= 0
. I agree it's easier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks man