@@ -13,7 +13,7 @@ async def set_children_extrinsic(
13
13
netuid : int ,
14
14
children : list [tuple [float , str ]],
15
15
wait_for_inclusion : bool = True ,
16
- wait_for_finalization : bool = True ,
16
+ wait_for_finalization : bool = False ,
17
17
raise_error : bool = False ,
18
18
period : Optional [int ] = None ,
19
19
):
@@ -55,37 +55,46 @@ async def set_children_extrinsic(
55
55
if not unlock .success :
56
56
return False , unlock .message
57
57
58
- call = await subtensor .substrate .compose_call (
59
- call_module = "SubtensorModule" ,
60
- call_function = "set_children" ,
61
- call_params = {
62
- "children" : [
63
- (
64
- float_to_u64 (proportion ),
65
- child_hotkey ,
66
- )
67
- for proportion , child_hotkey in children
68
- ],
69
- "hotkey" : hotkey ,
70
- "netuid" : netuid ,
71
- },
72
- )
73
-
74
- return await subtensor .sign_and_send_extrinsic (
75
- call = call ,
76
- wallet = wallet ,
77
- wait_for_inclusion = wait_for_inclusion ,
78
- wait_for_finalization = wait_for_finalization ,
79
- raise_error = raise_error ,
80
- period = period ,
81
- )
58
+ async with subtensor .substrate as substrate :
59
+ call = await substrate .compose_call (
60
+ call_module = "SubtensorModule" ,
61
+ call_function = "set_children" ,
62
+ call_params = {
63
+ "children" : [
64
+ (
65
+ float_to_u64 (proportion ),
66
+ child_hotkey ,
67
+ )
68
+ for proportion , child_hotkey in children
69
+ ],
70
+ "hotkey" : hotkey ,
71
+ "netuid" : netuid ,
72
+ },
73
+ )
74
+
75
+ success , message = await subtensor .sign_and_send_extrinsic (
76
+ call = call ,
77
+ wallet = wallet ,
78
+ wait_for_inclusion = wait_for_inclusion ,
79
+ wait_for_finalization = wait_for_finalization ,
80
+ raise_error = raise_error ,
81
+ period = period ,
82
+ )
83
+
84
+ if not wait_for_finalization and not wait_for_inclusion :
85
+ return True , message
86
+
87
+ if success :
88
+ return True , "Success with `set_children_extrinsic` response."
89
+
90
+ return True , message
82
91
83
92
84
93
async def root_set_pending_childkey_cooldown_extrinsic (
85
94
subtensor : "AsyncSubtensor" ,
86
95
wallet : "Wallet" ,
87
96
cooldown : int ,
88
- wait_for_inclusion : bool = False ,
97
+ wait_for_inclusion : bool = True ,
89
98
wait_for_finalization : bool = False ,
90
99
period : Optional [int ] = None ,
91
100
) -> tuple [bool , str ]:
@@ -97,22 +106,34 @@ async def root_set_pending_childkey_cooldown_extrinsic(
97
106
if not unlock .success :
98
107
return False , unlock .message
99
108
100
- call = await subtensor .substrate .compose_call (
101
- call_module = "SubtensorModule" ,
102
- call_function = "set_pending_childkey_cooldown" ,
103
- call_params = {"cooldown" : cooldown },
104
- )
105
-
106
- sudo_call = await subtensor .substrate .compose_call (
107
- call_module = "Sudo" ,
108
- call_function = "sudo" ,
109
- call_params = {"call" : call },
110
- )
111
-
112
- return await subtensor .sign_and_send_extrinsic (
113
- call = sudo_call ,
114
- wallet = wallet ,
115
- wait_for_inclusion = wait_for_inclusion ,
116
- wait_for_finalization = wait_for_finalization ,
117
- period = period ,
118
- )
109
+ async with subtensor .substrate as substrate :
110
+ call = await substrate .compose_call (
111
+ call_module = "SubtensorModule" ,
112
+ call_function = "set_pending_childkey_cooldown" ,
113
+ call_params = {"cooldown" : cooldown },
114
+ )
115
+
116
+ sudo_call = await substrate .compose_call (
117
+ call_module = "Sudo" ,
118
+ call_function = "sudo" ,
119
+ call_params = {"call" : call },
120
+ )
121
+
122
+ success , message = await subtensor .sign_and_send_extrinsic (
123
+ call = sudo_call ,
124
+ wallet = wallet ,
125
+ wait_for_inclusion = wait_for_inclusion ,
126
+ wait_for_finalization = wait_for_finalization ,
127
+ period = period ,
128
+ )
129
+
130
+ if not wait_for_finalization and not wait_for_inclusion :
131
+ return True , message
132
+
133
+ if success :
134
+ return (
135
+ True ,
136
+ "Success with `root_set_pending_childkey_cooldown_extrinsic` response." ,
137
+ )
138
+
139
+ return True , message
0 commit comments