Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/9.0.0rc4 #2648

Closed
wants to merge 14 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add extra fields
  • Loading branch information
roman-opentensor committed Feb 7, 2025
commit d1c2f8bc6232a7275c83b378fa73917fab7949a4
10 changes: 8 additions & 2 deletions bittensor/core/chain_data/info_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass
from dataclasses import dataclass, fields
from typing import Any, TypeVar

from bittensor.core.errors import SubstrateRequestException
@@ -13,7 +13,13 @@ class InfoBase:
@classmethod
def from_dict(cls, decoded: dict) -> T:
try:
return cls._from_dict(decoded)
class_fields = {f.name for f in fields(cls)}
extra_keys = decoded.keys() - class_fields
instance = cls._from_dict(
{k: v for k, v in decoded.items() if k in class_fields}
)
[setattr(instance, k, decoded[k]) for k in extra_keys]
return instance
except KeyError as e:
raise SubstrateRequestException(
f"The {cls} structure is missing {e} from the chain.",