Skip to content

Commit

Permalink
fix setup versioning issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sslivkoff committed Jul 14, 2023
1 parent 1f6a579 commit d26a2e9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/ctc/config/config_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,18 @@ def add_env_var_rpc_provider(default_config: spec.Config) -> None:
try:
from ctc.rpc import rpc_provider

if not eth_rpc_url.startswith('http') and not eth_rpc_url.startswith('ws'):
eth_rpc_url = 'http://' + eth_rpc_url

chain_id = rpc_provider._sync_get_chain_id(eth_rpc_url)
except Exception:

except Exception as e:
print(
'[WARNING] not using value in ETH_RPC_URL because could not determine its chain_id (value = '
+ str(eth_rpc_url)
+ ')'
)
print(e)
return
if chain_id not in default_config['networks']:
raise Exception(
Expand Down
36 changes: 32 additions & 4 deletions src/ctc/config/upgrade_utils/config_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def get_config_upgrade_functions() -> (
'0.3.3': upgrade__0_3_3__to__0_3_4,
'0.3.4': upgrade__0_3_4__to__0_3_5,
'0.3.5': upgrade__0_3_5__to__0_3_6,
'0.3.6': upgrade__0_3_6__to__0_3_7,
'0.3.7': upgrade__0_3_7__to__0_3_8,
'0.3.8': upgrade__0_3_8__to__0_3_9,
}


Expand All @@ -43,10 +46,11 @@ def upgrade_config(

# perform upgrade
if not isinstance(version, str):
print(
'old_config has unknown version, using default config',
file=sys.stderr,
)
if old_config != {}:
print(
'old_config has unknown version, using default config',
file=sys.stderr,
)
return dict(config_defaults.get_default_config())

new_config: typing.MutableMapping[typing.Any, typing.Any] = dict(old_config)
Expand Down Expand Up @@ -225,6 +229,30 @@ def upgrade__0_3_5__to__0_3_6(
return upgraded


def upgrade__0_3_6__to__0_3_7(
old_config: typing.MutableMapping[typing.Any, typing.Any]
) -> typing.MutableMapping[typing.Any, typing.Any]:
upgraded = dict(old_config)
upgraded['config_spec_version'] = '0.3.7'
return upgraded


def upgrade__0_3_7__to__0_3_8(
old_config: typing.MutableMapping[typing.Any, typing.Any]
) -> typing.MutableMapping[typing.Any, typing.Any]:
upgraded = dict(old_config)
upgraded['config_spec_version'] = '0.3.8'
return upgraded


def upgrade__0_3_8__to__0_3_9(
old_config: typing.MutableMapping[typing.Any, typing.Any]
) -> typing.MutableMapping[typing.Any, typing.Any]:
upgraded = dict(old_config)
upgraded['config_spec_version'] = '0.3.9'
return upgraded


def omit_extra_version_data(version: str) -> str:
for substr in ['a', 'b', 'rc']:
if substr in version:
Expand Down
6 changes: 6 additions & 0 deletions src/ctc/config/upgrade_utils/data_dir_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class DataDirSpec(TypedDict, total=False):
'0.3.4',
'0.3.5',
'0.3.6',
'0.3.7',
'0.3.8',
'0.3.9',
]

_0_3_0_spec: DataDirSpec = {
Expand All @@ -58,6 +61,9 @@ class DataDirSpec(TypedDict, total=False):
'0.3.4': _0_3_0_spec,
'0.3.5': _0_3_0_spec,
'0.3.6': _0_3_0_spec,
'0.3.7': _0_3_0_spec,
'0.3.8': _0_3_0_spec,
'0.3.9': _0_3_0_spec,
}


Expand Down
2 changes: 1 addition & 1 deletion src/ctc/evm/erc20_utils/erc20_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async def async_get_erc20_decimals(
'convert_reverts_to_none'
):
raise Exception('invalid rpc result')
decimals = decimals_result
decimals: int = decimals_result

if write_cache:
if result is not None:
Expand Down

0 comments on commit d26a2e9

Please sign in to comment.