Skip to content
Open
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
12 changes: 10 additions & 2 deletions ape_tokens/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ def from_tokeninfo(cls, token_info: "TokenInfo"):

# NOTE: Patch all of our "immutable" fields with caching call handler subclass
for field in ("name", "symbol", "decimals"):
method = contract_instance._view_methods_[field]
try:
method = contract_instance._view_methods_[field]
except KeyError:
continue

method.__class__ = ImmutableCallHandler
method.__doc__ = f"""The {field} of the token (sourced from 'py-tokenlists')"""
method._cached_value = getattr(token_info, field)
Expand All @@ -175,7 +179,11 @@ def at(self, *args, **kwargs) -> TokenInstance:

# NOTE: Patch all of our "immutable" fields with caching call handler subclass
for field in ("name", "symbol", "decimals"):
method = contract_instance._view_methods_[field]
try:
method = contract_instance._view_methods_[field]
except KeyError:
continue

method.__class__ = ImmutableCallHandler
method.__doc__ = f"""The {field} of the token (sourced from 'py-tokenlists')"""
contract_instance._view_methods_[field] = method
Expand Down
Loading