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.
pull/35/head
MaxMustermann2 2 years ago
parent 2f0d840f6e
commit 6d6c417fe5
No known key found for this signature in database
GPG Key ID: 4F4AB9DB6FF24C94
  1. 7
      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' )

Loading…
Cancel
Save