1313
1414from . import ICON , PRIMARY_COLOR
1515from .helper import INTENT_BYTES , benfen_address_from_pubkey , try_convert_to_bfc_address
16- from .layout import require_confirm_fee , require_show_overview
17- from .tx_parser import TransactionParser
1816
1917
2018async def process_transaction (
@@ -23,76 +21,10 @@ async def process_transaction(
2321 tx_bytes : bytes ,
2422 coin_type : bytes ,
2523) -> bytes :
26- parser = TransactionParser ()
27-
2824 intent = tx_bytes [:3 ]
2925 if INTENT_BYTES != intent :
3026 raise wire .DataError ("Invalid raw tx" )
31-
32- if coin_type :
33- try :
34- if not all (c < 128 for c in coin_type ):
35- await confirm_blind_sign_common (ctx , address , tx_bytes )
36- return blake2b (data = tx_bytes , outlen = 32 ).digest ()
37- currency_symbol = coin_type .decode ("ascii" )
38- if currency_symbol and "::" in currency_symbol :
39- currency_symbol = currency_symbol .split ("::" )[- 1 ]
40- ALLOWED_TOKENS = {
41- "BJPY" ,
42- "BUSD" ,
43- "LONG" ,
44- "BF_USDC" ,
45- "BF_USDT" ,
46- "BFC" ,
47- "BAUD" ,
48- "BCAD" ,
49- "BEUR" ,
50- "BIDR" ,
51- "BINR" ,
52- "BKRW" ,
53- "BMXN" ,
54- }
55- if currency_symbol not in ALLOWED_TOKENS :
56- currency_symbol = "UNKNOWN"
57- except UnicodeDecodeError :
58- await confirm_blind_sign_common (ctx , address , tx_bytes )
59- return blake2b (data = tx_bytes , outlen = 32 ).digest ()
60- else :
61- await confirm_blind_sign_common (ctx , address , tx_bytes )
62- return blake2b (data = tx_bytes , outlen = 32 ).digest ()
63-
64- parsed_tx = parser .parse_tx (tx_bytes )
65- if parsed_tx is None :
66- await confirm_blind_sign_common (ctx , address , tx_bytes )
67- return blake2b (data = tx_bytes , outlen = 32 ).digest ()
68-
69- is_valid = validate_transaction (parsed_tx )
70-
71- if is_valid :
72- (
73- amount_raw ,
74- recipient_bfc ,
75- sender_bfc ,
76- max_gas_fee ,
77- ) = parse_transaction (parsed_tx )
78- show_details = await require_show_overview (
79- ctx ,
80- recipient_bfc ,
81- amount_raw ,
82- currency_symbol ,
83- )
84- if show_details :
85- await require_confirm_fee (
86- ctx ,
87- from_address = sender_bfc ,
88- to_address = recipient_bfc ,
89- value = amount_raw ,
90- gas_price = max_gas_fee ,
91- gas_budget = max_gas_fee ,
92- currency_symbol = currency_symbol ,
93- )
94- else :
95- await confirm_blind_sign_common (ctx , address , tx_bytes )
27+ await confirm_blind_sign_common (ctx , address , tx_bytes )
9628 return blake2b (data = tx_bytes , outlen = 32 ).digest ()
9729
9830
0 commit comments