From 6d6c417fe531d72cdbf5be723b678db2e9c2d282 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 23 Aug 2022 12:33:48 +0000 Subject: [PATCH] fix(util): do not validate integer chainId anybody can create a network with a new chainId. stop validating the integers, but do validate the strings. as a side effect, this means we accept Harmony's ethereum compatible chain ids. --- pyhmy/util.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pyhmy/util.py b/pyhmy/util.py index df2dbd6..2c10031 100644 --- a/pyhmy/util.py +++ b/pyhmy/util.py @@ -64,12 +64,11 @@ def chain_id_to_int(chainId): HmyLocal = 2, HmyPangaea = 3, ) + + # do not validate integer chainids, only known strings if isinstance(chainId, str): - assert chainId in chainIds, f'ChainId {chainId} is not valid' + assert chainId in chainIds, f'Chain {chainId} unknown, specify an integer chainId' return chainIds.get(chainId) - elif isinstance(chainId, int): - assert chainId in chainIds.values(), f'Unknown chain id {chainId}' - return chainId else: raise TypeError( 'chainId must be str or int' )