diff --git a/common/protob/messages-tron.proto b/common/protob/messages-tron.proto index 625c53e52f..c47b57d855 100644 --- a/common/protob/messages-tron.proto +++ b/common/protob/messages-tron.proto @@ -105,7 +105,8 @@ message TronSignTx { optional uint64 balance = 3; optional string receiver_address = 4; } - + message TronCancelAllUnfreezeV2Contract { + } // Vote Witness Contract message TronVoteWitnessContract { message Vote { @@ -126,6 +127,7 @@ message TronSignTx { optional TronWithdrawExpireUnfreezeContract withdraw_expire_unfreeze_contract = 56; optional TronDelegateResourceContract delegate_resource_contract = 57; optional TronUnDelegateResourceContract undelegate_resource_contract = 58; + optional TronCancelAllUnfreezeV2Contract cancel_all_unfreeze_v2_contract = 59; optional bytes provider = 3; optional bytes contract_name = 5; optional uint32 permission_id = 6; diff --git a/core/embed/extmod/modtrezorio/modtrezorio-camera.h b/core/embed/extmod/modtrezorio/modtrezorio-camera.h index 09938407c7..7f60e33929 100644 --- a/core/embed/extmod/modtrezorio/modtrezorio-camera.h +++ b/core/embed/extmod/modtrezorio/modtrezorio-camera.h @@ -32,7 +32,7 @@ STATIC mp_obj_t mod_trezorio_camera_scan_qrcode(mp_obj_t x, mp_obj_t y) { uint32_t pos_x = trezor_obj_get_uint(x); uint32_t pos_y = trezor_obj_get_uint(y); - uint8_t qr_code[512] = {0}; + uint8_t qr_code[1024] = {0}; uint32_t qr_len; diff --git a/core/src/apps/tron/layout.py b/core/src/apps/tron/layout.py index 74e8a45986..5f6ec11fb2 100644 --- a/core/src/apps/tron/layout.py +++ b/core/src/apps/tron/layout.py @@ -235,6 +235,15 @@ def require_confirm_undelegate( ) +def require_confirm_cancel_all_unfreeze_v2( + ctx: Context, + signer: str, +) -> Awaitable[None]: + from trezor.ui.layouts.lvgl import confirm_tron_unfreeze + + return confirm_tron_unfreeze(ctx, "Cancel All UnStaking", signer, None, None) + + def require_confirm_vote_witness( ctx: Context, signer: str, diff --git a/core/src/apps/tron/serialize.py b/core/src/apps/tron/serialize.py index 9a98df5407..8cc8c7741c 100644 --- a/core/src/apps/tron/serialize.py +++ b/core/src/apps/tron/serialize.py @@ -214,6 +214,11 @@ def pack_contract(contract, owner_address): cmessage, base58.decode_check(contract.undelegate_resource_contract.receiver_address), ) + elif contract.cancel_all_unfreeze_v2_contract: + write_varint(retc, 59) + api = "CancelAllUnfreezeV2Contract" + add_field(cmessage, 1, TYPE_LEN) + write_bytes_with_length(cmessage, base58.decode_check(owner_address)) else: raise ValueError("Invalid contract type") diff --git a/core/src/apps/tron/sign_tx.py b/core/src/apps/tron/sign_tx.py index c2bf43b9ea..0f5292314e 100644 --- a/core/src/apps/tron/sign_tx.py +++ b/core/src/apps/tron/sign_tx.py @@ -179,6 +179,11 @@ async def _require_confirm_by_type(ctx, transaction, owner_address): contract.undelegate_resource_contract.receiver_address, None, ) + elif contract.cancel_all_unfreeze_v2_contract: + await layout.require_confirm_cancel_all_unfreeze_v2( + ctx, + owner_address, + ) elif contract.vote_witness_contract: vote_contract = contract.vote_witness_contract await layout.require_confirm_vote_witness( diff --git a/core/src/trezor/lvglui/scrs/template.py b/core/src/trezor/lvglui/scrs/template.py index 4d0d5f0056..c6dabe41a6 100644 --- a/core/src/trezor/lvglui/scrs/template.py +++ b/core/src/trezor/lvglui/scrs/template.py @@ -4320,45 +4320,47 @@ def __init__( sender, ) self.group_directions.add_dummy() - - self.group_more = ContainerFlexCol( - self.container, None, padding_row=0, no_align=True - ) - self.item_group_header = CardHeader( - self.group_more, _(i18n_keys.FORM__MORE), "A:/res/group-icon-more.png" - ) - if resource is not None: - self.item_body_resource = DisplayItem( - self.group_more, _(i18n_keys.LIST_KEY__RESOURCE_COLON), resource + if any((resource, balance, receiver, duration, lock)): + self.group_more = ContainerFlexCol( + self.container, None, padding_row=0, no_align=True + ) + self.item_group_header = CardHeader( + self.group_more, _(i18n_keys.FORM__MORE), "A:/res/group-icon-more.png" ) - if balance: - if is_freeze: - self.item_body_freeze_balance = DisplayItem( + if resource is not None: + self.item_body_resource = DisplayItem( + self.group_more, _(i18n_keys.LIST_KEY__RESOURCE_COLON), resource + ) + if balance: + if is_freeze: + self.item_body_freeze_balance = DisplayItem( + self.group_more, + _(i18n_keys.LIST_KEY__FROZEN_BALANCE_COLON), + balance, + ) + else: + self.item_body_balance = DisplayItem( + self.group_more, + _(i18n_keys.LIST_KEY__AMOUNT__COLON), + balance, + ) + if duration: + self.item_body_duration = DisplayItem( self.group_more, - _(i18n_keys.LIST_KEY__FROZEN_BALANCE_COLON), - balance, + _(i18n_keys.LIST_KEY__FROZEN_DURATION_COLON), + duration, ) - else: - self.item_body_balance = DisplayItem( + if receiver is not None: + self.item_body_receiver = DisplayItem( self.group_more, - _(i18n_keys.LIST_KEY__AMOUNT__COLON), - balance, + _(i18n_keys.LIST_KEY__RECEIVER_ADDRESS_COLON), + receiver, ) - if duration: - self.item_body_duration = DisplayItem( - self.group_more, - _(i18n_keys.LIST_KEY__FROZEN_DURATION_COLON), - duration, - ) - if receiver is not None: - self.item_body_receiver = DisplayItem( - self.group_more, _(i18n_keys.LIST_KEY__RECEIVER_ADDRESS_COLON), receiver - ) - if lock is not None: - self.item_body_lock = DisplayItem( - self.group_more, _(i18n_keys.LIST_KEY__LOCK_COLON), lock - ) - self.group_more.add_dummy() + if lock is not None: + self.item_body_lock = DisplayItem( + self.group_more, _(i18n_keys.LIST_KEY__LOCK_COLON), lock + ) + self.group_more.add_dummy() class TronVoteWitness(FullSizeWindow): diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index b12c843155..ea5956d382 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -9286,6 +9286,7 @@ class TronContract(protobuf.MessageType): withdraw_expire_unfreeze_contract: "TronWithdrawExpireUnfreezeContract | None" delegate_resource_contract: "TronDelegateResourceContract | None" undelegate_resource_contract: "TronUnDelegateResourceContract | None" + cancel_all_unfreeze_v2_contract: "TronCancelAllUnfreezeV2Contract | None" provider: "bytes | None" contract_name: "bytes | None" permission_id: "int | None" @@ -9304,6 +9305,7 @@ def __init__( withdraw_expire_unfreeze_contract: "TronWithdrawExpireUnfreezeContract | None" = None, delegate_resource_contract: "TronDelegateResourceContract | None" = None, undelegate_resource_contract: "TronUnDelegateResourceContract | None" = None, + cancel_all_unfreeze_v2_contract: "TronCancelAllUnfreezeV2Contract | None" = None, provider: "bytes | None" = None, contract_name: "bytes | None" = None, permission_id: "int | None" = None, @@ -9478,6 +9480,12 @@ def __init__( def is_type_of(cls, msg: Any) -> TypeGuard["TronUnDelegateResourceContract"]: return isinstance(msg, cls) + class TronCancelAllUnfreezeV2Contract(protobuf.MessageType): + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["TronCancelAllUnfreezeV2Contract"]: + return isinstance(msg, cls) + class TronVoteWitnessContract(protobuf.MessageType): votes: "list[Vote]" support: "bool | None" diff --git a/core/src/trezor/qr.py b/core/src/trezor/qr.py index 351fc6ae9a..e7a336d3b8 100644 --- a/core/src/trezor/qr.py +++ b/core/src/trezor/qr.py @@ -214,7 +214,14 @@ async def camear_scan(): camera.stop() # await qr_task.callback_finish() break - qr_data = camera.scan_qrcode(80, 180) + try: + qr_data = camera.scan_qrcode(80, 180) + except Exception as e: + if __debug__: + print(f"scan qrcode error: {e}") + await callback_obj.error_feedback() + await loop.sleep(100) + continue if qr_data: if __debug__: print(qr_data.decode("utf-8")) diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 3f3b7e9507..c7edd1620b 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -11499,6 +11499,7 @@ class TronContract(protobuf.MessageType): 56: protobuf.Field("withdraw_expire_unfreeze_contract", "TronWithdrawExpireUnfreezeContract", repeated=False, required=False), 57: protobuf.Field("delegate_resource_contract", "TronDelegateResourceContract", repeated=False, required=False), 58: protobuf.Field("undelegate_resource_contract", "TronUnDelegateResourceContract", repeated=False, required=False), + 59: protobuf.Field("cancel_all_unfreeze_v2_contract", "TronCancelAllUnfreezeV2Contract", repeated=False, required=False), 3: protobuf.Field("provider", "bytes", repeated=False, required=False), 5: protobuf.Field("contract_name", "bytes", repeated=False, required=False), 6: protobuf.Field("permission_id", "uint32", repeated=False, required=False), @@ -11518,6 +11519,7 @@ def __init__( withdraw_expire_unfreeze_contract: Optional["TronWithdrawExpireUnfreezeContract"] = None, delegate_resource_contract: Optional["TronDelegateResourceContract"] = None, undelegate_resource_contract: Optional["TronUnDelegateResourceContract"] = None, + cancel_all_unfreeze_v2_contract: Optional["TronCancelAllUnfreezeV2Contract"] = None, provider: Optional["bytes"] = None, contract_name: Optional["bytes"] = None, permission_id: Optional["int"] = None, @@ -11533,6 +11535,7 @@ def __init__( self.withdraw_expire_unfreeze_contract = withdraw_expire_unfreeze_contract self.delegate_resource_contract = delegate_resource_contract self.undelegate_resource_contract = undelegate_resource_contract + self.cancel_all_unfreeze_v2_contract = cancel_all_unfreeze_v2_contract self.provider = provider self.contract_name = contract_name self.permission_id = permission_id @@ -11716,6 +11719,10 @@ def __init__( self.receiver_address = receiver_address +class TronCancelAllUnfreezeV2Contract(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + + class TronVoteWitnessContract(protobuf.MessageType): MESSAGE_WIRE_TYPE = None FIELDS = {