2222
2323CLA : int = 0xE1
2424
25+ @dataclass
26+ class ReviewTransaction :
27+ transaction : Transaction
28+ has_command_input : bool
29+ review_custom_screen_text : str
2530
2631@dataclass
2732class SignTxStep :
@@ -65,8 +70,8 @@ class InsType(IntEnum):
6570class Errors (IntEnum ):
6671 SW_DENY = 0x6985
6772 SW_CLA_NOT_SUPPORTED = 0x6E00
68- SW_INS_NOT_SUPPORTED = 0x6D00
69- SW_WRONG_P1P2 = 0x6B00
73+ SW_INS_NOT_SUPPORTED = 0x6E01
74+ SW_WRONG_P1P2 = 0x6E02
7075 SW_WRONG_APDU_LENGTH = 0x6E03
7176
7277 SW_WRONG_RESPONSE_LENGTH = 0xB000
@@ -137,11 +142,19 @@ def sign_message(
137142
138143 for chunk in chunks [:- 1 ]:
139144 self .backend .exchange (
140- cla = CLA , ins = InsType .SIGN_MESSAGE , p1 = SignMessageP1 .P1_NEXT , p2 = P2 .P2_MORE , data = chunk
145+ cla = CLA ,
146+ ins = InsType .SIGN_MESSAGE ,
147+ p1 = SignMessageP1 .P1_NEXT ,
148+ p2 = P2 .P2_MORE ,
149+ data = chunk
141150 )
142151
143152 with self .backend .exchange_async (
144- cla = CLA , ins = InsType .SIGN_MESSAGE , p1 = SignMessageP1 .P1_NEXT , p2 = P2 .P2_LAST , data = chunks [- 1 ]
153+ cla = CLA ,
154+ ins = InsType .SIGN_MESSAGE ,
155+ p1 = SignMessageP1 .P1_NEXT ,
156+ p2 = P2 .P2_LAST ,
157+ data = chunks [- 1 ]
145158 ) as response :
146159 yield response
147160
@@ -202,7 +215,7 @@ def sign_tx(self, transaction: Transaction) -> Generator[SignTxStep, None, None]
202215 ):
203216 kind = "start"
204217 yield SignTxStep (kind = kind , index = 0 )
205-
218+
206219
207220 # ---- OUTPUTS ----
208221 print ("streaming outputs" )
@@ -301,7 +314,17 @@ def pack_derivation_path(derivation_path: str) -> bytes:
301314 return path_obj .encode (path ).data
302315
303316
304- def sign_tx_review (client , device , navigator , scenario_navigator , transaction , has_command_input , review_custom_screen_text ):
317+ def sign_tx_review (
318+ client ,
319+ device ,
320+ navigator ,
321+ scenario_navigator ,
322+ review_transaction : ReviewTransaction ,
323+ ):
324+ transaction = review_transaction .transaction
325+ has_command_input = review_transaction .has_command_input
326+ review_custom_screen_text = review_transaction .review_custom_screen_text
327+
305328 start_idx = 0
306329 if not device .is_nano :
307330 instruction = NavInsID .SWIPE_CENTER_TO_LEFT
@@ -370,7 +393,11 @@ def sign_tx_review(client, device, navigator, scenario_navigator, transaction, h
370393 start_idx += 10
371394
372395 elif step .kind == "final" :
373- scenario = NavigationScenarioData (scenario_navigator .device , scenario_navigator .backend , UseCase .TX_REVIEW , True )
396+ scenario = NavigationScenarioData (
397+ scenario_navigator .device ,
398+ scenario_navigator .backend ,
399+ UseCase .TX_REVIEW ,
400+ True )
374401 navigator .navigate_until_text_and_compare (
375402 navigate_instruction = scenario .navigation ,
376403 validation_instructions = scenario .validation ,
@@ -386,4 +413,4 @@ def sign_tx_review(client, device, navigator, scenario_navigator, transaction, h
386413
387414 assert len (responses ) == len (transaction .inputs )
388415 for response in responses :
389- assert len (response ) == TX_RESPONSE_SIZE
416+ assert len (response ) == TX_RESPONSE_SIZE
0 commit comments