Skip to content

Commit 8533ff0

Browse files
author
Roman
committed
make DynamicInfo.price Optional[Balance] + raise the error of not None or Balance
1 parent e9d12e7 commit 8533ff0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bittensor/core/chain_data/dynamic_info.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DynamicInfo(InfoBase):
2727
alpha_in: Balance
2828
alpha_out: Balance
2929
tao_in: Balance
30-
price: Balance
30+
price: Optional[Balance]
3131
k: float
3232
is_dynamic: bool
3333
alpha_out_emission: Balance
@@ -90,6 +90,10 @@ def _from_dict(cls, decoded: dict) -> "DynamicInfo":
9090
)
9191
else:
9292
subnet_identity = None
93+
price = decoded.get("price", None)
94+
95+
if price and not isinstance(price, Balance):
96+
raise ValueError(f"price must be a Balance object, got {type(price)}.")
9397

9498
return cls(
9599
netuid=netuid,
@@ -106,7 +110,7 @@ def _from_dict(cls, decoded: dict) -> "DynamicInfo":
106110
tao_in=tao_in,
107111
k=tao_in.rao * alpha_in.rao,
108112
is_dynamic=is_dynamic,
109-
price=decoded.get("price", None),
113+
price=price,
110114
alpha_out_emission=alpha_out_emission,
111115
alpha_in_emission=alpha_in_emission,
112116
tao_in_emission=tao_in_emission,

0 commit comments

Comments
 (0)