@@ -27,38 +27,48 @@ async def async_sign_and_send_with_nonce(
27
27
wait_for_inclusion : bool ,
28
28
wait_for_finalization : bool ,
29
29
period : Optional [int ] = None ,
30
+ nonce_key : str = "hotkey" ,
30
31
):
31
32
"""
32
- Signs an extrinsic call with the wallet hotkey, adding an optional era for period
33
+ Signs an extrinsic call with the wallet keypair (default hotkey) , adding an optional era for period
33
34
"""
34
- next_nonce = await subtensor .substrate .get_account_next_index (
35
- wallet .hotkey .ss58_address
36
- )
35
+ keypair = getattr (wallet , nonce_key )
36
+ next_nonce = await subtensor .substrate .get_account_next_index (keypair .ss58_address )
37
37
38
38
extrinsic_data = {"call" : call , "keypair" : wallet .hotkey , "nonce" : next_nonce }
39
39
if period is not None :
40
40
extrinsic_data ["era" ] = {"period" : period }
41
41
42
42
extrinsic = await subtensor .substrate .create_signed_extrinsic (** extrinsic_data )
43
- response = await subtensor .substrate .submit_extrinsic (
44
- extrinsic = extrinsic ,
45
- wait_for_inclusion = wait_for_inclusion ,
46
- wait_for_finalization = wait_for_finalization ,
47
- )
48
43
49
- if not wait_for_finalization and not wait_for_inclusion :
50
- return True , None
44
+ try :
45
+ response = await subtensor .substrate .submit_extrinsic (
46
+ extrinsic = extrinsic ,
47
+ wait_for_inclusion = wait_for_inclusion ,
48
+ wait_for_finalization = wait_for_finalization ,
49
+ )
51
50
52
- if await response . is_success :
53
- return True , None
51
+ if not wait_for_finalization and not wait_for_inclusion :
52
+ return True , None
54
53
55
- return False , format_error_message (await response .error_message )
54
+ if await response .is_success :
55
+ return True , None
56
+
57
+ return False , format_error_message (await response .error_message )
58
+ except SubstrateRequestException as e :
59
+ return False , format_error_message (e )
56
60
57
61
58
62
def sign_and_send_with_nonce (
59
- subtensor : "Subtensor" , call , wallet , wait_for_inclusion , wait_for_finalization
63
+ subtensor : "Subtensor" ,
64
+ call ,
65
+ wallet ,
66
+ wait_for_inclusion ,
67
+ wait_for_finalization ,
68
+ nonce_key : str = "hotkey" ,
60
69
):
61
- next_nonce = subtensor .substrate .get_account_next_index (wallet .hotkey .ss58_address )
70
+ keypair = getattr (wallet , nonce_key )
71
+ next_nonce = subtensor .substrate .get_account_next_index (keypair .ss58_address )
62
72
extrinsic = subtensor .substrate .create_signed_extrinsic (
63
73
call = call ,
64
74
keypair = wallet .hotkey ,
0 commit comments