Add read-only Tron (TRC20) chain family support (#9)

* Add read-only Tron (TRC20) chain family support

Adds Tron as a third chain family alongside Substrate and EVM:
address derivation (BIP44 coin type 195, secp256k1 reused from the
existing Ethereum path, Base58Check encoding), TronGrid-backed TRX
and TRC20 USDT balance display, and a Room migration for the new
per-account Tron key/address columns. Read-only only — no send,
signing, or broadcast support yet.

* fix: exhaustive when branches for Trc20/TronNative asset types

ChainExt.kt's onChainAssetId and Common.kt's existentialDepositError
both switch exhaustively over Chain.Asset.Type and didn't have cases
for the new Trc20/TronNative variants, breaking compilation. Trc20
mirrors EvmErc20 (contract address as the on-chain id, dust burns
rather than transfers on removal); TronNative mirrors EvmNative.
This commit is contained in:
2026-07-07 06:03:20 -07:00
committed by GitHub
parent 85bde7e448
commit 46d2a91510
39 changed files with 864 additions and 41 deletions
@@ -45,6 +45,13 @@ interface LightMetaAccount {
val substrateAccountId: ByteArray?
val ethereumAddress: ByteArray?
val ethereumPublicKey: ByteArray?
/**
* Tron account id (same keccak-based derivation as [ethereumAddress], different derivation path and address encoding).
* Only populated for [Type.SECRETS] wallets today (Phase 1 read-only support) - null for every other wallet type.
*/
val tronAddress: ByteArray?
val tronPublicKey: ByteArray?
val isSelected: Boolean
val name: String
val type: Type
@@ -81,6 +88,8 @@ fun LightMetaAccount(
type: LightMetaAccount.Type,
status: LightMetaAccount.Status,
parentMetaId: Long?,
tronAddress: ByteArray? = null,
tronPublicKey: ByteArray? = null,
) = object : LightMetaAccount {
override val id: Long = id
override val globallyUniqueId: String = globallyUniqueId
@@ -89,6 +98,8 @@ fun LightMetaAccount(
override val substrateAccountId: ByteArray? = substrateAccountId
override val ethereumAddress: ByteArray? = ethereumAddress
override val ethereumPublicKey: ByteArray? = ethereumPublicKey
override val tronAddress: ByteArray? = tronAddress
override val tronPublicKey: ByteArray? = tronPublicKey
override val isSelected: Boolean = isSelected
override val name: String = name
override val type: LightMetaAccount.Type = type
@@ -155,7 +166,7 @@ sealed class MultisigAvailability {
}
fun MetaAccount.isUniversal(): Boolean {
return substrateAccountId != null || ethereumAddress != null
return substrateAccountId != null || ethereumAddress != null || tronAddress != null
}
fun MultisigAvailability.singleChainId(): ChainId? {