Skip to content

Commit

Permalink
Merge pull request #45 from mikeshultz/hexbytes
Browse files Browse the repository at this point in the history
refactor: use isinstance() instead of type() == x, to allow support for subclasses
  • Loading branch information
mikeshultz authored Aug 5, 2023
2 parents 4eb50c1 + 2b6557e commit 4b3a1db
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ledgereth/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def sign_message(
message = message.encode("utf-8")

# Silence mypy due to type cohersion above
assert type(message) == bytes
assert isinstance(message, bytes)

encoded = struct.pack(">I", len(message))
encoded += message
Expand Down Expand Up @@ -125,8 +125,8 @@ def sign_typed_data_draft(
message_hash = message_hash.encode("utf-8")

# Silence mypy due to type cohersion above
assert type(domain_hash) == bytes
assert type(message_hash) == bytes
assert isinstance(domain_hash, bytes)
assert isinstance(message_hash, bytes)

encoded = domain_hash + message_hash

Expand Down
4 changes: 2 additions & 2 deletions ledgereth/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def create_transaction(
data = decode_hex(data)

# be cool mypy
assert type(destination) == bytes
assert type(data) == bytes
assert isinstance(destination, bytes)
assert isinstance(data, bytes)

# EIP-1559 transactions should never have gas_price
if gas_price and (max_priority_fee_per_gas or max_fee_per_gas):
Expand Down
2 changes: 1 addition & 1 deletion ledgereth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def decode_web3_access_list(
if "storageKeys" not in item:
raise ValueError(f"Access list item at position {idx} missing storageKeys")

assert type(item["address"]) == str
assert isinstance(item["address"], str)

work_list.append(
(
Expand Down

0 comments on commit 4b3a1db

Please sign in to comment.