@@ -140,7 +140,7 @@ class MetagraphInfo(InfoBase):
140140
141141 @classmethod
142142 def _from_dict (cls , decoded : dict ) -> "MetagraphInfo" :
143- """Returns a Metagraph object from a decoded MetagraphInfo dictionary ."""
143+ """Returns a MetagraphInfo object from decoded chain data ."""
144144 # Subnet index
145145 _netuid = decoded ["netuid" ]
146146
@@ -152,80 +152,101 @@ def _from_dict(cls, decoded: dict) -> "MetagraphInfo":
152152 processed = process_nested (raw_data , _chr_str )
153153 decoded .update ({key : processed })
154154
155- # Keys for owner.
156- decoded ["owner_hotkey" ] = decode_account_id (decoded ["owner_hotkey" ])
157- decoded ["owner_coldkey" ] = decode_account_id (decoded ["owner_coldkey" ])
158-
159- # Subnet emission terms
160- decoded ["subnet_emission" ] = _tbwu (decoded ["subnet_emission" ])
161- decoded ["alpha_in" ] = _tbwu (decoded ["alpha_in" ], _netuid )
162- decoded ["alpha_out" ] = _tbwu (decoded ["alpha_out" ], _netuid )
163- decoded ["tao_in" ] = _tbwu (decoded ["tao_in" ])
164- decoded ["alpha_out_emission" ] = _tbwu (decoded ["alpha_out_emission" ], _netuid )
165- decoded ["alpha_in_emission" ] = _tbwu (decoded ["alpha_in_emission" ], _netuid )
166- decoded ["tao_in_emission" ] = _tbwu (decoded ["tao_in_emission" ])
167- decoded ["pending_alpha_emission" ] = _tbwu (
168- decoded ["pending_alpha_emission" ], _netuid
169- )
170- decoded ["pending_root_emission" ] = _tbwu (decoded ["pending_root_emission" ])
171- decoded ["subnet_volume" ] = _tbwu (decoded ["subnet_volume" ], _netuid )
172- decoded ["moving_price" ] = Balance .from_tao (
173- fixed_to_float (decoded .get ("moving_price" ), 32 )
155+ return cls (
156+ # Subnet index
157+ netuid = _netuid ,
158+ # Name and symbol
159+ name = decoded ["name" ],
160+ symbol = decoded ["symbol" ],
161+ identity = decoded ["identity" ],
162+ network_registered_at = decoded ["network_registered_at" ],
163+ # Keys for owner.
164+ owner_hotkey = decoded ["owner_hotkey" ],
165+ owner_coldkey = decoded ["owner_coldkey" ],
166+ # Tempo terms.
167+ block = decoded ["block" ],
168+ tempo = decoded ["tempo" ],
169+ last_step = decoded ["last_step" ],
170+ blocks_since_last_step = decoded ["blocks_since_last_step" ],
171+ # Subnet emission terms
172+ subnet_emission = _tbwu (decoded ["subnet_emission" ]),
173+ alpha_in = _tbwu (decoded ["alpha_in" ], _netuid ),
174+ alpha_out = _tbwu (decoded ["alpha_out" ], _netuid ),
175+ tao_in = _tbwu (decoded ["tao_in" ]),
176+ alpha_out_emission = _tbwu (decoded ["alpha_out_emission" ], _netuid ),
177+ alpha_in_emission = _tbwu (decoded ["alpha_in_emission" ], _netuid ),
178+ tao_in_emission = _tbwu (decoded ["tao_in_emission" ]),
179+ pending_alpha_emission = _tbwu (decoded ["pending_alpha_emission" ], _netuid ),
180+ pending_root_emission = _tbwu (decoded ["pending_root_emission" ]),
181+ subnet_volume = _tbwu (decoded ["subnet_volume" ], _netuid ),
182+ moving_price = Balance .from_tao (
183+ fixed_to_float (decoded .get ("moving_price" ), 32 )
184+ ),
185+ # Hparams for epoch
186+ rho = decoded ["rho" ],
187+ kappa = decoded ["kappa" ],
188+ # Validator params
189+ min_allowed_weights = u16tf (decoded ["min_allowed_weights" ]),
190+ max_weights_limit = u16tf (decoded ["max_weights_limit" ]),
191+ weights_version = decoded ["weights_version" ],
192+ weights_rate_limit = decoded ["weights_rate_limit" ],
193+ activity_cutoff = decoded ["activity_cutoff" ],
194+ max_validators = decoded ["max_validators" ],
195+ # Registration
196+ num_uids = decoded ["num_uids" ],
197+ max_uids = decoded ["max_uids" ],
198+ burn = _tbwu (decoded ["burn" ]),
199+ difficulty = u64tf (decoded ["difficulty" ]),
200+ registration_allowed = decoded ["registration_allowed" ],
201+ pow_registration_allowed = decoded ["pow_registration_allowed" ],
202+ immunity_period = decoded ["immunity_period" ],
203+ min_difficulty = u64tf (decoded ["min_difficulty" ]),
204+ max_difficulty = u64tf (decoded ["max_difficulty" ]),
205+ min_burn = _tbwu (decoded ["min_burn" ]),
206+ max_burn = _tbwu (decoded ["max_burn" ]),
207+ adjustment_alpha = u64tf (decoded ["adjustment_alpha" ]),
208+ adjustment_interval = decoded ["adjustment_interval" ],
209+ target_regs_per_interval = decoded ["target_regs_per_interval" ],
210+ max_regs_per_block = decoded ["max_regs_per_block" ],
211+ serving_rate_limit = decoded ["serving_rate_limit" ],
212+ # CR
213+ commit_reveal_weights_enabled = decoded ["commit_reveal_weights_enabled" ],
214+ commit_reveal_period = decoded ["commit_reveal_period" ],
215+ # Bonds
216+ liquid_alpha_enabled = decoded ["liquid_alpha_enabled" ],
217+ alpha_high = u16tf (decoded ["alpha_high" ]),
218+ alpha_low = u16tf (decoded ["alpha_low" ]),
219+ bonds_moving_avg = u64tf (decoded ["bonds_moving_avg" ]),
220+ # Metagraph info.
221+ hotkeys = [decode_account_id (ck ) for ck in decoded .get ("hotkeys" , [])],
222+ coldkeys = [decode_account_id (hk ) for hk in decoded .get ("coldkeys" , [])],
223+ identities = decoded ["identities" ],
224+ axons = decoded .get ("axons" , []),
225+ active = decoded ["active" ],
226+ validator_permit = decoded ["validator_permit" ],
227+ pruning_score = [u16tf (ps ) for ps in decoded .get ("pruning_score" , [])],
228+ last_update = decoded ["last_update" ],
229+ emission = [_tbwu (em , _netuid ) for em in decoded .get ("emission" , [])],
230+ dividends = [u16tf (dv ) for dv in decoded .get ("dividends" , [])],
231+ incentives = [u16tf (ic ) for ic in decoded .get ("incentives" , [])],
232+ consensus = [u16tf (cs ) for cs in decoded .get ("consensus" , [])],
233+ trust = [u16tf (tr ) for tr in decoded .get ("trust" , [])],
234+ rank = [u16tf (rk ) for rk in decoded .get ("rank" , [])],
235+ block_at_registration = decoded ["block_at_registration" ],
236+ alpha_stake = [_tbwu (ast , _netuid ) for ast in decoded ["alpha_stake" ]],
237+ tao_stake = [_tbwu (ts ) for ts in decoded ["tao_stake" ]],
238+ total_stake = [_tbwu (ts , _netuid ) for ts in decoded ["total_stake" ]],
239+ # Dividend break down
240+ tao_dividends_per_hotkey = [
241+ (decode_account_id (alpha [0 ]), _tbwu (alpha [1 ]))
242+ for alpha in decoded ["tao_dividends_per_hotkey" ]
243+ ],
244+ alpha_dividends_per_hotkey = [
245+ (decode_account_id (adphk [0 ]), _tbwu (adphk [1 ], _netuid ))
246+ for adphk in decoded ["alpha_dividends_per_hotkey" ]
247+ ],
174248 )
175249
176- # Hparams for epoch
177- decoded ["kappa" ] = u16tf (decoded ["kappa" ])
178-
179- # Validator params
180- decoded ["min_allowed_weights" ] = u16tf (decoded ["min_allowed_weights" ])
181- decoded ["max_weights_limit" ] = u16tf (decoded ["max_weights_limit" ])
182-
183- # Registration
184- decoded ["burn" ] = _tbwu (decoded ["burn" ])
185- decoded ["difficulty" ] = u64tf (decoded ["difficulty" ])
186- decoded ["min_difficulty" ] = u64tf (decoded ["min_difficulty" ])
187- decoded ["max_difficulty" ] = u64tf (decoded ["max_difficulty" ])
188- decoded ["min_burn" ] = _tbwu (decoded ["min_burn" ])
189- decoded ["max_burn" ] = _tbwu (decoded ["max_burn" ])
190- decoded ["adjustment_alpha" ] = u64tf (decoded ["adjustment_alpha" ])
191-
192- # Bonds
193- decoded ["alpha_high" ] = u16tf (decoded ["alpha_high" ])
194- decoded ["alpha_low" ] = u16tf (decoded ["alpha_low" ])
195- decoded ["bonds_moving_avg" ] = u64tf (decoded ["bonds_moving_avg" ])
196-
197- # Metagraph info.
198- decoded ["hotkeys" ] = [
199- decode_account_id (ck ) for ck in decoded .get ("hotkeys" , [])
200- ]
201- decoded ["coldkeys" ] = [
202- decode_account_id (hk ) for hk in decoded .get ("coldkeys" , [])
203- ]
204- decoded ["axons" ] = decoded .get ("axons" , [])
205- decoded ["pruning_score" ] = [
206- u16tf (ps ) for ps in decoded .get ("pruning_score" , [])
207- ]
208- decoded ["emission" ] = [_tbwu (em , _netuid ) for em in decoded .get ("emission" , [])]
209- decoded ["dividends" ] = [u16tf (dv ) for dv in decoded .get ("dividends" , [])]
210- decoded ["incentives" ] = [u16tf (ic ) for ic in decoded .get ("incentives" , [])]
211- decoded ["consensus" ] = [u16tf (cs ) for cs in decoded .get ("consensus" , [])]
212- decoded ["trust" ] = [u16tf (tr ) for tr in decoded .get ("trust" , [])]
213- decoded ["rank" ] = [u16tf (rk ) for rk in decoded .get ("trust" , [])]
214- decoded ["alpha_stake" ] = [_tbwu (ast , _netuid ) for ast in decoded ["alpha_stake" ]]
215- decoded ["tao_stake" ] = [_tbwu (ts ) for ts in decoded ["tao_stake" ]]
216- decoded ["total_stake" ] = [_tbwu (ts , _netuid ) for ts in decoded ["total_stake" ]]
217-
218- # Dividend break down
219- decoded ["tao_dividends_per_hotkey" ] = [
220- (decode_account_id (alpha [0 ]), _tbwu (alpha [1 ]))
221- for alpha in decoded ["tao_dividends_per_hotkey" ]
222- ]
223- decoded ["alpha_dividends_per_hotkey" ] = [
224- (decode_account_id (adphk [0 ]), _tbwu (adphk [1 ], _netuid ))
225- for adphk in decoded ["alpha_dividends_per_hotkey" ]
226- ]
227- return MetagraphInfo (** decoded )
228-
229250
230251@dataclass
231252class MetagraphInfoEmissions :
0 commit comments