@@ -157,10 +157,10 @@ def _from_dict(cls, decoded: dict) -> "MetagraphInfo":
157
157
decoded .update ({"symbol" : bytes (symbol ).decode ()})
158
158
159
159
ii_list = []
160
- if decoded .get ("identity" ):
160
+ if decoded .get ("identity" ) is not None :
161
161
ii_list .append ("identity" )
162
162
163
- if decoded .get ("identities" ):
163
+ if decoded .get ("identities" ) is not None :
164
164
ii_list .append ("identities" )
165
165
166
166
for key in ii_list :
@@ -178,10 +178,10 @@ def _from_dict(cls, decoded: dict) -> "MetagraphInfo":
178
178
network_registered_at = decoded ["network_registered_at" ],
179
179
# Keys for owner.
180
180
owner_hotkey = decode_account_id (decoded ["owner_hotkey" ][0 ])
181
- if decoded .get ("owner_hotkey" )
181
+ if decoded .get ("owner_hotkey" ) is not None
182
182
else None ,
183
183
owner_coldkey = decode_account_id (decoded ["owner_coldkey" ][0 ])
184
- if decoded .get ("owner_coldkey" )
184
+ if decoded .get ("owner_coldkey" ) is not None
185
185
else None ,
186
186
# Tempo terms.
187
187
block = decoded ["block" ],
@@ -202,17 +202,17 @@ def _from_dict(cls, decoded: dict) -> "MetagraphInfo":
202
202
moving_price = Balance .from_tao (
203
203
fixed_to_float (decoded .get ("moving_price" ), 32 )
204
204
)
205
- if decoded .get ("moving_price" )
205
+ if decoded .get ("moving_price" ) is not None
206
206
else None ,
207
207
# Hparams for epoch
208
208
rho = decoded ["rho" ],
209
209
kappa = decoded ["kappa" ],
210
210
# Validator params
211
211
min_allowed_weights = u16tf (decoded ["min_allowed_weights" ])
212
- if decoded [ "min_allowed_weights" ]
212
+ if decoded . get ( "min_allowed_weights" ) is not None
213
213
else None ,
214
214
max_weights_limit = u16tf (decoded ["max_weights_limit" ])
215
- if decoded ["max_weights_limit" ]
215
+ if decoded ["max_weights_limit" ] is not None
216
216
else None ,
217
217
weights_version = decoded ["weights_version" ],
218
218
weights_rate_limit = decoded ["weights_rate_limit" ],
@@ -222,20 +222,22 @@ def _from_dict(cls, decoded: dict) -> "MetagraphInfo":
222
222
num_uids = decoded ["num_uids" ],
223
223
max_uids = decoded ["max_uids" ],
224
224
burn = _tbwu (decoded ["burn" ]),
225
- difficulty = u64tf (decoded ["difficulty" ]) if decoded ["difficulty" ] else None ,
225
+ difficulty = u64tf (decoded ["difficulty" ])
226
+ if decoded ["difficulty" ] is not None
227
+ else None ,
226
228
registration_allowed = decoded ["registration_allowed" ],
227
229
pow_registration_allowed = decoded ["pow_registration_allowed" ],
228
230
immunity_period = decoded ["immunity_period" ],
229
231
min_difficulty = u64tf (decoded ["min_difficulty" ])
230
- if decoded ["min_difficulty" ]
232
+ if decoded ["min_difficulty" ] is not None
231
233
else None ,
232
234
max_difficulty = u64tf (decoded ["max_difficulty" ])
233
- if decoded ["max_difficulty" ]
235
+ if decoded ["max_difficulty" ] is not None
234
236
else None ,
235
237
min_burn = _tbwu (decoded ["min_burn" ]),
236
238
max_burn = _tbwu (decoded ["max_burn" ]),
237
239
adjustment_alpha = u64tf (decoded ["adjustment_alpha" ])
238
- if decoded ["adjustment_alpha" ]
240
+ if decoded ["adjustment_alpha" ] is not None
239
241
else None ,
240
242
adjustment_interval = decoded ["adjustment_interval" ],
241
243
target_regs_per_interval = decoded ["target_regs_per_interval" ],
@@ -246,69 +248,73 @@ def _from_dict(cls, decoded: dict) -> "MetagraphInfo":
246
248
commit_reveal_period = decoded ["commit_reveal_period" ],
247
249
# Bonds
248
250
liquid_alpha_enabled = decoded ["liquid_alpha_enabled" ],
249
- alpha_high = u16tf (decoded ["alpha_high" ]) if decoded ["alpha_high" ] else None ,
250
- alpha_low = u16tf (decoded ["alpha_low" ]) if decoded ["alpha_low" ] else None ,
251
+ alpha_high = u16tf (decoded ["alpha_high" ])
252
+ if decoded ["alpha_high" ] is not None
253
+ else None ,
254
+ alpha_low = u16tf (decoded ["alpha_low" ])
255
+ if decoded ["alpha_low" ] is not None
256
+ else None ,
251
257
bonds_moving_avg = u64tf (decoded ["bonds_moving_avg" ])
252
- if decoded ["bonds_moving_avg" ]
258
+ if decoded ["bonds_moving_avg" ] is not None
253
259
else None ,
254
260
# Metagraph info.
255
261
hotkeys = [decode_account_id (ck ) for ck in decoded .get ("hotkeys" , [])]
256
- if decoded .get ("hotkeys" )
262
+ if decoded .get ("hotkeys" ) is not None
257
263
else None ,
258
264
coldkeys = [decode_account_id (hk ) for hk in decoded .get ("coldkeys" , [])]
259
- if decoded .get ("coldkeys" )
265
+ if decoded .get ("coldkeys" ) is not None
260
266
else None ,
261
267
identities = decoded ["identities" ],
262
268
axons = decoded .get ("axons" , []),
263
269
active = decoded ["active" ],
264
270
validator_permit = decoded ["validator_permit" ],
265
271
pruning_score = [u16tf (ps ) for ps in decoded .get ("pruning_score" , [])]
266
- if decoded .get ("pruning_score" )
272
+ if decoded .get ("pruning_score" ) is not None
267
273
else None ,
268
274
last_update = decoded ["last_update" ],
269
275
emission = [_tbwu (em , _netuid ) for em in decoded .get ("emission" , [])]
270
- if decoded .get ("emission" )
276
+ if decoded .get ("emission" ) is not None
271
277
else None ,
272
278
dividends = [u16tf (dv ) for dv in decoded .get ("dividends" , [])]
273
- if decoded .get ("dividends" )
279
+ if decoded .get ("dividends" ) is not None
274
280
else None ,
275
281
incentives = [u16tf (ic ) for ic in decoded .get ("incentives" , [])]
276
- if decoded .get ("incentives" )
282
+ if decoded .get ("incentives" ) is not None
277
283
else None ,
278
284
consensus = [u16tf (cs ) for cs in decoded .get ("consensus" , [])]
279
- if decoded .get ("consensus" )
285
+ if decoded .get ("consensus" ) is not None
280
286
else None ,
281
287
trust = [u16tf (tr ) for tr in decoded .get ("trust" , [])]
282
- if decoded .get ("trust" )
288
+ if decoded .get ("trust" ) is not None
283
289
else None ,
284
290
rank = [u16tf (rk ) for rk in decoded .get ("rank" , [])]
285
- if decoded .get ("rank" )
291
+ if decoded .get ("rank" ) is not None
286
292
else None ,
287
293
block_at_registration = decoded ["block_at_registration" ],
288
294
alpha_stake = [_tbwu (ast , _netuid ) for ast in decoded ["alpha_stake" ]]
289
- if decoded .get ("alpha_stake" )
295
+ if decoded .get ("alpha_stake" ) is not None
290
296
else None ,
291
297
tao_stake = [
292
298
_tbwu (ts ) * settings .ROOT_TAO_STAKE_WEIGHT
293
299
for ts in decoded ["tao_stake" ]
294
300
]
295
- if decoded .get ("tao_stake" )
301
+ if decoded .get ("tao_stake" ) is not None
296
302
else None ,
297
303
total_stake = [_tbwu (ts , _netuid ) for ts in decoded ["total_stake" ]]
298
- if decoded .get ("total_stake" )
304
+ if decoded .get ("total_stake" ) is not None
299
305
else None ,
300
306
# Dividend break down
301
307
tao_dividends_per_hotkey = [
302
308
(decode_account_id (alpha [0 ]), _tbwu (alpha [1 ]))
303
309
for alpha in decoded ["tao_dividends_per_hotkey" ]
304
310
]
305
- if decoded .get ("tao_dividends_per_hotkey" )
311
+ if decoded .get ("tao_dividends_per_hotkey" ) is not None
306
312
else None ,
307
313
alpha_dividends_per_hotkey = [
308
314
(decode_account_id (adphk [0 ]), _tbwu (adphk [1 ], _netuid ))
309
315
for adphk in decoded ["alpha_dividends_per_hotkey" ]
310
316
]
311
- if decoded .get ("alpha_dividends_per_hotkey" )
317
+ if decoded .get ("alpha_dividends_per_hotkey" ) is not None
312
318
else None ,
313
319
)
314
320
0 commit comments