1- import scalecodec # type: ignore
21from dataclasses import dataclass
32from typing import List , Optional
3+ import scalecodec # type: ignore
44
55sign_tx_start_req_obj = scalecodec .base .RuntimeConfiguration ().create_scale_object (
66 "SignTxStartReq"
@@ -19,16 +19,16 @@ class TxInputSignatureResponse:
1919
2020 @staticmethod
2121 def from_data (response : bytes ):
22- response = decode_response_variant (response , "TxInputSignature" )
22+ decoded_response = decode_response_variant (response , "TxInputSignature" )
2323
24- signature = bytes .fromhex (response ["signature" ][2 :])
24+ signature = bytes .fromhex (decoded_response ["signature" ][2 :])
2525 assert len (signature ) == 64
2626
2727 return TxInputSignatureResponse (
2828 signature = signature ,
29- input_idx = response ["input_idx" ],
30- multisig_idx = response ["multisig_idx" ],
31- has_next = response ["has_next" ],
29+ input_idx = decoded_response ["input_idx" ],
30+ multisig_idx = decoded_response ["multisig_idx" ],
31+ has_next = decoded_response ["has_next" ],
3232 )
3333
3434
@@ -68,11 +68,11 @@ class Transaction:
6868
6969 def expected_sig_indices (self ) -> set [TxInputSignatureIndices ]:
7070 result = set ()
71- for input_idx , input in enumerate (self .inputs ):
72- input_data = input .get ("ProcessInput" )
71+ for input_idx , inp in enumerate (self .inputs ):
72+ input_data = inp .get ("ProcessInput" )
7373 assert (
7474 input_data is not None
75- ), f"Transaction input is not a ProcessInput request: { input !r} "
75+ ), f"Transaction input is not a ProcessInput request: { inp !r} "
7676
7777 for addr in input_data ["addresses" ]:
7878 multisig_idx = addr ["multisig_idx" ]
@@ -85,21 +85,21 @@ def expected_sig_indices(self) -> set[TxInputSignatureIndices]:
8585 return result
8686
8787
88- def decode_response (response : bytes ):
88+ def decode_response (response : bytes ) -> dict :
8989 response_bytes = scalecodec .base .ScaleBytes (response )
9090 response_obj = scalecodec .base .RuntimeConfiguration ().create_scale_object (
9191 "Response" , data = response_bytes
9292 )
9393 return response_obj .decode ()
9494
9595
96- def decode_response_variant (response : bytes , expected_variant : str ):
97- response = decode_response (response )
96+ def decode_response_variant (response : bytes , expected_variant : str ) -> dict :
97+ decoded_response = decode_response (response )
9898
9999 assert (
100- isinstance (response , dict )
101- and len (response ) == 1
102- and expected_variant in response
103- ), f"Expecting a dict with a single key '{ expected_variant } ', but got: { response !r} "
100+ isinstance (decoded_response , dict )
101+ and len (decoded_response ) == 1
102+ and expected_variant in decoded_response
103+ ), f"Expecting a dict with a single key '{ expected_variant } ', but got: { decoded_response !r} "
104104
105- return response [expected_variant ]
105+ return decoded_response [expected_variant ]
0 commit comments