Skip to content

Commit 8085729

Browse files
committed
Initial commit
1 parent 1a3a944 commit 8085729

File tree

2 files changed

+303
-11
lines changed

2 files changed

+303
-11
lines changed

bittensor_cli/src/__init__.py

+167-11
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44

55

66
class Constants:
7-
networks = ["local", "finney", "test", "archive"]
7+
networks = ["local", "finney", "test", "archive", "rao", "dev"]
88
finney_entrypoint = "wss://entrypoint-finney.opentensor.ai:443"
99
finney_test_entrypoint = "wss://test.finney.opentensor.ai:443"
1010
archive_entrypoint = "wss://archive.chain.opentensor.ai:443"
11+
rao_entrypoint = "wss://rao.chain.opentensor.ai:443/"
12+
dev_entrypoint = "wss://dev.chain.opentensor.ai:443 "
1113
local_entrypoint = "ws://127.0.0.1:9444"
1214
network_map = {
1315
"finney": finney_entrypoint,
1416
"test": finney_test_entrypoint,
1517
"archive": archive_entrypoint,
1618
"local": local_entrypoint,
19+
"dev": dev_entrypoint,
20+
"rao": rao_entrypoint
1721
}
1822
delegates_detail_url = "https://raw.githubusercontent.com/opentensor/bittensor-delegates/main/public/delegates.json"
1923

@@ -206,24 +210,34 @@ class WalletValidationTypes(Enum):
206210
"StakeInfoRuntimeApi": {
207211
"methods": {
208212
"get_stake_info_for_coldkey": {
213+
"params": [{"name": "coldkey_account_vec", "type": "Vec<u8>"}],
214+
"type": "Vec<u8>",
215+
},
216+
"get_stake_info_for_coldkeys": {
209217
"params": [
210-
{
211-
"name": "coldkey_account_vec",
212-
"type": "Vec<u8>",
213-
},
218+
{"name": "coldkey_account_vecs", "type": "Vec<Vec<u8>>"}
214219
],
215220
"type": "Vec<u8>",
216221
},
217-
"get_stake_info_for_coldkeys": {
222+
"get_subnet_stake_info_for_coldkeys": {
218223
"params": [
219-
{
220-
"name": "coldkey_account_vecs",
221-
"type": "Vec<Vec<u8>>",
222-
},
224+
{"name": "coldkey_account_vecs", "type": "Vec<Vec<u8>>"},
225+
{"name": "netuid", "type": "u16"},
223226
],
224227
"type": "Vec<u8>",
225228
},
226-
},
229+
"get_subnet_stake_info_for_coldkey": {
230+
"params": [
231+
{"name": "coldkey_account_vec", "type": "Vec<u8>"},
232+
{"name": "netuid", "type": "u16"},
233+
],
234+
"type": "Vec<u8>",
235+
},
236+
"get_total_subnet_stake": {
237+
"params": [{"name": "netuid", "type": "u16"}],
238+
"type": "Vec<u8>",
239+
},
240+
}
227241
},
228242
"ValidatorIPRuntimeApi": {
229243
"methods": {
@@ -301,6 +315,148 @@ class WalletValidationTypes(Enum):
301315
},
302316
}
303317

318+
UNITS = [
319+
"\u03c4", # τ (tau, 0)
320+
"\u03b1", # α (alpha, 1)
321+
"\u03b2", # β (beta, 2)
322+
"\u03b3", # γ (gamma, 3)
323+
"\u03b4", # δ (delta, 4)
324+
"\u03b5", # ε (epsilon, 5)
325+
"\u03b6", # ζ (zeta, 6)
326+
"\u03b7", # η (eta, 7)
327+
"\u03b8", # θ (theta, 8)
328+
"\u03b9", # ι (iota, 9)
329+
"\u03ba", # κ (kappa, 10)
330+
"\u03bb", # λ (lambda, 11)
331+
"\u03bc", # μ (mu, 12)
332+
"\u03bd", # ν (nu, 13)
333+
"\u03be", # ξ (xi, 14)
334+
"\u03bf", # ο (omicron, 15)
335+
"\u03c0", # π (pi, 16)
336+
"\u03c1", # ρ (rho, 17)
337+
"\u03c3", # σ (sigma, 18)
338+
"t", # t (tau, 19)
339+
"\u03c5", # υ (upsilon, 20)
340+
"\u03c6", # φ (phi, 21)
341+
"\u03c7", # χ (chi, 22)
342+
"\u03c8", # ψ (psi, 23)
343+
"\u03c9", # ω (omega, 24)
344+
# Hebrew letters
345+
"\u05d0", # א (aleph, 25)
346+
"\u05d1", # ב (bet, 26)
347+
"\u05d2", # ג (gimel, 27)
348+
"\u05d3", # ד (dalet, 28)
349+
"\u05d4", # ה (he, 29)
350+
"\u05d5", # ו (vav, 30)
351+
"\u05d6", # ז (zayin, 31)
352+
"\u05d7", # ח (het, 32)
353+
"\u05d8", # ט (tet, 33)
354+
"\u05d9", # י (yod, 34)
355+
"\u05da", # ך (final kaf, 35)
356+
"\u05db", # כ (kaf, 36)
357+
"\u05dc", # ל (lamed, 37)
358+
"\u05dd", # ם (final mem, 38)
359+
"\u05de", # מ (mem, 39)
360+
"\u05df", # ן (final nun, 40)
361+
"\u05e0", # נ (nun, 41)
362+
"\u05e1", # ס (samekh, 42)
363+
"\u05e2", # ע (ayin, 43)
364+
"\u05e3", # ף (final pe, 44)
365+
"\u05e4", # פ (pe, 45)
366+
"\u05e5", # ץ (final tsadi, 46)
367+
"\u05e6", # צ (tsadi, 47)
368+
"\u05e7", # ק (qof, 48)
369+
"\u05e8", # ר (resh, 49)
370+
"\u05e9", # ש (shin, 50)
371+
"\u05ea", # ת (tav, 51)
372+
# Georgian Alphabet (Mkhedruli)
373+
"\u10d0", # ა (Ani, 97)
374+
"\u10d1", # ბ (Bani, 98)
375+
"\u10d2", # გ (Gani, 99)
376+
"\u10d3", # დ (Doni, 100)
377+
"\u10d4", # ე (Eni, 101)
378+
"\u10d5", # ვ (Vini, 102)
379+
# Armenian Alphabet
380+
"\u0531", # Ա (Ayp, 103)
381+
"\u0532", # Բ (Ben, 104)
382+
"\u0533", # Գ (Gim, 105)
383+
"\u0534", # Դ (Da, 106)
384+
"\u0535", # Ե (Ech, 107)
385+
"\u0536", # Զ (Za, 108)
386+
# "\u055e", # ՞ (Question mark, 109)
387+
# Runic Alphabet
388+
"\u16a0", # ᚠ (Fehu, wealth, 81)
389+
"\u16a2", # ᚢ (Uruz, strength, 82)
390+
"\u16a6", # ᚦ (Thurisaz, giant, 83)
391+
"\u16a8", # ᚨ (Ansuz, god, 84)
392+
"\u16b1", # ᚱ (Raidho, ride, 85)
393+
"\u16b3", # ᚲ (Kaunan, ulcer, 86)
394+
"\u16c7", # ᛇ (Eihwaz, yew, 87)
395+
"\u16c9", # ᛉ (Algiz, protection, 88)
396+
"\u16d2", # ᛒ (Berkanan, birch, 89)
397+
# Cyrillic Alphabet
398+
"\u0400", # Ѐ (Ie with grave, 110)
399+
"\u0401", # Ё (Io, 111)
400+
"\u0402", # Ђ (Dje, 112)
401+
"\u0403", # Ѓ (Gje, 113)
402+
"\u0404", # Є (Ukrainian Ie, 114)
403+
"\u0405", # Ѕ (Dze, 115)
404+
# Coptic Alphabet
405+
"\u2c80", # Ⲁ (Alfa, 116)
406+
"\u2c81", # ⲁ (Small Alfa, 117)
407+
"\u2c82", # Ⲃ (Vida, 118)
408+
"\u2c83", # ⲃ (Small Vida, 119)
409+
"\u2c84", # Ⲅ (Gamma, 120)
410+
"\u2c85", # ⲅ (Small Gamma, 121)
411+
# Arabic letters
412+
"\u0627", # ا (alef, 52)
413+
"\u0628", # ب (ba, 53)
414+
"\u062a", # ت (ta, 54)
415+
"\u062b", # ث (tha, 55)
416+
"\u062c", # ج (jeem, 56)
417+
"\u062d", # ح (ha, 57)
418+
"\u062e", # خ (kha, 58)
419+
"\u062f", # د (dal, 59)
420+
"\u0630", # ذ (dhal, 60)
421+
"\u0631", # ر (ra, 61)
422+
"\u0632", # ز (zay, 62)
423+
"\u0633", # س (seen, 63)
424+
"\u0634", # ش (sheen, 64)
425+
"\u0635", # ص (sad, 65)
426+
"\u0636", # ض (dad, 66)
427+
"\u0637", # ط (ta, 67)
428+
"\u0638", # ظ (dha, 68)
429+
"\u0639", # ع (ain, 69)
430+
"\u063a", # غ (ghain, 70)
431+
"\u0641", # ف (fa, 71)
432+
"\u0642", # ق (qaf, 72)
433+
"\u0643", # ك (kaf, 73)
434+
"\u0644", # ل (lam, 74)
435+
"\u0645", # م (meem, 75)
436+
"\u0646", # ن (noon, 76)
437+
"\u0647", # ه (ha, 77)
438+
"\u0648", # و (waw, 78)
439+
"\u0649", # ى (alef maksura, 79)
440+
"\u064a", # ي (ya, 80)
441+
# Ogham Alphabet
442+
"\u1680", #   (Space, 90)
443+
"\u1681", # ᚁ (Beith, birch, 91)
444+
"\u1682", # ᚂ (Luis, rowan, 92)
445+
"\u1683", # ᚃ (Fearn, alder, 93)
446+
"\u1684", # ᚄ (Sail, willow, 94)
447+
"\u1685", # ᚅ (Nion, ash, 95)
448+
"\u169b", # ᚛ (Forfeda, 96)
449+
# Brahmi Script TODO verify these https://discord.com/channels/799672011265015819/1176889593136693339/1288500713625878558
450+
"\u11000", # 𑀀 (A, 122)
451+
"\u11001", # 𑀁 (Aa, 123)
452+
"\u11002", # 𑀂 (I, 124)
453+
"\u11003", # 𑀃 (Ii, 125)
454+
"\u11005", # 𑀅 (U, 126)
455+
# Tifinagh Alphabet
456+
"\u2d30", # ⴰ (Ya, 127)
457+
"\u2d31", # ⴱ (Yab, 128)
458+
]
459+
304460
NETWORK_EXPLORER_MAP = {
305461
"opentensor": {
306462
"local": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",

bittensor_cli/src/bittensor/chain_data.py

+136
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,47 @@ def list_from_vec_u8(cls, vec_u8: bytes) -> list["SubnetInfo"]:
571571
)
572572
return result
573573

574+
@dataclass
575+
class SubnetInfoV2:
576+
"""Dataclass for subnet info."""
577+
netuid: int
578+
owner_ss58: str
579+
max_allowed_validators: int
580+
scaling_law_power: float
581+
subnetwork_n: int
582+
max_n: int
583+
blocks_since_epoch: int
584+
modality: int
585+
emission_value: float
586+
burn: Balance
587+
tao_locked: Balance
588+
hyperparameters: "SubnetHyperparameters"
589+
dynamic_pool: "DynamicPool"
590+
591+
@classmethod
592+
def from_vec_u8(cls, vec_u8: bytes) -> Optional["SubnetInfoV2"]:
593+
"""Returns a SubnetInfoV2 object from a ``vec_u8``."""
594+
if len(vec_u8) == 0:
595+
return None
596+
decoded = bt_decode.SubnetInfoV2.decode(vec_u8) # TODO fix values
597+
598+
if decoded is None:
599+
return None
600+
601+
return cls.fix_decoded_values(decoded)
602+
603+
@classmethod
604+
def list_from_vec_u8(cls, vec_u8: bytes) -> List["SubnetInfoV2"]:
605+
"""Returns a list of SubnetInfoV2 objects from a ``vec_u8``."""
606+
decoded = bt_decode.SubnetInfoV2.decode_vec(vec_u8) # TODO fix values
607+
608+
if decoded is None:
609+
return []
610+
611+
decoded = [cls.fix_decoded_values(d) for d in decoded]
612+
613+
return decoded
614+
574615

575616
custom_rpc_type_registry = {
576617
"types": {
@@ -597,6 +638,35 @@ def list_from_vec_u8(cls, vec_u8: bytes) -> list["SubnetInfo"]:
597638
["owner", "AccountId"],
598639
],
599640
},
641+
"DynamicPoolInfoV2": {
642+
"type": "struct",
643+
"type_mapping": [
644+
["netuid", "u16"],
645+
["alpha_issuance", "u64"],
646+
["alpha_outstanding", "u64"],
647+
["alpha_reserve", "u64"],
648+
["tao_reserve", "u64"],
649+
["k", "u128"],
650+
],
651+
},
652+
"SubnetInfoV2": {
653+
"type": "struct",
654+
"type_mapping": [
655+
["netuid", "u16"],
656+
["owner", "AccountId"],
657+
["max_allowed_validators", "u16"],
658+
["scaling_law_power", "u16"],
659+
["subnetwork_n", "u16"],
660+
["max_allowed_uids", "u16"],
661+
["blocks_since_last_step", "Compact<u32>"],
662+
["network_modality", "u16"],
663+
["emission_values", "Compact<u64>"],
664+
["burn", "Compact<u64>"],
665+
["tao_locked", "Compact<u64>"],
666+
["hyperparameters", "SubnetHyperparameters"],
667+
["dynamic_pool", "Option<DynamicPoolInfoV2>"],
668+
],
669+
},
600670
"DelegateInfo": {
601671
"type": "struct",
602672
"type_mapping": [
@@ -610,6 +680,16 @@ def list_from_vec_u8(cls, vec_u8: bytes) -> list["SubnetInfo"]:
610680
["total_daily_return", "Compact<u64>"],
611681
],
612682
},
683+
"DelegateInfoLight": {
684+
"type": "struct",
685+
"type_mapping": [
686+
["delegate_ss58", "AccountId"],
687+
["owner_ss58", "AccountId"],
688+
["take", "u16"],
689+
["owner_stake", "Compact<u64>"],
690+
["total_stake", "Compact<u64>"],
691+
],
692+
},
613693
"NeuronInfo": {
614694
"type": "struct",
615695
"type_mapping": [
@@ -688,6 +768,37 @@ def list_from_vec_u8(cls, vec_u8: bytes) -> list["SubnetInfo"]:
688768
["ip_type_and_protocol", "Compact<u8>"],
689769
],
690770
},
771+
"ScheduledColdkeySwapInfo": {
772+
"type": "struct",
773+
"type_mapping": [
774+
["old_coldkey", "AccountId"],
775+
["new_coldkey", "AccountId"],
776+
["arbitration_block", "Compact<u64>"],
777+
],
778+
},
779+
"SubnetState": {
780+
"type": "struct",
781+
"type_mapping": [
782+
["netuid", "Compact<u16>"],
783+
["hotkeys", "Vec<AccountId>"],
784+
["coldkeys", "Vec<AccountId>"],
785+
["active", "Vec<bool>"],
786+
["validator_permit", "Vec<bool>"],
787+
["pruning_score", "Vec<Compact<u16>>"],
788+
["last_update", "Vec<Compact<u64>>"],
789+
["emission", "Vec<Compact<u64>>"],
790+
["dividends", "Vec<Compact<u16>>"],
791+
["incentives", "Vec<Compact<u16>>"],
792+
["consensus", "Vec<Compact<u16>>"],
793+
["trust", "Vec<Compact<u16>>"],
794+
["rank", "Vec<Compact<u16>>"],
795+
["block_at_registration", "Vec<Compact<u64>>"],
796+
["local_stake", "Vec<Compact<u64>>"],
797+
["global_stake", "Vec<Compact<u64>>"],
798+
["stake_weight", "Vec<Compact<u16>>"],
799+
["emission_history", "Vec<Vec<Compact<u64>>>"],
800+
],
801+
},
691802
"StakeInfo": {
692803
"type": "struct",
693804
"type_mapping": [
@@ -696,6 +807,31 @@ def list_from_vec_u8(cls, vec_u8: bytes) -> list["SubnetInfo"]:
696807
["stake", "Compact<u64>"],
697808
],
698809
},
810+
"DynamicInfo": {
811+
"type": "struct",
812+
"type_mapping": [
813+
["owner", "AccountId"],
814+
["netuid", "Compact<u16>"],
815+
["tempo", "Compact<u16>"],
816+
["last_step", "Compact<u64>"],
817+
["blocks_since_last_step", "Compact<u64>"],
818+
["emission", "Compact<u64>"],
819+
["alpha_in", "Compact<u64>"],
820+
["alpha_out", "Compact<u64>"],
821+
["tao_in", "Compact<u64>"],
822+
["total_locked", "Compact<u64>"],
823+
["owner_locked", "Compact<u64>"],
824+
],
825+
},
826+
"SubstakeElements": {
827+
"type": "struct",
828+
"type_mapping": [
829+
["hotkey", "AccountId"],
830+
["coldkey", "AccountId"],
831+
["netuid", "Compact<u16>"],
832+
["stake", "Compact<u64>"],
833+
],
834+
},
699835
"SubnetHyperparameters": {
700836
"type": "struct",
701837
"type_mapping": [

0 commit comments

Comments
 (0)