Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web3/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ def parse_block_identifier(web3, block_identifier):
elif block_identifier in ['latest', 'earliest', 'pending']:
return block_identifier
elif isinstance(block_identifier, bytes) or is_hex_encoded_block_hash(block_identifier):
return web3.eth.getBlock(block_identifier).number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @dylanjw @carver @voith just in case you don't see this. This is a good example of why we should be as diligent as possible to not assume the AttributeDict API is usable within our own web3 apis. Forgive me for preaching to the choir if you're already aware.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, replacing all the middlewares as the user did in #1039 is almost definitely not what they wanted to do. There will be a lot of things that work incorrectly, like: fields won't be converted to and from python native types. I'm not suggesting that we should encourage attribute syntax, but this is only one of many things that will work in unexpected ways if the user drops all the middleware.

return web3.eth.getBlock(block_identifier)['number']
else:
raise BlockNumberOutofRange

Expand All @@ -1425,7 +1425,7 @@ def parse_block_identifier_int(web3, block_identifier_int):
if block_identifier_int >= 0:
block_num = block_identifier_int
else:
last_block = web3.eth.getBlock('latest').number
last_block = web3.eth.getBlock('latest')['number']
block_num = last_block + block_identifier_int + 1
if block_num < 0:
raise BlockNumberOutofRange
Expand Down