Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion common/protob/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
for fn in sorted(glob(os.path.join(MYDIR, "messages-*.proto"))):
with open(fn, "rt") as f:
prefix = EXPECTED_PREFIX_RE.search(fn).group(1).capitalize()
if prefix in ("Bitcoin", "Bootloader", "Common", "Crypto", "Management", "Ton"):
if prefix in (
"Bitcoin",
"Bootloader",
"Common",
"Crypto",
"Management",
"Ton",
"Tron",
):
continue
if prefix == "Nem":
prefix = "NEM"
Expand Down
1 change: 1 addition & 0 deletions common/protob/messages-polkadot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ message PolkadotSignTx {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
required bytes raw_tx = 2; // serialized raw transaction
required string network = 3; // Network name
optional uint32 prefix = 4; // SS58 address-type
}

/**
Expand Down
31 changes: 27 additions & 4 deletions common/protob/messages-tron.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ message TronSignTx {
required bytes ref_block_bytes = 2; // Reference block number
required bytes ref_block_hash = 3; // Reference block hash
required uint64 expiration = 4; // Transaction expiration
optional string data = 5; // Extra transaction info
optional bytes data = 5; // Extra transaction info
required TronContract contract = 6; // Contract messages
required uint64 timestamp = 7; // UTC timestamp
optional uint64 fee_limit = 8; // Fee limit for smartcontracts
Expand Down Expand Up @@ -63,6 +63,7 @@ message TronSignTx {
enum TronResourceCode {
BANDWIDTH = 0x00;
ENERGY = 0x01;
TRON_POWER = 0x02;
}

// Freeze TRX balance
Expand Down Expand Up @@ -98,14 +99,26 @@ message TronSignTx {
optional uint64 balance = 3;
optional string receiver_address = 4;
optional bool lock = 5;
optional uint64 lock_period = 6;
}
message TronUnDelegateResourceContract {
optional TronResourceCode resource = 2;
optional uint64 balance = 3;
optional string receiver_address = 4;
}

message TronCancelAllUnfreezeV2Contract {
}
// Vote Witness Contract
message TronVoteWitnessContract {
message Vote {
required string vote_address = 1;
required uint32 vote_count = 2;
}
repeated Vote votes = 2;
optional bool support = 3;
}
Comment thread
somebodyLi marked this conversation as resolved.
optional TronTransferContract transfer_contract = 2;
optional TronVoteWitnessContract vote_witness_contract = 4;
optional TronFreezeBalanceContract freeze_balance_contract = 11;
optional TronUnfreezeBalanceContract unfreeze_balance_contract = 12;
optional TronWithdrawBalanceContract withdraw_balance_contract = 13;
Expand All @@ -115,6 +128,10 @@ 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;
}
}

Expand All @@ -127,14 +144,20 @@ message TronSignedTx {
optional bytes serialized_tx = 2; // Serialized transaction
}

enum TronMessageType {
V1 = 1 [deprecated=true];
V2 = 2;
}
Comment thread
somebodyLi marked this conversation as resolved.

/**
* Request: Ask device to sign message
* @next TronMessageSignature
* @next Failure
*/
message TronSignMessage {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
required bytes message = 2; // message to be signed
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
required bytes message = 2; // message to be signed
optional TronMessageType message_type = 3[default = V1]; // message type
}

/**
Expand Down
4 changes: 2 additions & 2 deletions core/embed/firmware/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#define FIX_VERSION_BUILD 99

#define ONEKEY_VERSION_MAJOR 4
#define ONEKEY_VERSION_MINOR 11
#define ONEKEY_VERSION_MINOR 12
Comment thread
somebodyLi marked this conversation as resolved.
#define ONEKEY_VERSION_PATCH 0
#define ONEKEY_VERSION_BUILD 0

#define ONEKEY_VERSION "4.11.0"
#define ONEKEY_VERSION "4.12.0"
4 changes: 4 additions & 0 deletions core/src/all_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
import trezor.enums.TonWalletVersion
trezor.enums.TonWorkChain
import trezor.enums.TonWorkChain
trezor.enums.TronMessageType
import trezor.enums.TronMessageType
trezor.enums.TronResourceCode
import trezor.enums.TronResourceCode
trezor.enums.WordRequestType
Expand Down Expand Up @@ -885,6 +887,8 @@
import apps.tron.get_address
apps.tron.layout
import apps.tron.layout
apps.tron.providers
import apps.tron.providers
apps.tron.serialize
import apps.tron.serialize
apps.tron.sign_message
Expand Down
2 changes: 0 additions & 2 deletions core/src/apps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,8 @@ async def handle_CancelAuthorization(

def set_homescreen() -> None:
import lvgl as lv # type: ignore[Import "lvgl" could not be resolved]
from trezor import uart

ble_name = storage.device.get_ble_name()
uart.get_ble_con_status()
if storage.device.is_initialized():
dev_state = get_state()
device_name = storage.device.get_label()
Expand Down
11 changes: 5 additions & 6 deletions core/src/apps/management/recovery_device/homescreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from trezor.messages import Success
from trezor.ui.layouts import show_onekey_app_guide, show_popup, show_success

from apps.base import set_homescreen
from apps.common import mnemonic
from apps.homescreen.homescreen import homescreen

Expand Down Expand Up @@ -158,11 +157,11 @@ async def _finish_recovery(
header=_(i18n_keys.TITLE__WALLET_IS_READY),
button=_(i18n_keys.BUTTON__CONTINUE),
)
if isinstance(ctx, wire.DummyContext):
utils.make_show_app_guide()
else:
await show_onekey_app_guide()
set_homescreen()
# if isinstance(ctx, wire.DummyContext):
# utils.make_show_app_guide()
# else:
await show_onekey_app_guide()
# set_homescreen()
Comment thread
somebodyLi marked this conversation as resolved.
return Success(message="Device recovered")


Expand Down
8 changes: 4 additions & 4 deletions core/src/apps/management/reset_device/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ async def reset_device(ctx: wire.Context, msg: ResetDevice) -> Success:
if not __debug__:
await show_bip39_dotmap(ctx, secret)
await layout.show_backup_success(ctx)
if isinstance(ctx, wire.DummyContext):
utils.make_show_app_guide()
else:
await show_onekey_app_guide()
# if isinstance(ctx, wire.DummyContext):
# utils.make_show_app_guide()
# else:
await show_onekey_app_guide()
Comment thread
somebodyLi marked this conversation as resolved.
except BaseException as e:
raise e
else:
Expand Down
10 changes: 8 additions & 2 deletions core/src/apps/polkadot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
CURVE = "secp256k1"
SLIP44_ID = 354
PATTERN = PATTERN_BIP44
PRIMARY_COLOR = 0xE6007A
PRIMARY_COLOR_KSM = 0xFFFFFF
PRIMARY_COLOR = 0x00FF33
PRIMARY_COLOR_KSM = 0x00FF33
PRIMARY_COLOR_WESTEND = 0x969696
PRIMARY_COLOR_ASTAR = 0x04E2FE
PRIMARY_COLOR_JOY = 0x4038FF
PRIMARY_COLOR_MAMTA = 0x26C8BF
PRIMARY_COLOR_HYDRATION = 0x00FF33
PRIMARY_COLOR_BIFROST = 0x00FF33
PRIMARY_COLOR_BIFROST_KSMC = 0x00FF33
ICON = "A:/res/chain-dot.png"
ICON_KSM = "A:/res/chain-kusama.png"
ICON_WESTEND = "A:/res/chain-westend.png"
ICON_ASTAR = "A:/res/chain-astar.png"
ICON_JOY = "A:/res/chain-joystream.png"
ICON_MANTA = "A:/res/chain-manta.png"
ICON_HYDRATION = "A:/res/chain-hydration.png"
ICON_BIFROST = "A:/res/chain-bifrost.png"
ICON_BIFROST_KSM = "A:/res/chain-bifrost-ksm.png"
41 changes: 38 additions & 3 deletions core/src/apps/polkadot/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
from . import (
ICON,
ICON_ASTAR,
ICON_BIFROST,
ICON_BIFROST_KSM,
ICON_HYDRATION,
ICON_JOY,
ICON_KSM,
ICON_MANTA,
ICON_WESTEND,
PRIMARY_COLOR,
PRIMARY_COLOR_ASTAR,
PRIMARY_COLOR_BIFROST,
PRIMARY_COLOR_BIFROST_KSMC,
PRIMARY_COLOR_HYDRATION,
PRIMARY_COLOR_JOY,
PRIMARY_COLOR_KSM,
PRIMARY_COLOR_MAMTA,
Expand All @@ -30,6 +36,9 @@
["astar", 5],
["joystream", 126],
["manta", 77],
["hydration", 0],
["bifrost", 0],
["bifrost-ksm", 0],
]

COIN_AMOUNT_DECIMAL_PLACES = 10
Expand All @@ -41,6 +50,8 @@
ASTAR_COIN_TICKER = "ASTR"
JOY_COIN_TICKER = "JOY"
MANTA_COIN_TICKER = "MANTA"
HYDRATION_COIN_TICKER = "HDX"
BIFROST_COIN_TICKER = "BNC"


def ss58_encode(address: bytes, ss58_format: int = 42) -> str:
Expand Down Expand Up @@ -118,6 +129,30 @@ def update_chain_res(ctx: Context, network: str) -> tuple[str, str, int]:
chain_name = "Manta"
symbol = MANTA_COIN_TICKER
decimal = COIN_AMOUNT_DECIMAL_PLACES_18
elif network == "hydration":
ctx.primary_color, ctx.icon_path = (
lv.color_hex(PRIMARY_COLOR_HYDRATION),
ICON_HYDRATION,
)
chain_name = "Hydration"
symbol = HYDRATION_COIN_TICKER
decimal = COIN_AMOUNT_DECIMAL_PLACES_12
elif network == "bifrost":
ctx.primary_color, ctx.icon_path = (
lv.color_hex(PRIMARY_COLOR_BIFROST),
ICON_BIFROST,
)
chain_name = "Bifrost"
symbol = BIFROST_COIN_TICKER
decimal = COIN_AMOUNT_DECIMAL_PLACES_12
elif network == "bifrost-ksm":
ctx.primary_color, ctx.icon_path = (
lv.color_hex(PRIMARY_COLOR_BIFROST_KSMC),
ICON_BIFROST_KSM,
)
chain_name = "Bifrost-KSM"
symbol = BIFROST_COIN_TICKER
decimal = COIN_AMOUNT_DECIMAL_PLACES_12
else:
ctx.primary_color, ctx.icon_path = lv.color_hex(PRIMARY_COLOR), ICON
chain_name = "UNKN Chain"
Expand All @@ -126,10 +161,10 @@ def update_chain_res(ctx: Context, network: str) -> tuple[str, str, int]:
return chain_name, symbol, decimal


def get_address_type(network: str) -> int:
address_type = 42
def get_address_type(network: str, preset_prefix: int | None = None) -> int:
address_type = preset_prefix if preset_prefix is not None else 42
for element in POLKADOT_ADDRESS_TYPES:
if network == element[0]:
address_type = element[1]

break
return address_type
2 changes: 1 addition & 1 deletion core/src/apps/polkadot/sign_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def sign_tx(

node = keychain.derive(msg.address_n)
public_key = ed25519.publickey(node.private_key())
address_type = helper.get_address_type(msg.network)
address_type = helper.get_address_type(msg.network, msg.prefix)
address = helper.ss58_encode(public_key, address_type)
chain_name, symbol, decimal = helper.update_chain_res(ctx, msg.network)
tx = transaction.Transaction.deserialize(msg.raw_tx, msg.network)
Expand Down
Loading
Loading