Skip to content

Commit

Permalink
fix: chain id type
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jan 8, 2025
1 parent 1a018d2 commit 808d067
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/ape/api/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,6 @@ def chain_id(self) -> int:
**NOTE**: Unless overridden, returns same as
:py:attr:`ape.api.providers.ProviderAPI.chain_id`.
"""

return self.provider.chain_id

@property
Expand Down
1 change: 0 additions & 1 deletion src/ape/managers/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,6 @@ def chain_id(self) -> int:
The blockchain ID.
See `ChainList <https://chainlist.org/>`__ for a comprehensive list of IDs.
"""

network_name = self.provider.network.name
if network_name not in self._chain_id_map:
self._chain_id_map[network_name] = self.provider.chain_id
Expand Down
9 changes: 8 additions & 1 deletion src/ape_ethereum/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def chain_id(self) -> int:

try:
if hasattr(self.web3, "eth"):
return self.make_request("eth_chainId", [])
return self._get_chain_id()

except ProviderNotConnectedError:
if default_chain_id is not None:
Expand Down Expand Up @@ -614,6 +614,13 @@ def priority_fee(self) -> int:
"eth_maxPriorityFeePerGas not supported in this RPC. Please specify manually."
) from err

def _get_chain_id(self) -> int:
result = self.make_request("eth_chainId", [])
if isinstance(result, int):
return result

return int(result, 16)

def get_block(self, block_id: "BlockID") -> BlockAPI:
if isinstance(block_id, str) and block_id.isnumeric():
block_id = int(block_id)
Expand Down

0 comments on commit 808d067

Please sign in to comment.