diff --git a/common/protob/messages-ton.proto b/common/protob/messages-ton.proto index 5f4c4d431..450e1bbf8 100644 --- a/common/protob/messages-ton.proto +++ b/common/protob/messages-ton.proto @@ -56,17 +56,18 @@ message TonSignMessage { optional uint64 jetton_amount = 6; // jetton value (by nanojetton) optional uint64 fwd_fee = 7 [default=0]; // toncoin is needed to transfer notification message optional string comment = 8; // message comment - optional uint32 mode = 9 [default=3]; // message modes - required uint32 seqno = 10; // message sequence number - required uint64 expire_at = 11; // message expiration time - optional TonWalletVersion wallet_version = 12 [default=V4R2]; // ton wallet version - optional uint32 wallet_id = 13 [default=698983191]; // 698983191 is the default subwallet_id value - optional TonWorkChain workchain = 14 [default=BASECHAIN]; // 0: BaseChain, 1: MasterChain - optional bool is_bounceable = 15 [default=false]; // bounceable flag - optional bool is_testnet_only = 16 [default=false]; // testnet only flag - repeated string ext_destination = 17; - repeated uint64 ext_ton_amount = 18; - repeated string ext_payload = 19; + optional bool is_raw_data = 9 [default=false]; // raw data flag + optional uint32 mode = 10 [default=3]; // message modes + required uint32 seqno = 11; // message sequence number + required uint64 expire_at = 12; // message expiration time + optional TonWalletVersion wallet_version = 13 [default=V4R2]; // ton wallet version + optional uint32 wallet_id = 14 [default=698983191]; // 698983191 is the default subwallet_id value + optional TonWorkChain workchain = 15 [default=BASECHAIN]; // 0: BaseChain, 1: MasterChain + optional bool is_bounceable = 16 [default=false]; // bounceable flag + optional bool is_testnet_only = 17 [default=false]; // testnet only flag + repeated string ext_destination = 18; + repeated uint64 ext_ton_amount = 19; + repeated string ext_payload = 20; } /** diff --git a/core/src/apps/ton/layout.py b/core/src/apps/ton/layout.py index 2c1420cd1..9a0342200 100644 --- a/core/src/apps/ton/layout.py +++ b/core/src/apps/ton/layout.py @@ -23,6 +23,7 @@ def require_confirm_fee( gas_limit: int = 0, token: tokens.TokenInfo | None = None, raw_data: bytes | None = None, + is_raw_data: bool = False, ) -> Awaitable[None]: from trezor.ui.layouts.lvgl.altcoin import confirm_total_ton @@ -37,6 +38,7 @@ def require_confirm_fee( to_address, format_ton_amount(value + fee_limit, None) if token is None else None, raw_data=raw_data, + is_raw_data=is_raw_data, ) diff --git a/core/src/apps/ton/sign_message.py b/core/src/apps/ton/sign_message.py index 43187e79a..34717a19f 100644 --- a/core/src/apps/ton/sign_message.py +++ b/core/src/apps/ton/sign_message.py @@ -64,10 +64,14 @@ async def sign_message( raise ValueError("Address cannot be None") await confirm_unknown_token_transfer(ctx, msg.jetton_master_address) + amount = msg.jetton_amount if is_jetton_transfer else msg.ton_amount + if amount is None: + raise ValueError("Amount cannot be None") + show_details = await require_show_overview( ctx, recipient, - msg.ton_amount, + amount, token, ) @@ -77,9 +81,10 @@ async def sign_message( ctx, from_address=address, to_address=recipient, - value=msg.ton_amount, + value=amount, token=token, raw_data=comment if comment else None, + is_raw_data=msg.is_raw_data, ) await confirm_final(ctx, token.symbol if token else "TON") @@ -105,6 +110,7 @@ async def sign_message( seqno=msg.seqno, expire_at=msg.expire_at, payload=payload, + is_raw_data=msg.is_raw_data, send_mode=msg.mode, ext_to=None if is_jetton_transfer else msg.ext_destination, ext_amount=None if is_jetton_transfer else msg.ext_ton_amount, diff --git a/core/src/apps/ton/tonsdk/contract/wallet/_wallet_contract.py b/core/src/apps/ton/tonsdk/contract/wallet/_wallet_contract.py index df5672650..ba6e2a9ff 100755 --- a/core/src/apps/ton/tonsdk/contract/wallet/_wallet_contract.py +++ b/core/src/apps/ton/tonsdk/contract/wallet/_wallet_contract.py @@ -46,6 +46,7 @@ def create_transaction_digest( seqno: int, expire_at: int, payload: Union[Cell, str, bytes, None] = None, + is_raw_data: bool = False, send_mode=SendModeEnum.ignore_errors | SendModeEnum.pay_gas_separately, state_init=None, ext_to: List[str] = None, @@ -56,6 +57,7 @@ def create_transaction_digest( if payload: if isinstance(payload, str): # check payload type + # if is_raw_data: if payload.startswith("b5ee9c72"): payload_cell = Cell.one_from_boc(payload) else: diff --git a/core/src/trezor/lvglui/scrs/template.py b/core/src/trezor/lvglui/scrs/template.py index 46502d6c5..0af8785dc 100644 --- a/core/src/trezor/lvglui/scrs/template.py +++ b/core/src/trezor/lvglui/scrs/template.py @@ -1563,6 +1563,7 @@ def __init__( token_id=None, evm_chain_id=None, raw_data=None, + is_raw_data=False, sub_icon_path=None, striped=False, ): @@ -1653,10 +1654,11 @@ def __init__( self.data = self.data_str self.item_data = CardItem( self.container, - _(i18n_keys.LIST_KEY__DATA__COLON), + _(i18n_keys.LIST_KEY__DATA__COLON) if self.data.startswith("b5ee9c72") else _(i18n_keys.LIST_KEY__MEMO__COLON), self.data, - "A:/res/group-icon-data.png", + "A:/res/group-icon-data.png" if self.data.startswith("b5ee9c72") else "A:/res/group-icon-more.png", ) + if self.long_data: self.show_full_data = NormalButton( self.item_data.content, _(i18n_keys.BUTTON__VIEW_DATA) @@ -1669,6 +1671,21 @@ def __init__( self.show_full_data.remove_style(None, lv.PART.MAIN | lv.STATE.PRESSED) self.show_full_data.add_event_cb(self.on_click, lv.EVENT.CLICKED, None) + def on_click(self, event_obj): + code = event_obj.code + target = event_obj.get_target() + if code == lv.EVENT.CLICKED: + if target == self.show_full_data: + PageAbleMessage( + _(i18n_keys.TITLE__VIEW_DATA), + self.data_str, + None, + primary_color=self.primary_color, + font=font_GeistMono28, + confirm_text=None, + cancel_text=None, + ) + class TransactionDetailsTRON(FullSizeWindow): def __init__( diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index 0ed77eef1..2830151a5 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -8709,6 +8709,7 @@ class TonSignMessage(protobuf.MessageType): jetton_amount: "int | None" fwd_fee: "int" comment: "str | None" + is_raw_data: "bool" mode: "int" seqno: "int" expire_at: "int" @@ -8737,6 +8738,7 @@ def __init__( jetton_amount: "int | None" = None, fwd_fee: "int | None" = None, comment: "str | None" = None, + is_raw_data: "bool | None" = None, mode: "int | None" = None, wallet_version: "TonWalletVersion | None" = None, wallet_id: "int | None" = None, diff --git a/core/src/trezor/ui/layouts/lvgl/altcoin.py b/core/src/trezor/ui/layouts/lvgl/altcoin.py index ecb9c1153..b2daf65f2 100644 --- a/core/src/trezor/ui/layouts/lvgl/altcoin.py +++ b/core/src/trezor/ui/layouts/lvgl/altcoin.py @@ -170,6 +170,7 @@ async def confirm_total_ton( token_id: int | None = None, evm_chain_id: int | None = None, raw_data: bytes | None = None, + is_raw_data: bool = False, ) -> None: from trezor.lvglui.scrs.template import TransactionDetailsTON @@ -187,6 +188,7 @@ async def confirm_total_ton( token_id=str(token_id), evm_chain_id=evm_chain_id, raw_data=raw_data, + is_raw_data=is_raw_data, sub_icon_path=ctx.icon_path, striped=striped, ) diff --git a/python/src/trezorlib/cli/ton.py b/python/src/trezorlib/cli/ton.py index e58fb334e..158555b71 100644 --- a/python/src/trezorlib/cli/ton.py +++ b/python/src/trezorlib/cli/ton.py @@ -75,6 +75,7 @@ def get_address(client: "TrezorClient", @click.option("-ja", "--jetton_amount", type=int) @click.option("-f", "--fwd_fee", type=int) @click.option("-c", "--comment", type=str) +@click.option("-r", "--is_raw_data", is_flag=True) @click.option("-m", "--mode", type=int) @click.option("-s", "--seqno", type=int, required=True) @click.option("-e", "--expire_at", type=int, required=True) @@ -99,6 +100,7 @@ def sign_message(client: "TrezorClient", seqno: int, expire_at: int, comment: str, + is_raw_data: bool, version: messages.TonWalletVersion, wallet_id: int, workchain: messages.TonWorkChain, @@ -124,6 +126,7 @@ def sign_message(client: "TrezorClient", seqno, expire_at, comment, + is_raw_data, version, wallet_id, workchain, diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 81c109261..220e88fb8 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -10799,17 +10799,18 @@ class TonSignMessage(protobuf.MessageType): 6: protobuf.Field("jetton_amount", "uint64", repeated=False, required=False), 7: protobuf.Field("fwd_fee", "uint64", repeated=False, required=False), 8: protobuf.Field("comment", "string", repeated=False, required=False), - 9: protobuf.Field("mode", "uint32", repeated=False, required=False), - 10: protobuf.Field("seqno", "uint32", repeated=False, required=True), - 11: protobuf.Field("expire_at", "uint64", repeated=False, required=True), - 12: protobuf.Field("wallet_version", "TonWalletVersion", repeated=False, required=False), - 13: protobuf.Field("wallet_id", "uint32", repeated=False, required=False), - 14: protobuf.Field("workchain", "TonWorkChain", repeated=False, required=False), - 15: protobuf.Field("is_bounceable", "bool", repeated=False, required=False), - 16: protobuf.Field("is_testnet_only", "bool", repeated=False, required=False), - 17: protobuf.Field("ext_destination", "string", repeated=True, required=False), - 18: protobuf.Field("ext_ton_amount", "uint64", repeated=True, required=False), - 19: protobuf.Field("ext_payload", "string", repeated=True, required=False), + 9: protobuf.Field("is_raw_data", "bool", repeated=False, required=False), + 10: protobuf.Field("mode", "uint32", repeated=False, required=False), + 11: protobuf.Field("seqno", "uint32", repeated=False, required=True), + 12: protobuf.Field("expire_at", "uint64", repeated=False, required=True), + 13: protobuf.Field("wallet_version", "TonWalletVersion", repeated=False, required=False), + 14: protobuf.Field("wallet_id", "uint32", repeated=False, required=False), + 15: protobuf.Field("workchain", "TonWorkChain", repeated=False, required=False), + 16: protobuf.Field("is_bounceable", "bool", repeated=False, required=False), + 17: protobuf.Field("is_testnet_only", "bool", repeated=False, required=False), + 18: protobuf.Field("ext_destination", "string", repeated=True, required=False), + 19: protobuf.Field("ext_ton_amount", "uint64", repeated=True, required=False), + 20: protobuf.Field("ext_payload", "string", repeated=True, required=False), } def __init__( @@ -10828,6 +10829,7 @@ def __init__( jetton_amount: Optional["int"] = None, fwd_fee: Optional["int"] = 0, comment: Optional["str"] = None, + is_raw_data: Optional["bool"] = False, mode: Optional["int"] = 3, wallet_version: Optional["TonWalletVersion"] = TonWalletVersion.V4R2, wallet_id: Optional["int"] = 698983191, @@ -10848,6 +10850,7 @@ def __init__( self.jetton_amount = jetton_amount self.fwd_fee = fwd_fee self.comment = comment + self.is_raw_data = is_raw_data self.mode = mode self.wallet_version = wallet_version self.wallet_id = wallet_id diff --git a/python/src/trezorlib/ton.py b/python/src/trezorlib/ton.py index 97a3cd444..eeebc614e 100644 --- a/python/src/trezorlib/ton.py +++ b/python/src/trezorlib/ton.py @@ -42,6 +42,7 @@ def sign_message(client: "TrezorClient", seqno: int, expire_at: int, comment: str="", + is_raw_data: bool = False, version: messages.TonWalletVersion=messages.TonWalletVersion.V4R2, wallet_id: int = 698983191, workchain: messages.TonWorkChain=messages.TonWorkChain.BASECHAIN, @@ -65,6 +66,7 @@ def sign_message(client: "TrezorClient", seqno=seqno, expire_at=expire_at, version=version, + is_raw_data=is_raw_data, wallet_id=wallet_id, workchain=workchain, bounceable=bounceable,