Skip to content

Commit

Permalink
optimizing code
Browse files Browse the repository at this point in the history
  • Loading branch information
guowei0105 committed Dec 26, 2024
1 parent fcf6fa8 commit e41d7d9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/SConscript.firmware
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ USE_THD89 = ARGUMENTS.get('USE_THD89', '0')
FEATURE_FLAGS = {
"RDI": True,
"SECP256K1_ZKP": True, # required for trezor.crypto.curve.bip340 (BIP340/Taproot)
"SYSTEM_VIEW": True,
"SYSTEM_VIEW": False,
}

CCFLAGS_MOD = ''
Expand Down
3 changes: 1 addition & 2 deletions core/src/apps/benfen/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ async def require_show_overview(
) -> bool:
from trezor.strings import strip_amount

result = await should_show_details(
return await should_show_details(
ctx,
title=_(i18n_keys.TITLE__SEND_MULTILINE).format(
strip_amount(format_benfen_amount(value, currency_symbol))[0]
),
address=to_addr,
br_code=ButtonRequestType.SignTx,
)
return result


async def require_confirm_fee(
Expand Down
5 changes: 4 additions & 1 deletion core/src/apps/benfen/sign_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@


async def process_transaction(
ctx, address: str, tx_bytes: bytes, coin_type: bytes
ctx,
address: str,
tx_bytes: bytes,
coin_type: bytes,
) -> bytes:
parser = TransactionParser()

Expand Down
10 changes: 5 additions & 5 deletions core/src/apps/benfen/tx_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def read_commands(self) -> list | None:
return commands


def parse_transaction_inputs(parser):
def parse_transaction_inputs(parser) -> list[ParsedInput] | None:
input_count = parser.read_u8()

inputs = []
Expand Down Expand Up @@ -312,7 +312,7 @@ def parse_transaction_inputs(parser):
return inputs


def parse_gas_data(parser):
def parse_gas_data(parser) -> dict | None:
payment_count = parser.read_u8()
payments = []
for _ in range(payment_count):
Expand All @@ -330,7 +330,7 @@ def parse_gas_data(parser):
return {"payment": payments, "owner": owner, "price": price, "budget": budget}


def parse_transaction_expiration(parser):
def parse_transaction_expiration(parser) -> dict | None:
expiration_type = parser.read_u8()
if expiration_type == 0:
return {"type": "None", "value": None}
Expand All @@ -341,7 +341,7 @@ def parse_transaction_expiration(parser):
return None


def parse_transaction(hex_data):
def parse_transaction(hex_data) -> dict | None:
try:
data = binascii.unhexlify(hex_data)
parser = BCSParser(data)
Expand Down Expand Up @@ -388,7 +388,7 @@ def parse_transaction(hex_data):


class TransactionParser:
def parse_tx(self, tx_hex):
def parse_tx(self, tx_hex) -> dict | None:
try:
if isinstance(tx_hex, bytes):
tx_hex = binascii.hexlify(tx_hex).decode()
Expand Down

0 comments on commit e41d7d9

Please sign in to comment.